Sign in to follow this  
Followers 0
sitedude

Need Help with AutoIt Script. (Blob Image 5-5-5 BMP)

15 posts in this topic

I am trying to find a simple way to replace images on an Innotab (kids vtech device)

The images are stored in a SQLite database in Blob Format.

The images are Bmp 5-5-5 (without a header)

I am able to view them using this AutoIT script

http://pastebin.com/v2dyRyBG

The above link is the auto it script

the "SELECT thumbnail FROM Games_info where pkey='3'" pulls the blob file from the database

Here is the blob file I saved directly from the database

http://wikisend.com/download/239802/blobthumbnail

Does anyone know an easy way to possible edit this blob file? Or a way I can make a 57x57 a 5-5-5 bmp blob without a header so i can insert it into the SQLite db?

Here is a link to the innopad.db file that the AutoIt script reads from

http://wikisend.com/download/393450/Innopad.db

Share this post


Link to post
Share on other sites



Your post reminds me with albeit a little bit different.

In fact your question seems to boil down to: "how do I remove the header of a .BMP image format?"

Maybe a title more along this line would attract a GDI+ guru (UEZ?).


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

If the problem is what jchd said then the bitmap header consist of first 54 bytes. So you just need to remove these bytes.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

So I could manually do this you think? How would I save in the 5-5-5 format? Once I save in the 555 format I could use a hex editor to use the first 54 bytes of the image?

Share this post


Link to post
Share on other sites

I believe I can remove them through command line like this

tail -c +54 picwith54bytes.bmp > picwithout54bytes.bmp.

I guess my main problem is now, what image editor can save a 5-5-5 bmp (I believe 15 bit)

Share this post


Link to post
Share on other sites

It's pretty simple, because you can clone an image in this format using GDI+. Please let me some minutes to write an example if you need one.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

That would be awesome!! You would be my hero. In Autoit format?

Share this post


Link to post
Share on other sites

#include <GDIPlus.au3>

_GDIPlus_Startup()

$hImage = _GDIPlus_BitmapCreateFromFile("your_bitmap.bmp")
$iWidth = _GDIPlus_ImageGetWidth($hImage)
$iHeight = _GDIPlus_ImageGetHeight($hImage)

; I think this is what you call 5-5-5 bitmap
; or you can check the documentation of this function for other formats
$hBitmap = _GDIPlus_BitmapCloneArea($hImage,0,0,$iWidth,$iHeight,$GDIP_PXF16RGB555)

; Now you can do whatever you want with your new bitmap

_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_BitmapDispose($hImage)
_GDIPlus_Shutdown()


When the words fail... music speaks

Share this post


Link to post
Share on other sites

Andreik How do I save it to another file? for example if I open test.bmp and want to save it as a 555 bmp.

I tried your code an added this

#include <GDIPlus.au3>

_GDIPlus_Startup()

$hImage = _GDIPlus_BitmapCreateFromFile(@MyDocumentsDir & "test.bmp")

$iWidth = _GDIPlus_ImageGetWidth($hImage)

$iHeight = _GDIPlus_ImageGetHeight($hImage)

; I think this is what you call 5-5-5 bitmap

; or you can check the documentation of this function for other formats

$hBitmap = _GDIPlus_BitmapCloneArea($hImage,0,0,$iWidth,$iHeight,$GDIP_PXF16RGB555)

_GDIPlus_ImageSaveToFile($hBitmap , @MyDocumentsDir & "test555.bmp");

; Now you can do whatever you want with your new bitmap

_GDIPlus_BitmapDispose($hBitmap)

_GDIPlus_BitmapDispose($hImage)

_GDIPlus_Shutdown()

Share this post


Link to post
Share on other sites

And does not work? In case it doesn't you can use _GDIPlus_ImageSaveToFileEx() where you can specify the encoder.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

That's my biggest problem, I dont know the encoder or anything to save it as a 5-5-5. I think you are getting very close. Do you think you could give me an example of

loading the test.bmp

converting it to RGB 555

Then save as test2.bmp

Share this post


Link to post
Share on other sites

I got it to save but not as RGB 555

#include <GDIPlus.au3>

Local $hBitmap, $hImage, $sCLSID, $tData, $tParams

_GDIPlus_Startup()

$hImage = _GDIPlus_BitmapCreateFromFile("sponge.bmp")

$iWidth = _GDIPlus_ImageGetWidth($hImage)

$iHeight = _GDIPlus_ImageGetHeight($hImage)

; I think this is what you call 5-5-5 bitmap

; or you can check the documentation of this function for other formats

$hBitmap = _GDIPlus_BitmapCloneArea($hImage,0,0,$iWidth,$iHeight,$GDIP_PXF16RGB555)

$sCLSID = _GDIPlus_EncodersGetCLSID ("BMP")

; Now you can do whatever you want with your new bitmap

_GDIPlus_ImageSaveToFileEx ($hImage, "01.bmp", $sCLSID, DllStructGetPtr($tParams))

_GDIPlus_BitmapDispose($hBitmap)

_GDIPlus_BitmapDispose($hImage)

_GDIPlus_Shutdown()

Is there an $sCLSID = _GDIPlus_EncodersGetCLSID Encoder I can declare to save as RGB555 BMP?

Share this post


Link to post
Share on other sites

For some reasons GDI+ doesn't work as I expected but you can use also and you'll do this work for sure.

#include <FreeImage.au3>

_FreeImage_LoadDLL()
_FreeImage_Initialise()

$hImage = _FreeImage_LoadU($FIF_BMP,@ScriptDir & "your_bitmap.bmp",0)
$h555 = _FreeImage_ConvertTo16Bits555($hImage)
_FreeImage_SaveU($FIF_BMP,$h555,@ScriptDir & "bitmap555.bmp",0)
_FreeImage_Unload($h555)
_FreeImage_Unload($hImage)

_FreeImage_DeInitialise()
_FreeImage_UnLoadDLL()

When the words fail... music speaks

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Is this working?

#include <ScreenCapture.au3>

$s555Bmp = @ScriptDir & "TestBMP555.bmp"
_GDIPlus_Startup()

Global $iW = 57, $iH = 57
Global $hHBitmap = _ScreenCapture_Capture("", 0, 0, $iW, $iH)
Global $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap)
_WinAPI_DeleteObject($hHBitmap)

Global $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", $GDIP_PXF16RGB555, "ptr", 0, "int*", 0) ;create RGB555 bitmap
Global $hBmp555 = $aResult[6]
Global $hContext = _GDIPlus_ImageGetGraphicsContext($hBmp555)
_GDIPlus_GraphicsDrawImageRect($hContext, $hBitmap, 0, 0, $iW, $iH) ;copy captured image 24bit image to RGB555 bitmap
_GDIPlus_ImageSaveToFile($hBmp555, $s555Bmp) ;save to a bmp file
_GDIPlus_GraphicsDispose($hContext)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_BitmapDispose($hBmp555)
_GDIPlus_Shutdown()

;load bitmap and cut off first 54 header bytes and save it to a new file
Global $iFileSize = FileGetSize($s555Bmp)
Global $hFile = FileOpen($s555Bmp, 16)
Global $iPos = FileSetPos($hFile, 54, $FILE_BEGIN)
Global $binBOB = FileRead($hFile, $iFileSize - 54)
FileClose($hFile)

$hFile = FileOpen(@ScriptDir & "Blob555", 18)
FileWrite($hFile, $binBOB)
FileClose($hFile)

ShellExecute($s555Bmp)

Br,

UEZ

Edited by UEZ
1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

judging by the size of resulting bitmap seems to work well.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0