sitedude Posted December 8, 2012 Share Posted December 8, 2012 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 scripthttp://pastebin.com/v2dyRyBGThe above link is the auto it scriptthe "SELECT thumbnail FROM Games_info where pkey='3'" pulls the blob file from the databaseHere is the blob file I saved directly from the databasehttp://wikisend.com/download/239802/blobthumbnailDoes 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 fromhttp://wikisend.com/download/393450/Innopad.db Link to comment Share on other sites More sharing options...
jchd Posted December 8, 2012 Share Posted December 8, 2012 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 hereRegExp tutorial: enough to get startedPCRE 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) Link to comment Share on other sites More sharing options...
Andreik Posted December 8, 2012 Share Posted December 8, 2012 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. Link to comment Share on other sites More sharing options...
sitedude Posted December 8, 2012 Author Share Posted December 8, 2012 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? Link to comment Share on other sites More sharing options...
sitedude Posted December 8, 2012 Author Share Posted December 8, 2012 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) Link to comment Share on other sites More sharing options...
Andreik Posted December 8, 2012 Share Posted December 8, 2012 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. Link to comment Share on other sites More sharing options...
sitedude Posted December 8, 2012 Author Share Posted December 8, 2012 That would be awesome!! You would be my hero. In Autoit format? Link to comment Share on other sites More sharing options...
Andreik Posted December 8, 2012 Share Posted December 8, 2012 #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. Link to comment Share on other sites More sharing options...
sitedude Posted December 8, 2012 Author Share Posted December 8, 2012 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() Link to comment Share on other sites More sharing options...
Andreik Posted December 8, 2012 Share Posted December 8, 2012 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. Link to comment Share on other sites More sharing options...
sitedude2k4 Posted December 8, 2012 Share Posted December 8, 2012 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 Link to comment Share on other sites More sharing options...
sitedude2k4 Posted December 8, 2012 Share Posted December 8, 2012 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? Link to comment Share on other sites More sharing options...
Andreik Posted December 8, 2012 Share Posted December 8, 2012 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. Link to comment Share on other sites More sharing options...
UEZ Posted December 9, 2012 Share Posted December 9, 2012 (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 December 9, 2012 by UEZ Andreik 1 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Andreik Posted December 9, 2012 Share Posted December 9, 2012 judging by the size of resulting bitmap seems to work well. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now