Jump to content

Recommended Posts

Posted

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

Posted

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)

Posted

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?

Posted

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)

Posted

#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()

Posted

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()

Posted

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

Posted

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?

Posted

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()
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

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...