Jump to content

Identify SQLite BLOB Image Format


NiVZ
 Share

Recommended Posts

Hello,

I've got a SQLite database (not created by me) which has thumbnails stored in it in a BLOB field. If I paste the raw data from the field into Notepad, turn on word wrap and resize it I can see an ASCII representation of the image.

EDIT: Or if you load it using DOS command, EDIT /176 test.txt

Is there anyway to identify what format the original image is (or does anyone recognise the format)?

The attached test.txt is the raw data I extracted for an image of the 'Peppa Pig' logo.

Any help appreciated.

Thanks,

NiVZ

test.txt

Edited by NiVZ
Link to comment
Share on other sites

Notepad is a _text_ editor and unlikely to show you anything useful. Rather use any hex editor to see the actual file content.

Now, to your SQLite blob question, try downloading SQLite Expert. It has the feature to show you images directly (and embeds an hex editor as well).

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)

Link to comment
Share on other sites

Hi jchd,

I tried SQLite Expert, but the image viewer just shows a black box.

I understand Notepad is a text editor, but I did say it gives an ASCII art style representation of the image, in much the way that an .xpm or other character based image saving formats use - I just can't identify this one. Tried renaming it to all the usual extensions, but I fear that the header info may also have been stripped out before the image was saved to the database as a BLOB.

Thanks,

NiVZ

Link to comment
Share on other sites

Is there anyway to identify what format the original image is (or does anyone recognise the format)?

Using IDENTIFY from the ImageMagick package provided the following data.

[C:DL]
08:49:13 $ identify -verbose test.txt
Image: test.txt
  Format: TXT (Text)
  Class: DirectClass
  Geometry: 612x792+0+0
  Resolution: 72x72
  Print size: 8.5x11
  Units: Undefined
  Type: GrayscaleMatte
  Base type: GrayscaleMatte
  Endianess: Undefined
  Colorspace: RGB
  Depth: 16-bit
  Channel depth:
    gray: 16-bit
    alpha: 1-bit
  Channel statistics:
    Gray:
      min: 0 (0)
      max: 65535 (1)
      mean: 55229.5 (0.842748)
      standard deviation: 22197.2 (0.338707)
      kurtosis: 1.66916
      skewness: -1.86288
    Alpha:
      min: 65535 (1)
      max: 65535 (1)
      mean: 65535 (1)
      standard deviation: 0 (0)
      kurtosis: 0
      skewness: 0
  Colors: 193
  Histogram:
     24284: (    0,    0,    0,65535) #000000000000 black
         3: (    1,    1,    1,65535) #000100010001 rgba(0.0015259%,0.0015259%,0.0015259%,1)
       710: (    4,    4,    4,65535) #000400040004 rgba(0.00610361%,0.00610361%,0.00610361%,1)
        28: (    9,    9,    9,65535) #000900090009 rgba(0.0137331%,0.0137331%,0.0137331%,1)
      1665: (   16,   16,   16,65535) #001000100010 rgba(0.0244144%,0.0244144%,0.0244144%,1)
      2577: (   25,   25,   25,65535) #001900190019 rgba(0.0381476%,0.0381476%,0.0381476%,1)
      3131: (   36,   36,   36,65535) #002400240024 rgba(0.0549325%,0.0549325%,0.0549325%,1)
       555: (   49,   49,   49,65535) #003100310031 rgba(0.0747692%,0.0747692%,0.0747692%,1)
      1115: (   65,   65,   65,65535) #004100410041 rgba(0.0991836%,0.0991836%,0.0991836%,1)
       361: (   82,   82,   82,65535) #005200520052 rgba(0.125124%,0.125124%,0.125124%,1)
       359: (  101,  101,  101,65535) #006500650065 rgba(0.154116%,0.154116%,0.154116%,1)
         7: (  122,  122,  122,65535) #007A007A007A rgba(0.18616%,0.18616%,0.18616%,1)
       707: (  145,  145,  145,65535) #009100910091 rgba(0.221256%,0.221256%,0.221256%,1)
       546: (  198,  198,  198,65535) #00C600C600C6 rgba(0.302129%,0.302129%,0.302129%,1)
         3: (  227,  227,  227,65535) #00E300E300E3 rgba(0.34638%,0.34638%,0.34638%,1)
         7: (  258,  258,  258,65535) #010201020102 rgba(0.393683%,0.393683%,0.393683%,1)
        39: (  291,  291,  291,65535) #012301230123 rgba(0.444038%,0.444038%,0.444038%,1)
       556: (  364,  364,  364,65535) #016C016C016C rgba(0.555428%,0.555428%,0.555428%,1)
        20: (  403,  403,  403,65535) #019301930193 rgba(0.614939%,0.614939%,0.614939%,1)
         6: (  444,  444,  444,65535) #01BC01BC01BC rgba(0.677501%,0.677501%,0.677501%,1)
       559: (  488,  488,  488,65535) #01E801E801E8 rgba(0.74464%,0.74464%,0.74464%,1)
        23: (  581,  581,  581,65535) #024502450245 rgba(0.886549%,0.886549%,0.886549%,1)
        11: (  630,  630,  630,65535) #027602760276 rgba(0.961318%,0.961318%,0.961318%,1)
       533: (  681,  681,  681,65535) #02A902A902A9 rgba(1.03914%,1.03914%,1.03914%,1)
      1112: (  735,  735,  735,65535) #02DF02DF02DF rgba(1.12154%,1.12154%,1.12154%,1)
       549: (  790,  790,  790,65535) #031603160316 rgba(1.20546%,1.20546%,1.20546%,1)
       560: (  907,  907,  907,65535) #038B038B038B rgba(1.38399%,1.38399%,1.38399%,1)
         4: ( 1098, 1098, 1098,65535) #044A044A044A rgba(1.67544%,1.67544%,1.67544%,1)
        16: ( 1165, 1165, 1165,65535) #048D048D048D rgba(1.77768%,1.77768%,1.77768%,1)
       553: ( 1235, 1235, 1235,65535) #04D304D304D3 rgba(1.88449%,1.88449%,1.88449%,1)
        35: ( 1306, 1306, 1306,65535) #051A051A051A rgba(1.99283%,1.99283%,1.99283%,1)
       698: ( 1380, 1380, 1380,65535) #056405640564 rgba(2.10575%,2.10575%,2.10575%,1)
       358: ( 1455, 1455, 1455,65535) #05AF05AF05AF rgba(2.22019%,2.22019%,2.22019%,1)
      1060: ( 1533, 1533, 1533,65535) #05FD05FD05FD rgba(2.33921%,2.33921%,2.33921%,1)
         3: ( 1613, 1613, 1613,65535) #064D064D064D rgba(2.46128%,2.46128%,2.46128%,1)
       899: ( 1694, 1694, 1694,65535) #069E069E069E rgba(2.58488%,2.58488%,2.58488%,1)
       567: ( 1778, 1778, 1778,65535) #06F206F206F2 rgba(2.71305%,2.71305%,2.71305%,1)
      1105: ( 1951, 1951, 1951,65535) #079F079F079F rgba(2.97704%,2.97704%,2.97704%,1)
       220: ( 2041, 2041, 2041,65535) #07F907F907F9 rgba(3.11437%,3.11437%,3.11437%,1)
       560: ( 2133, 2133, 2133,65535) #085508550855 rgba(3.25475%,3.25475%,3.25475%,1)
      1113: ( 2322, 2322, 2322,65535) #091209120912 rgba(3.54314%,3.54314%,3.54314%,1)
       376: ( 2520, 2520, 2520,65535) #09D809D809D8 rgba(3.84527%,3.84527%,3.84527%,1)
       612: ( 2621, 2621, 2621,65535) #0A3D0A3D0A3D rgba(3.99939%,3.99939%,3.99939%,1)
       576: ( 2725, 2725, 2725,65535) #0AA50AA50AA5 rgba(4.15808%,4.15808%,4.15808%,1)
       573: ( 2939, 2939, 2939,65535) #0B7B0B7B0B7B rgba(4.48463%,4.48463%,4.48463%,1)
       540: ( 3049, 3049, 3049,65535) #0BE90BE90BE9 rgba(4.65248%,4.65248%,4.65248%,1)
       626: ( 3161, 3161, 3161,65535) #0C590C590C59 rgba(4.82338%,4.82338%,4.82338%,1)
        59: ( 3274, 3274, 3274,65535) #0CCA0CCA0CCA rgba(4.9958%,4.9958%,4.9958%,1)
       575: ( 3390, 3390, 3390,65535) #0D3E0D3E0D3E rgba(5.17281%,5.17281%,5.17281%,1)
       536: ( 3508, 3508, 3508,65535) #0DB40DB40DB4 rgba(5.35286%,5.35286%,5.35286%,1)
        48: ( 3628, 3628, 3628,65535) #0E2C0E2C0E2C rgba(5.53597%,5.53597%,5.53597%,1)
       540: ( 3750, 3750, 3750,65535) #0EA60EA60EA6 rgba(5.72213%,5.72213%,5.72213%,1)
      1092: ( 3874, 3874, 3874,65535) #0F220F220F22 rgba(5.91135%,5.91135%,5.91135%,1)
       547: ( 4000, 4000, 4000,65535) #0FA00FA00FA0 rgba(6.10361%,6.10361%,6.10361%,1)
      2763: ( 4128, 4128, 4128,65535) #102010201020 rgba(6.29892%,6.29892%,6.29892%,1)
      1092: ( 4258, 4258, 4258,65535) #10A210A210A2 rgba(6.49729%,6.49729%,6.49729%,1)
         3: ( 4390, 4390, 4390,65535) #112611261126 rgba(6.69871%,6.69871%,6.69871%,1)
         9: ( 4938, 4938, 4938,65535) #134A134A134A rgba(7.53491%,7.53491%,7.53491%,1)
        10: ( 5081, 5081, 5081,65535) #13D913D913D9 rgba(7.75311%,7.75311%,7.75311%,1)
       117: ( 5225, 5225, 5225,65535) #146914691469 rgba(7.97284%,7.97284%,7.97284%,1)
       111: ( 5371, 5371, 5371,65535) #14FB14FB14FB rgba(8.19562%,8.19562%,8.19562%,1)
        20: ( 5821, 5821, 5821,65535) #16BD16BD16BD rgba(8.88228%,8.88228%,8.88228%,1)
       546: ( 5976, 5976, 5976,65535) #175817581758 rgba(9.11879%,9.11879%,9.11879%,1)
       556: ( 6290, 6290, 6290,65535) #189218921892 rgba(9.59792%,9.59792%,9.59792%,1)
        10: ( 6450, 6450, 6450,65535) #193219321932 rgba(9.84207%,9.84207%,9.84207%,1)
         3: ( 6612, 6612, 6612,65535) #19D419D419D4 rgba(10.0893%,10.0893%,10.0893%,1)
        19: ( 6777, 6777, 6777,65535) #1A791A791A79 rgba(10.341%,10.341%,10.341%,1)
         3: ( 7111, 7111, 7111,65535) #1BC71BC71BC7 rgba(10.8507%,10.8507%,10.8507%,1)
         3: ( 7282, 7282, 7282,65535) #1C721C721C72 rgba(11.1116%,11.1116%,11.1116%,1)
       355: ( 7454, 7454, 7454,65535) #1D1E1D1E1D1E rgba(11.3741%,11.3741%,11.3741%,1)
         3: ( 7805, 7805, 7805,65535) #1E7D1E7D1E7D rgba(11.9097%,11.9097%,11.9097%,1)
       349: ( 8164, 8164, 8164,65535) #1FE41FE41FE4 rgba(12.4575%,12.4575%,12.4575%,1)
       358: ( 8346, 8346, 8346,65535) #209A209A209A rgba(12.7352%,12.7352%,12.7352%,1)
       893: ( 8905, 8905, 8905,65535) #22C922C922C9 rgba(13.5882%,13.5882%,13.5882%,1)
         3: ( 9096, 9096, 9096,65535) #238823882388 rgba(13.8796%,13.8796%,13.8796%,1)
         3: ( 9288, 9288, 9288,65535) #244824482448 rgba(14.1726%,14.1726%,14.1726%,1)
         3: ( 9483, 9483, 9483,65535) #250B250B250B rgba(14.4701%,14.4701%,14.4701%,1)
         3: ( 9878, 9878, 9878,65535) #269626962696 rgba(15.0729%,15.0729%,15.0729%,1)
       549: (10078,10078,10078,65535) #275E275E275E rgba(15.378%,15.378%,15.378%,1)
         3: (10281,10281,10281,65535) #282928292829 rgba(15.6878%,15.6878%,15.6878%,1)
         3: (10486,10486,10486,65535) #28F628F628F6 rgba(16.0006%,16.0006%,16.0006%,1)
         3: (11111,11111,11111,65535) #2B672B672B67 rgba(16.9543%,16.9543%,16.9543%,1)
        10: (11324,11324,11324,65535) #2C3C2C3C2C3C rgba(17.2793%,17.2793%,17.2793%,1)
         3: (11539,11539,11539,65535) #2D132D132D13 rgba(17.6074%,17.6074%,17.6074%,1)
       107: (11755,11755,11755,65535) #2DEB2DEB2DEB rgba(17.937%,17.937%,17.937%,1)
       107: (11974,11974,11974,65535) #2EC62EC62EC6 rgba(18.2712%,18.2712%,18.2712%,1)
         3: (12195,12195,12195,65535) #2FA32FA32FA3 rgba(18.6084%,18.6084%,18.6084%,1)
       546: (12869,12869,12869,65535) #324532453245 rgba(19.6368%,19.6368%,19.6368%,1)
       547: (13329,13329,13329,65535) #341134113411 rgba(20.3388%,20.3388%,20.3388%,1)
         3: (13796,13796,13796,65535) #35E435E435E4 rgba(21.0513%,21.0513%,21.0513%,1)
         3: (14513,14513,14513,65535) #38B138B138B1 rgba(22.1454%,22.1454%,22.1454%,1)
         3: (15001,15001,15001,65535) #3A993A993A99 rgba(22.8901%,22.8901%,22.8901%,1)
         3: (15497,15497,15497,65535) #3C893C893C89 rgba(23.6469%,23.6469%,23.6469%,1)
       902: (15748,15748,15748,65535) #3D843D843D84 rgba(24.0299%,24.0299%,24.0299%,1)
       706: (16256,16256,16256,65535) #3F803F803F80 rgba(24.8051%,24.8051%,24.8051%,1)
       560: (16513,16513,16513,65535) #408140814081 rgba(25.1972%,25.1972%,25.1972%,1)
       557: (17296,17296,17296,65535) #439043904390 rgba(26.392%,26.392%,26.392%,1)
      1097: (17828,17828,17828,65535) #45A445A445A4 rgba(27.2038%,27.2038%,27.2038%,1)
       540: (18097,18097,18097,65535) #46B146B146B1 rgba(27.6143%,27.6143%,27.6143%,1)
         3: (18368,18368,18368,65535) #47C047C047C0 rgba(28.0278%,28.0278%,28.0278%,1)
         3: (18641,18641,18641,65535) #48D148D148D1 rgba(28.4443%,28.4443%,28.4443%,1)
       361: (18916,18916,18916,65535) #49E449E449E4 rgba(28.864%,28.864%,28.864%,1)
       544: (20322,20322,20322,65535) #4F624F624F62 rgba(31.0094%,31.0094%,31.0094%,1)
       572: (21190,21190,21190,65535) #52C652C652C6 rgba(32.3339%,32.3339%,32.3339%,1)
       533: (21483,21483,21483,65535) #53EB53EB53EB rgba(32.781%,32.781%,32.781%,1)
       543: (21778,21778,21778,65535) #551255125512 rgba(33.2311%,33.2311%,33.2311%,1)
       540: (22676,22676,22676,65535) #589458945894 rgba(34.6014%,34.6014%,34.6014%,1)
         6: (22980,22980,22980,65535) #59C459C459C4 rgba(35.0652%,35.0652%,35.0652%,1)
        17: (23902,23902,23902,65535) #5D5E5D5E5D5E rgba(36.4721%,36.4721%,36.4721%,1)
         3: (24213,24213,24213,65535) #5E955E955E95 rgba(36.9467%,36.9467%,36.9467%,1)
        22: (24527,24527,24527,65535) #5FCF5FCF5FCF rgba(37.4258%,37.4258%,37.4258%,1)
         4: (24842,24842,24842,65535) #610A610A610A rgba(37.9065%,37.9065%,37.9065%,1)
         3: (25160,25160,25160,65535) #624862486248 rgba(38.3917%,38.3917%,38.3917%,1)
       530: (25479,25479,25479,65535) #638763876387 rgba(38.8785%,38.8785%,38.8785%,1)
         4: (26124,26124,26124,65535) #660C660C660C rgba(39.8627%,39.8627%,39.8627%,1)
         3: (26450,26450,26450,65535) #675267526752 rgba(40.3601%,40.3601%,40.3601%,1)
       559: (26777,26777,26777,65535) #689968996899 rgba(40.8591%,40.8591%,40.8591%,1)
       546: (27772,27772,27772,65535) #6C7C6C7C6C7C rgba(42.3774%,42.3774%,42.3774%,1)
         3: (28445,28445,28445,65535) #6F1D6F1D6F1D rgba(43.4043%,43.4043%,43.4043%,1)
         4: (28785,28785,28785,65535) #707170717071 rgba(43.9231%,43.9231%,43.9231%,1)
         4: (29127,29127,29127,65535) #71C771C771C7 rgba(44.445%,44.445%,44.445%,1)
       559: (29816,29816,29816,65535) #747874787478 rgba(45.4963%,45.4963%,45.4963%,1)
      1091: (30513,30513,30513,65535) #773177317731 rgba(46.5599%,46.5599%,46.5599%,1)
       576: (30865,30865,30865,65535) #789178917891 rgba(47.097%,47.097%,47.097%,1)
         6: (31219,31219,31219,65535) #79F379F379F3 rgba(47.6371%,47.6371%,47.6371%,1)
       560: (31575,31575,31575,65535) #7B577B577B57 rgba(48.1804%,48.1804%,48.1804%,1)
         7: (31933,31933,31933,65535) #7CBD7CBD7CBD rgba(48.7266%,48.7266%,48.7266%,1)
       550: (33018,33018,33018,65535) #80FA80FA80FA rgba(50.3822%,50.3822%,50.3822%,1)
       233: (33384,33384,33384,65535) #826882688268 rgba(50.9407%,50.9407%,50.9407%,1)
         3: (33752,33752,33752,65535) #83D883D883D8 rgba(51.5023%,51.5023%,51.5023%,1)
        16: (34493,34493,34493,65535) #86BD86BD86BD rgba(52.6329%,52.6329%,52.6329%,1)
         3: (34867,34867,34867,65535) #883388338833 rgba(53.2036%,53.2036%,53.2036%,1)
       550: (35243,35243,35243,65535) #89AB89AB89AB rgba(53.7774%,53.7774%,53.7774%,1)
       573: (36383,36383,36383,65535) #8E1F8E1F8E1F rgba(55.5169%,55.5169%,55.5169%,1)
      2236: (36767,36767,36767,65535) #8F9F8F9F8F9F rgba(56.1028%,56.1028%,56.1028%,1)
      1087: (37153,37153,37153,65535) #912191219121 rgba(56.6918%,56.6918%,56.6918%,1)
      1125: (37541,37541,37541,65535) #92A592A592A5 rgba(57.2839%,57.2839%,57.2839%,1)
        16: (37931,37931,37931,65535) #942B942B942B rgba(57.879%,57.879%,57.879%,1)
        16: (38323,38323,38323,65535) #95B395B395B3 rgba(58.4771%,58.4771%,58.4771%,1)
        20: (38717,38717,38717,65535) #973D973D973D rgba(59.0784%,59.0784%,59.0784%,1)
       355: (39113,39113,39113,65535) #98C998C998C9 rgba(59.6826%,59.6826%,59.6826%,1)
       365: (39511,39511,39511,65535) #9A579A579A57 rgba(60.2899%,60.2899%,60.2899%,1)
       550: (39912,39912,39912,65535) #9BE89BE89BE8 rgba(60.9018%,60.9018%,60.9018%,1)
        19: (40314,40314,40314,65535) #9D7A9D7A9D7A rgba(61.5152%,61.5152%,61.5152%,1)
       546: (40718,40718,40718,65535) #9F0E9F0E9F0E rgba(62.1317%,62.1317%,62.1317%,1)
         4: (41124,41124,41124,65535) #A0A4A0A4A0A4 rgba(62.7512%,62.7512%,62.7512%,1)
        32: (41532,41532,41532,65535) #A23CA23CA23C rgba(63.3738%,63.3738%,63.3738%,1)
       548: (41942,41942,41942,65535) #A3D6A3D6A3D6 rgba(63.9994%,63.9994%,63.9994%,1)
       352: (42769,42769,42769,65535) #A711A711A711 rgba(65.2613%,65.2613%,65.2613%,1)
       358: (43185,43185,43185,65535) #A8B1A8B1A8B1 rgba(65.8961%,65.8961%,65.8961%,1)
         3: (44024,44024,44024,65535) #ABF8ABF8ABF8 rgba(67.1763%,67.1763%,67.1763%,1)
       555: (44870,44870,44870,65535) #AF46AF46AF46 rgba(68.4672%,68.4672%,68.4672%,1)
      1151: (45297,45297,45297,65535) #B0F1B0F1B0F1 rgba(69.1188%,69.1188%,69.1188%,1)
        16: (45725,45725,45725,65535) #B29DB29DB29D rgba(69.7719%,69.7719%,69.7719%,1)
       127: (46155,46155,46155,65535) #B44BB44BB44B rgba(70.428%,70.428%,70.428%,1)
       647: (46588,46588,46588,65535) #B5FCB5FCB5FC rgba(71.0887%,71.0887%,71.0887%,1)
      1086: (47458,47458,47458,65535) #B962B962B962 rgba(72.4163%,72.4163%,72.4163%,1)
        72: (47897,47897,47897,65535) #BB19BB19BB19 rgba(73.0861%,73.0861%,73.0861%,1)
        53: (48337,48337,48337,65535) #BCD1BCD1BCD1 rgba(73.7575%,73.7575%,73.7575%,1)
       559: (48780,48780,48780,65535) #BE8CBE8CBE8C rgba(74.4335%,74.4335%,74.4335%,1)
         4: (50119,50119,50119,65535) #C3C7C3C7C3C7 rgba(76.4767%,76.4767%,76.4767%,1)
       901: (50570,50570,50570,65535) #C58AC58AC58A rgba(77.1649%,77.1649%,77.1649%,1)
         3: (51022,51022,51022,65535) #C74EC74EC74E rgba(77.8546%,77.8546%,77.8546%,1)
       574: (51477,51477,51477,65535) #C915C915C915 rgba(78.5489%,78.5489%,78.5489%,1)
       352: (51933,51933,51933,65535) #CADDCADDCADD rgba(79.2447%,79.2447%,79.2447%,1)
       898: (52392,52392,52392,65535) #CCA8CCA8CCA8 rgba(79.9451%,79.9451%,79.9451%,1)
         7: (52852,52852,52852,65535) #CE74CE74CE74 rgba(80.647%,80.647%,80.647%,1)
        17: (53315,53315,53315,65535) #D043D043D043 rgba(81.3535%,81.3535%,81.3535%,1)
         3: (53780,53780,53780,65535) #D214D214D214 rgba(82.063%,82.063%,82.063%,1)
         3: (54246,54246,54246,65535) #D3E6D3E6D3E6 rgba(82.7741%,82.7741%,82.7741%,1)
       550: (54715,54715,54715,65535) #D5BBD5BBD5BB rgba(83.4897%,83.4897%,83.4897%,1)
       895: (55185,55185,55185,65535) #D791D791D791 rgba(84.2069%,84.2069%,84.2069%,1)
         6: (55658,55658,55658,65535) #D96AD96AD96A rgba(84.9287%,84.9287%,84.9287%,1)
         6: (56133,56133,56133,65535) #DB45DB45DB45 rgba(85.6535%,85.6535%,85.6535%,1)
        37: (56610,56610,56610,65535) #DD22DD22DD22 rgba(86.3813%,86.3813%,86.3813%,1)
       559: (57088,57088,57088,65535) #DF00DF00DF00 rgba(87.1107%,87.1107%,87.1107%,1)
        19: (57569,57569,57569,65535) #E0E1E0E1E0E1 rgba(87.8447%,87.8447%,87.8447%,1)
        19: (58052,58052,58052,65535) #E2C4E2C4E2C4 rgba(88.5817%,88.5817%,88.5817%,1)
         3: (58537,58537,58537,65535) #E4A9E4A9E4A9 rgba(89.3217%,89.3217%,89.3217%,1)
         3: (59023,59023,59023,65535) #E68FE68FE68F rgba(90.0633%,90.0633%,90.0633%,1)
       895: (59512,59512,59512,65535) #E878E878E878 rgba(90.8095%,90.8095%,90.8095%,1)
         3: (60003,60003,60003,65535) #EA63EA63EA63 rgba(91.5587%,91.5587%,91.5587%,1)
      1665: (60496,60496,60496,65535) #EC50EC50EC50 rgba(92.311%,92.311%,92.311%,1)
      2322: (60991,60991,60991,65535) #EE3FEE3FEE3F rgba(93.0663%,93.0663%,93.0663%,1)
      1446: (61488,61488,61488,65535) #F030F030F030 rgba(93.8247%,93.8247%,93.8247%,1)
      2540: (61986,61986,61986,65535) #F222F222F222 rgba(94.5846%,94.5846%,94.5846%,1)
       885: (62487,62487,62487,65535) #F417F417F417 rgba(95.3491%,95.3491%,95.3491%,1)
       920: (62990,62990,62990,65535) #F60EF60EF60E rgba(96.1166%,96.1166%,96.1166%,1)
       927: (63495,63495,63495,65535) #F807F807F807 rgba(96.8872%,96.8872%,96.8872%,1)
        52: (64002,64002,64002,65535) #FA02FA02FA02 rgba(97.6608%,97.6608%,97.6608%,1)
       573: (64511,64511,64511,65535) #FBFFFBFFFBFF rgba(98.4375%,98.4375%,98.4375%,1)
       937: (65022,65022,65022,65535) #FDFEFDFEFDFE rgba(99.2172%,99.2172%,99.2172%,1)
    377841: (65535,65535,65535,65535) #FFFFFFFFFFFF white
  Rendering intent: Undefined
  Interlace: None
  Background color: white
  Border color: rgba(223,223,223,1)
  Matte color: grey74
  Transparent color: none
  Compose: Over
  Page geometry: 612x792+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Undefined
  Orientation: Undefined
  Properties:
    date:create: 2012-03-20T08:46:46-05:00
    date:modify: 2012-03-20T08:46:45-05:00
    signature: c4a6800742fb122fad2e372352a4760f5ebf8db2030ff9cd3cc9e61cddb0ce79
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 9.05KB
  Number pixels: 485K
  Pixels per second: 87.4KB
  User time: 5.813u
  Elapsed time: 0:06.546
  Version: ImageMagick 6.7.5-2 2012-02-05 Q16 http://www.imagemagick.org

Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Link to comment
Share on other sites

Thanks JohnQSmith,

Not sure what a lot of that information means. These images are very small, probably around 30x20 pixels so the resolution ImageMagik is suggesting is far too big :oops:

I think it's using some sort of pixmap format (http://www.franz.com/support/documentation/6.2/doc/cg/cg-pixmaps.htm), but I can't see anywhere in the file where it stores colour information.

Thanks,

NiVZ

Edited by NiVZ
Link to comment
Share on other sites

Yeah, after converting it to a JPG and viewing it, it appeared to have interpreted as some sort of a hex dump. I'll see if I can take another look at it.

Edit: Sorry. No joy.

Edited by JohnQSmith

Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Link to comment
Share on other sites

From the little that made thru in text mode I suspect the file is merely a raw bitmap in 16-bit color (possibly 5-6-5) or grayscale.

Can you post the same blob (not truncated by text mode) in binary format after taking care that you grab it in full length?

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)

Link to comment
Share on other sites

Hello,

The images are definitely in colour and not grayscale.

I extracted the image info using sqlite browser 2.0 beta 1 from Sourceforge by double clicking the field and then clicking Extract. But I do notice the data is different when viewed in the database. Doesn't seem to be anyway to extract it in Binary using Sqlite browser so I've uploaded the database with 1 record in the Videos table.

I had to rename it to from .db to .txt to upload it.

Thanks for taking the time to look at this,

NiVZ

test.txt

Link to comment
Share on other sites

Thanks. The blob is 0x3C80 = 15488 bytes long. I'd make the guess that pixels are 16-bits and the image has 15488 / 2 = 7744 pixels. 7744 = 26 × 112 = From images I googled, the picture should be rectangular, maybe 64 × 121 or why not may be perfect squares 88 × 88 !

I'll experiment with this and tell you how it cooks. Done!

I was correct about the image format: 88 × 88, 16-bit per pixel (little-endian) as 5-6-5 (RGB)

Edited by jchd

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)

Link to comment
Share on other sites

Hello,

I checked on the display and the thumbnails are square.

My goal now is to be able to convert to and from this format. I'll need to read up on 5-6-5 RGB and see how I get on.

Many thanks for looking at this, really appreciate your help :oops:

NiVZ

Edited by NiVZ
Link to comment
Share on other sites

Hello, here is an example for reading the image, and creating a GDI-Bitmap in order to show it in a GUI:

#include<winapi.au3>
#include<sqlite.au3>
#include<windowsconstants.au3>

_SQLite_Startup()
_SQLite_Open(@ScriptDir & "img.bin")

Global $aRow
_SQLite_QuerySingleRow(-1, "SELECT thumbnail FROM Videos LIMIT 1", $aRow)

_SQLite_Close()
_SQLite_Shutdown()


GUICreate("Test")
$imgIcon = GUICtrlCreatePic("", 10, 10, 88, 88)
GUISetState()

$hLblDC = _WinAPI_GetDC(GUICtrlGetHandle($imgIcon))
$hBitmap = _WinAPI_CreateCompatibleBitmap($hLblDC, 88, 88)
$hDC = _WinAPI_CreateCompatibleDC($hLblDC)
_WinAPI_SelectObject($hDC, $hBitmap)


$tData = DllStructCreate("byte[" & BinaryLen($aRow[0]) & "]")
DllStructSetData($tData, 1, $aRow[0])

$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]")
DllStructSetData($tBITMAPINFOHEADER, 1, DllStructGetSize($tBITMAPINFOHEADER))
DllStructSetData($tBITMAPINFOHEADER, 2, 88)
DllStructSetData($tBITMAPINFOHEADER, 3, -88)
DllStructSetData($tBITMAPINFOHEADER, 4, 1)
DllStructSetData($tBITMAPINFOHEADER, 5, 16)

; use default GDI32 16 bit format: 5-5-5
DllStructSetData($tBITMAPINFOHEADER,  6, 0)

; Choose Colormask manually, example for 5-5-5
;~ DllStructSetData($tBITMAPINFOHEADER,  6, 3) ;BI_BITFIELDS
;~ DllStructSetData($tBITMAPINFOHEADER, "colormap", 0x7C00, 1) ;- Red mask
;~ DllStructSetData($tBITMAPINFOHEADER, "colormap", 0x03E0, 2) ;- Green mask
;~ DllStructSetData($tBITMAPINFOHEADER, "colormap", 0x001F, 3) ;- Blue mask


_WinAPI_SetDIBits($hLblDC, $hBitmap, 0, 88, DllStructGetPtr($tData), DllStructGetPtr($tBITMAPINFOHEADER), 1)

_WinAPI_ReleaseDC(GUICtrlGetHandle($imgIcon), $hLblDC)
_WinAPI_DeleteDC($hDC)

_GUICtrlStatic_SetImage($imgIcon, $hBitmap)



While GUIGetMsg()<>-3
WEnd




; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlStatic_SetImage
; Description ...: Sets a HBITMAP to a static control like image or label
; Syntax.........: _GUICtrlStatic_SetImage($iCtrlId, $hBitmap)
; Parameters ....: $iCtrlId  - CtrlId or handle of Control in the current process
;                  $hBitmap  - Pointer top Windows HBITMAP
; Return values .: Success      - 1
;                  Failure      - 0 and set @error:
;                  |1  - invalid $pSource
;                  |1  - invalid $pSource
; Author ........: ProgAndy, Zedna
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _GUICtrlStatic_SetImage($iCtrlId, $hBitmap)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $IMAGE_BITMAP = 0
    Local Const $SS_BITMAP = 0xE
    Local Const $GWL_STYLE = -16

    If IsHWnd($iCtrlId) Then
        If WinGetProcess($iCtrlId) <> @AutoItPID Then Return SetError(1,0,0)
    Else
        $iCtrlId = GUICtrlGetHandle($iCtrlId)
        If Not $iCtrlId Then Return SetError(2,0,0)
    EndIf
    ; set SS_BITMAP style to control
    Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE)
    If @error Then Return SetError(3, 0, 0)
    DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP))
    If @error Then Return SetError(4, 0, 0)
    Local $oldBmp = DllCall("user32.dll", "handle", "SendMessageW", "hwnd", $iCtrlId, "int", $STM_SETIMAGE, "wparam", $IMAGE_BITMAP, "handle", $hBitmap)
    If @error Then Return SetError(5, 0, 0)
    If $oldBmp[0] Then _WinAPI_DeleteObject($oldBmp[0])
    Return 1
EndFunc
Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Nice shot ProgAndy!

You're right, it was 5-5-5 and not 5-6-5.

I was fighting with GDI+ to create a bitmap from scratch but didn't see how to do that.

I'm very ignorant at Windows graphics.

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)

Link to comment
Share on other sites

Nice shot ProgAndy!

You're right, it was 5-5-5 and not 5-6-5.

I was fighting with GDI+ to create a bitmap from scratch but didn't see how to do that.

I'm very ignorant at Windows graphics.

I tried 565, but the picture looked really bad :oops:

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Wow, thank you both very much :oops: Especially for the GUI program @ProgAndy

It's really good being able to see the image.

My final question (I know sorry) is, how do I now load an image to insert back into the database (ie add new images or replace existing ones)?

I'm happy enough using _GDIPlus_LoadImageFromFile and using SQLite to do the Insert/replace statement. I just don't know how to manipulate the image I load using GDIPlus into the RGB 555 stream (with no header?)

Here's the code with an added File selection dialog which creates a GDIPlus bitmap (and replaces the currently shown image)

#include<sqlite.au3>
#include <GDIPlus.au3>
#include <GUIConstants.au3>

$GUI    = GUICreate("Test")
$imgIcon   = GUICtrlCreatePic("", 10, 10, 88, 88)
$btnGetImage = GUICtrlCreateButton("Choose Image", 10, 100, 100, 20)
GUISetState()
$hLblDC  = _WinAPI_GetDC(GUICtrlGetHandle($imgIcon))
$hBitmap  = _WinAPI_CreateCompatibleBitmap($hLblDC, 88, 88)
$hDC   = _WinAPI_CreateCompatibleDC($hLblDC)
_WinAPI_SelectObject($hDC, $hBitmap)
$hLblDC  = _WinAPI_GetDC(GUICtrlGetHandle($imgIcon))
$hBitmap  = _WinAPI_CreateCompatibleBitmap($hLblDC, 88, 88)
$hDC   = _WinAPI_CreateCompatibleDC($hLblDC)
_WinAPI_SelectObject($hDC, $hBitmap)
_GDIPlus_Startup()
_SQLite_Startup()
$hDB = _SQLite_Open(@ScriptDir & "Test.db")
Global $aRow
_SQLite_QuerySingleRow(-1, "SELECT thumbnail FROM Videos LIMIT 1", $aRow)

$tData = DllStructCreate("byte[" & BinaryLen($aRow[0]) & "]")
DllStructSetData($tData, 1, $aRow[0])

; Bitmap Header info
$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]")
DllStructSetData($tBITMAPINFOHEADER, 1, DllStructGetSize($tBITMAPINFOHEADER))
DllStructSetData($tBITMAPINFOHEADER, 2, 88)
DllStructSetData($tBITMAPINFOHEADER, 3, -88)
DllStructSetData($tBITMAPINFOHEADER, 4, 1)
DllStructSetData($tBITMAPINFOHEADER, 5, 16)
; use default GDI32 16 bit format: 5-5-5
DllStructSetData($tBITMAPINFOHEADER,  6, 0)
_WinAPI_SetDIBits($hLblDC, $hBitmap, 0, 88, DllStructGetPtr($tData), DllStructGetPtr($tBITMAPINFOHEADER), 1)
_WinAPI_ReleaseDC(GUICtrlGetHandle($imgIcon), $hLblDC)
_WinAPI_DeleteDC($hDC)
_GUICtrlStatic_SetImage($imgIcon, $hBitmap)

While 1
  
   $nMsg = GuiGetMsg()
  
   If $nMsg = $GUI_EVENT_CLOSE Then ExitLoop
  
   If $nMsg = $btnGetImage Then
   $sFilename = FileOpenDialog("Choose Image...", @DesktopDir, "Images(*.jpg;*.bmp)|All (*.*)", 3, "", $GUI)
   If @Error Then
   ; Do nothing
   Else

   $Bitmap = _GDIPlus_BitmapCreateFromFile($sFilename)
   $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Bitmap)
   _GUICtrlStatic_SetImage($imgIcon, $hBitmap)
  
   ; Convert File to RGB555
   ; DON'T KNOW HOW TO DO THIS :-(
  
  
   ; Insert into SQLite
   ;_SQLite_Exec($hDB, "INSERT OR REPLACE into Videos (thumbnail) VALUES ('" & $rgb555_data & "');")
  
   EndIf
  
   EndIf
  
  
WEnd
_GDIPlus_Shutdown()
_SQLite_Close()
_SQLite_Shutdown()

Func _GetImageFromDB($row)
  
  

  
EndFunc

Func _GUICtrlStatic_SetImage($iCtrlId, $hBitmap)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $IMAGE_BITMAP = 0
    Local Const $SS_BITMAP = 0xE
    Local Const $GWL_STYLE = -16
    If IsHWnd($iCtrlId) Then
        If WinGetProcess($iCtrlId) <> @AutoItPID Then Return SetError(1,0,0)
    Else
        $iCtrlId = GUICtrlGetHandle($iCtrlId)
        If Not $iCtrlId Then Return SetError(2,0,0)
    EndIf
    ; set SS_BITMAP style to control
    Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE)
    If @error Then Return SetError(3, 0, 0)
    DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP))
    If @error Then Return SetError(4, 0, 0)
    Local $oldBmp = DllCall("user32.dll", "handle", "SendMessageW", "hwnd", $iCtrlId, "int", $STM_SETIMAGE, "wparam", $IMAGE_BITMAP, "handle", $hBitmap)
    If @error Then Return SetError(5, 0, 0)
    If $oldBmp[0] Then _WinAPI_DeleteObject($oldBmp[0])
    Return 1
EndFunc

Thanks,

NiVZ

Edited by NiVZ
Link to comment
Share on other sites

Better safe than sorry. Use SQLite Expert to create a new BLOB column in your table and store there the image in JPG (or PNG or whatever standard format) you want. Double check that all thumbnails get converted correctly, then only you can remove the headerless blob column. (but be sure to have a backup before: better double safe than sorry).

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)

Link to comment
Share on other sites

@jchd - I wish it was that easy. The database is used on a device and the images need to be in that format so the device can display them. I just want to be able to change the existing images to the ones I want :oops:

Thanks,

NiVZ

Edited by NiVZ
Link to comment
Share on other sites

To convert an image to that format, you can try this:

#include<winapi.au3>
#include<sqlite.au3>
#include<windowsconstants.au3>
#include<gdiplus.au3>
_GDIPlus_Startup()

GUICreate("Test")
$imgIcon = GUICtrlCreatePic("", 10, 10, 88, 88)
GUISetState()

$hLblDC = _WinAPI_GetDC(GUICtrlGetHandle($imgIcon))
$hBitmap = _WinAPI_CreateCompatibleBitmap($hLblDC, 88, 88)
$hDC = _WinAPI_CreateCompatibleDC($hLblDC)
_WinAPI_SelectObject($hDC, $hBitmap)

$hImg = _GDIPlus_ImageLoadFromFile(@ScriptDir & "test.png")
$hGraph = _GDIPlus_GraphicsCreateFromHDC($hDC)

_GDIPlus_GraphicsDrawImageRect($hGraph, $hImg, 0, 0, 88, 88)
_GDIPlus_GraphicsDispose($hGraph)
_GDIPlus_ImageDispose($hImg)

$tData = DllStructCreate("byte[15488]")

$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]")
DllStructSetData($tBITMAPINFOHEADER, 1, DllStructGetSize($tBITMAPINFOHEADER))
DllStructSetData($tBITMAPINFOHEADER, 2, 88)
DllStructSetData($tBITMAPINFOHEADER, 3, -88)
DllStructSetData($tBITMAPINFOHEADER, 4, 1)
DllStructSetData($tBITMAPINFOHEADER, 5, 16)

; use default GDI32 16 bit format: 5-5-5
DllStructSetData($tBITMAPINFOHEADER,  6, 0)

; Choose Colormask manually, example for 5-5-5
;~ DllStructSetData($tBITMAPINFOHEADER,  6, 3) ;BI_BITFIELDS
;~ DllStructSetData($tBITMAPINFOHEADER, "colormap", 0x7C00, 1) ;- Red mask
;~ DllStructSetData($tBITMAPINFOHEADER, "colormap", 0x03E0, 2) ;- Green mask
;~ DllStructSetData($tBITMAPINFOHEADER, "colormap", 0x001F, 3) ;- Blue mask


_WinAPI_GetDIBits($hLblDC, $hBitmap, 0, 88, DllStructGetPtr($tData), DllStructGetPtr($tBITMAPINFOHEADER), 1)

_WinAPI_ReleaseDC(GUICtrlGetHandle($imgIcon), $hLblDC)
_WinAPI_DeleteDC($hDC)

_GUICtrlStatic_SetImage($imgIcon, $hBitmap)

$hFile = FileOpen(@ScriptDir & "image555.bin", 18)
FileWrite($hFile, DllStructGetData($tData, 1))
FileClose($hFile)

While GUIGetMsg()<>-3
WEnd



; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlStatic_SetImage
; Description ...: Sets a HBITMAP to a static control like image or label
; Syntax.........: _GUICtrlStatic_SetImage($iCtrlId, $hBitmap)
; Parameters ....: $iCtrlId  - CtrlId or handle of Control in the current process
;                  $hBitmap  - Pointer top Windows HBITMAP
; Return values .: Success      - 1
;                  Failure      - 0 and set @error:
;                  |1  - invalid $pSource
;                  |1  - invalid $pSource
; Author ........: ProgAndy, Zedna
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _GUICtrlStatic_SetImage($iCtrlId, $hBitmap)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $IMAGE_BITMAP = 0
    Local Const $SS_BITMAP = 0xE
    Local Const $GWL_STYLE = -16

    If IsHWnd($iCtrlId) Then
        If WinGetProcess($iCtrlId) <> @AutoItPID Then Return SetError(1,0,0)
    Else
        $iCtrlId = GUICtrlGetHandle($iCtrlId)
        If Not $iCtrlId Then Return SetError(2,0,0)
    EndIf
    ; set SS_BITMAP style to control
    Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE)
    If @error Then Return SetError(3, 0, 0)
    DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP))
    If @error Then Return SetError(4, 0, 0)
    Local $oldBmp = DllCall("user32.dll", "handle", "SendMessageW", "hwnd", $iCtrlId, "int", $STM_SETIMAGE, "wparam", $IMAGE_BITMAP, "handle", $hBitmap)
    If @error Then Return SetError(5, 0, 0)
    If $oldBmp[0] Then _WinAPI_DeleteObject($oldBmp[0])
    Return 1
EndFunc
</gdiplus.au3></windowsconstants.au3></sqlite.au3></winapi.au3>

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

@ProgAndy - you beat me to it. I got this far, but now I can't get the data into the SQL database. It's inserting it as a readable string. I tried different combinations of Binary and Hex but not having much luck. I also saw _SQLite_Encode but I get a Syntax error in the output window when I try it.

#include<winapi.au3>
#include<sqlite.au3>
#include<windowsconstants.au3>
#include<guiconstants.au3>
#include<gdiplus.au3>
Const $DIB_RGB_COLORS = 0
$GUI    = GUICreate("Test")
$imgIcon   = GUICtrlCreatePic("", 10, 10, 88, 88)
$btnGetImage = GUICtrlCreateButton("Choose Image", 10, 100, 100, 20)
GUISetState()
$hLblDC  = _WinAPI_GetDC(GUICtrlGetHandle($imgIcon))
$hBitmap  = _WinAPI_CreateCompatibleBitmap($hLblDC, 88, 88)
$hDC   = _WinAPI_CreateCompatibleDC($hLblDC)
_WinAPI_SelectObject($hDC, $hBitmap)
$hLblDC  = _WinAPI_GetDC(GUICtrlGetHandle($imgIcon))
$hBitmap  = _WinAPI_CreateCompatibleBitmap($hLblDC, 88, 88)
$hDC   = _WinAPI_CreateCompatibleDC($hLblDC)
_WinAPI_SelectObject($hDC, $hBitmap)
_GDIPlus_Startup()
_SQLite_Startup()
$hDB = _SQLite_Open(@ScriptDir & "Test.db")
Global $aRow
_SQLite_QuerySingleRow(-1, "SELECT thumbnail FROM Videos LIMIT 1", $aRow)
;$tData = DllStructCreate("byte[" & BinaryLen($aRow[0]) & "]")
$tData = DllStructCreate("byte[" & BinaryLen($aRow[0]) & "]")
DllStructSetData($tData, 1, $aRow[0])
; Bitmap Header info
$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]")
DllStructSetData($tBITMAPINFOHEADER, 1, DllStructGetSize($tBITMAPINFOHEADER))
DllStructSetData($tBITMAPINFOHEADER, 2, 88)
DllStructSetData($tBITMAPINFOHEADER, 3, -88)
DllStructSetData($tBITMAPINFOHEADER, 4, 1)
DllStructSetData($tBITMAPINFOHEADER, 5, 16)
; use default GDI32 16 bit format: 5-5-5
DllStructSetData($tBITMAPINFOHEADER,  6, 0)
_WinAPI_SetDIBits($hLblDC, $hBitmap, 0, 88, DllStructGetPtr($tData), DllStructGetPtr($tBITMAPINFOHEADER), 1)
_WinAPI_ReleaseDC(GUICtrlGetHandle($imgIcon), $hLblDC)
_WinAPI_DeleteDC($hDC)
_GUICtrlStatic_SetImage($imgIcon, $hBitmap)
While 1

   $nMsg = GuiGetMsg()

   If $nMsg = $GUI_EVENT_CLOSE Then ExitLoop

   If $nMsg = $btnGetImage Then
   $sFilename = FileOpenDialog("Choose Image...", @DesktopDir, "Images(*.jpg;*.bmp)|All (*.*)", 3, "", $GUI)
   If @Error Then
   ; Do nothing
   Else
   $Bitmap = _GDIPlus_BitmapCreateFromFile($sFilename)
   $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Bitmap)
   _GUICtrlStatic_SetImage($imgIcon, $hBitmap)

  $hLblDC  = _WinAPI_GetDC(GUICtrlGetHandle($imgIcon))

   ; Convert File to RGB555
   ; DON'T KNOW HOW TO DO THIS :-(
   $oData = DllStructCreate("byte[15488]")
    
   _WinAPI_GetDIBits($hLblDC, $hBitmap, 0, 88, DllStructGetPtr($oData), DllStructGetPtr($tBITMAPINFOHEADER), 0)
   ;ConsoleWrite(DllStructGetData($oData, 1))
  
   ; Insert into SQLite
   _SQLite_Exec($hDB, "INSERT OR REPLACE into Videos (thumbnail) VALUES ('" & DllStructGetData($oData, 1) & "');")

   EndIf

   EndIf


WEnd
_GDIPlus_Shutdown()
_SQLite_Close()
_SQLite_Shutdown()
Func _GetImageFromDB($row)



EndFunc
Func _GUICtrlStatic_SetImage($iCtrlId, $hBitmap)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $IMAGE_BITMAP = 0
    Local Const $SS_BITMAP = 0xE
    Local Const $GWL_STYLE = -16
    If IsHWnd($iCtrlId) Then
        If WinGetProcess($iCtrlId) <> @AutoItPID Then Return SetError(1,0,0)
    Else
        $iCtrlId = GUICtrlGetHandle($iCtrlId)
        If Not $iCtrlId Then Return SetError(2,0,0)
    EndIf
    ; set SS_BITMAP style to control
    Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE)
    If @error Then Return SetError(3, 0, 0)
    DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP))
    If @error Then Return SetError(4, 0, 0)
    Local $oldBmp = DllCall("user32.dll", "handle", "SendMessageW", "hwnd", $iCtrlId, "int", $STM_SETIMAGE, "wparam", $IMAGE_BITMAP, "handle", $hBitmap)
    If @error Then Return SetError(5, 0, 0)
    If $oldBmp[0] Then _WinAPI_DeleteObject($oldBmp[0])
    Return 1
EndFunc

Thanks,

NiVZ

Edited by NiVZ
Link to comment
Share on other sites

BLOB-strings are enclosed in x'' in SQLite:

_SQLite_Exec($hDB, "INSERT OR REPLACE into Videos (thumbnail) VALUES (x'" & Hex(DllStructGetData($oData, 1)) & "');")

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

@ProgAndy - An 'x', can't believe I got so close and got stumped by an 'x' :oops:

Thanks very much with all your help with this, and you @jchd. No way I'd have figured all the image stuff out on my own.

NiVZ

Link to comment
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
 Share

  • Recently Browsing   0 members

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