Advertisement
Guest User

innotab blob reader

a guest
Dec 7th, 2012
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. #include<winapi.au3>
  2. #include<sqlite.au3>
  3. #include<windowsconstants.au3>
  4. _SQLite_Startup()
  5. _SQLite_Open(@ScriptDir & "\Innopad.db")
  6. Global $aRow
  7. _SQLite_QuerySingleRow(-1, "SELECT thumbnail FROM Games_info where pkey='3'", $aRow)
  8. _SQLite_Close()
  9. _SQLite_Shutdown()
  10. GUICreate("Test")
  11. $imgIcon = GUICtrlCreatePic("", 10, 10, 57, 57)
  12. GUISetState()
  13. $hLblDC = _WinAPI_GetDC(GUICtrlGetHandle($imgIcon))
  14. $hBitmap = _WinAPI_CreateCompatibleBitmap($hLblDC, 57, 57)
  15. $hDC = _WinAPI_CreateCompatibleDC($hLblDC)
  16. _WinAPI_SelectObject($hDC, $hBitmap)
  17. $aRow[0] = BinaryMid($aRow[0], 9, BinaryLen($aRow[0])-9)
  18. Dim $newRow
  19.  
  20. For $i = 1 To BinaryLen($aRow[0]) Step 171
  21.  
  22. ConsoleWrite("OLD:" & BinaryMid($aRow[0], $i, 171) & '00' & @CRLF)
  23. $newRow &= BinaryToString(BinaryMid($aRow[0], $i, 171) & BinaryMid(0x00,1,2))
  24. ConsoleWrite("NEW:" & BinaryMid($newRow, $i, 173) & @CRLF & @CRLF)
  25.  
  26. ;EXITLOOP
  27. Next
  28. $newRow = Binary($newRow)
  29. ;ConsoleWrite("NEW ROW:" & @CRLF)
  30. ;ConsoleWrite($newRow & @CRLF)
  31. ;EXIT
  32. ;ConsoleWrite($aRow[0] & @CRLF)
  33. ;$tData = DllStructCreate("byte[" & BinaryLen($aRow[0]) & "]")
  34. ;DllStructSetData($tData, 1, $aRow[0])
  35.  
  36. MsgBox(0,"",BinaryLen($aRow[0]) & @CRLF & BinaryLen($newRow))
  37. $tData = DllStructCreate("byte[" & BinaryLen($newRow) & "]")
  38. DllStructSetData($tData, 1, $newRow)
  39.  
  40. $tBITMAPINFOHEADER = DllStructCreate("DWORD biSize;LONG biWidth;LONG biHeight;WORD biPlanes;WORD biBitCount;DWORD biCompression;DWORD biSizeImage;LONG biXPelsPerMeter;LONG biYPelsPerMeter;DWORD biClrUsed;DWORD biClrImportant; DWORD colormap[3]")
  41. DllStructSetData($tBITMAPINFOHEADER, 1, DllStructGetSize($tBITMAPINFOHEADER))
  42. DllStructSetData($tBITMAPINFOHEADER, 2, 57)
  43. DllStructSetData($tBITMAPINFOHEADER, 3, -57)
  44. DllStructSetData($tBITMAPINFOHEADER, 4, 1)
  45. DllStructSetData($tBITMAPINFOHEADER, 5, 16)
  46. ; use default GDI32 16 bit format: 5-5-5
  47. DllStructSetData($tBITMAPINFOHEADER, 6, 0)
  48. ; Choose Colormask manually, example for 5-5-5
  49. ;~ DllStructSetData($tBITMAPINFOHEADER, 6, 3) ;BI_BITFIELDS
  50. ;~ DllStructSetData($tBITMAPINFOHEADER, "colormap", 0x7C00, 1) ;- Red mask
  51. ;~ DllStructSetData($tBITMAPINFOHEADER, "colormap", 0x03E0, 2) ;- Green mask
  52. ;~ DllStructSetData($tBITMAPINFOHEADER, "colormap", 0x001F, 3) ;- Blue mask
  53. _WinAPI_SetDIBits($hLblDC, $hBitmap, 0, 57, DllStructGetPtr($tData), DllStructGetPtr($tBITMAPINFOHEADER), 1)
  54. _WinAPI_ReleaseDC(GUICtrlGetHandle($imgIcon), $hLblDC)
  55. _WinAPI_DeleteDC($hDC)
  56. _GUICtrlStatic_SetImage($imgIcon, $hBitmap)
  57. While GUIGetMsg()<>-3
  58. WEnd
  59.  
  60. ; #FUNCTION# ====================================================================================================================
  61. ; Name...........: _GUICtrlStatic_SetImage
  62. ; Description ...: Sets a HBITMAP to a static control like image or label
  63. ; Syntax.........: _GUICtrlStatic_SetImage($iCtrlId, $hBitmap)
  64. ; Parameters ....: $iCtrlId - CtrlId or handle of Control in the current process
  65. ; $hBitmap - Pointer top Windows HBITMAP
  66. ; Return values .: Success - 1
  67. ; Failure - 0 and set @error:
  68. ; |1 - invalid $pSource
  69. ; |1 - invalid $pSource
  70. ; Author ........: ProgAndy, Zedna
  71. ; Modified.......:
  72. ; Remarks .......:
  73. ; Related .......:
  74. ; Link ..........:
  75. ; Example .......:
  76. ; ===============================================================================================================================
  77. Func _GUICtrlStatic_SetImage($iCtrlId, $hBitmap)
  78. Local Const $STM_SETIMAGE = 0x0172
  79. Local Const $IMAGE_BITMAP = 0
  80. Local Const $SS_BITMAP = 0xE
  81. Local Const $GWL_STYLE = -16
  82. If IsHWnd($iCtrlId) Then
  83. If WinGetProcess($iCtrlId) <> @AutoItPID Then Return SetError(1,0,0)
  84. Else
  85. $iCtrlId = GUICtrlGetHandle($iCtrlId)
  86. If Not $iCtrlId Then Return SetError(2,0,0)
  87. EndIf
  88. ; set SS_BITMAP style to control
  89. Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE)
  90. If @error Then Return SetError(3, 0, 0)
  91. DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP))
  92. If @error Then Return SetError(4, 0, 0)
  93. Local $oldBmp = DllCall("user32.dll", "handle", "SendMessageW", "hwnd", $iCtrlId, "int", $STM_SETIMAGE, "wparam", $IMAGE_BITMAP, "handle", $hBitmap)
  94. If @error Then Return SetError(5, 0, 0)
  95. If $oldBmp[0] Then _WinAPI_DeleteObject($oldBmp[0])
  96. Return 1
  97. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement