Bookstore

Recent

Author Topic: SOLVED: Convert glyph data and assign it to TBitBtn  (Read 1343 times)

SaraT

  • Jr. Member
  • **
  • Posts: 79
  • A little student
SOLVED: Convert glyph data and assign it to TBitBtn
« on: February 21, 2020, 02:49:39 pm »
Good morning friends :)
Please, see the attached image.

Let's suppose that I just want to load an image with the glyph data.
How can I convert this string to my glyph button?

No image png, jpg, ico, no resource option... just this glyph data.
Have a great day and many thanks.


« Last Edit: February 25, 2020, 04:28:37 pm by SaraT »

Handoko

  • Hero Member
  • *****
  • Posts: 3434
  • My goal: build my own game engine using Lazarus
Re: Convert glyph data and assign it to TBitBtn
« Reply #1 on: February 21, 2020, 03:09:19 pm »
Do something like this:

Code: Pascal  [Select]
  1.   Image1.Picture.Assign(BitBtn1.Glyph);

If that is not what you want, you may try:

Code: Pascal  [Select]
  1.   Image1.Picture.LoadFromStream(aTStream);

And if none above is what you want, you need to show us how you obtain the data.
« Last Edit: February 21, 2020, 03:16:16 pm by Handoko »

SaraT

  • Jr. Member
  • **
  • Posts: 79
  • A little student
Re: Convert glyph data and assign it to TBitBtn
« Reply #2 on: February 21, 2020, 03:21:03 pm »
Thanks Handoko
I think is something like this but I dont know the correct way:

Code: Pascal  [Select]
  1. Var
  2.   imageData : ???
  3. Begin
  4.   imageData := {361000...};
  5.   BitBtn1.Glyph := imageData;
  6. end;

But is obvious that that won't work. I just want to use the data, nothing else: {361000...}
Any idea?
Thanks :)
« Last Edit: February 21, 2020, 03:26:14 pm by SaraT »

Handoko

  • Hero Member
  • *****
  • Posts: 3434
  • My goal: build my own game engine using Lazarus
Re: Convert glyph data and assign it to TBitBtn
« Reply #3 on: February 21, 2020, 03:34:30 pm »
That numbers is converted from binary data.

First you need to convert the image data (which is binary data) to human readable text. Save it and use it later, but convert it back to binary data before used directly to the TBitmap.

There are many ways to convert binary data to that readable text, you can search the web, using these keywords:
data to hex string
binary data to text

And here is detailed explanation:
https://en.wikipedia.org/wiki/Binary-to-text_encoding

I believe FPC has such functions, but I don't know what they are. So I wrote mine and it can be used to convert my game data to importable string for used in the pascal code.

Once you managed to do the conversion, you can use it in your Pascal code like this:

Code: Pascal  [Select]
  1. var
  2.   ImageData: string;
  3.   AStream: TStringStream;
  4.  
  5. begin
  6.   ImageData := // ... the human readble data
  7.   ConvertDataToStream(AStream); // your own function
  8.   Image1.Picture.LoadFromStream(AStream);
  9. end;

Most Lazarus components internally use TStream for 'managing' data, so you can write your own ConvertDataToStream to 'send' the data to other components.

Note:
The 'binary' mentioned above is not the same as the binary you learned from school (Mathematics).
« Last Edit: February 21, 2020, 03:59:54 pm by Handoko »

SaraT

  • Jr. Member
  • **
  • Posts: 79
  • A little student
Re: Convert glyph data and assign it to TBitBtn
« Reply #4 on: February 21, 2020, 04:36:42 pm »
Many thanks Handoko
I will try to do someyhing with it.
In case someone already has the solution, please, share it with us.

Best regards :)

Handoko

  • Hero Member
  • *****
  • Posts: 3434
  • My goal: build my own game engine using Lazarus
Re: Convert glyph data and assign it to TBitBtn
« Reply #5 on: February 21, 2020, 04:56:13 pm »
If you're really interested, here are mine:

Code: Pascal  [Select]
  1. procedure HexStringToStream(const Input: string; Output: TMemoryStream;
  2.   OutputReturn: Boolean);
  3. var
  4.   Bookmark:   Int64;
  5.   Buffer:     array of Byte;
  6.   ResultSize: Integer;
  7.   i:          Integer;
  8. begin
  9.   ResultSize := Input.Length div 2;
  10.   SetLength(Buffer, ResultSize);
  11.   HexToBin(PChar(Input), PChar(Buffer), ResultSize);
  12.   Bookmark := Output.Position;
  13.   for i := 0 to (ResultSize-1) do
  14.     Output.WriteByte(Buffer[i]);
  15.   if OutputReturn then
  16.     Output.Position := Bookmark;
  17. end;
  18.  
  19. procedure StreamToHexStringFile(Input: TMemoryStream; const ConstName,
  20.   FileName: string);
  21. var
  22.   Buffer: TStringList;
  23.   S:      string;
  24.   i:      Integer;
  25. begin
  26.   Buffer := TStringList.Create;
  27.   StreamToHexStringList(Input, Buffer);
  28.   with Buffer do
  29.   begin
  30.     for i := 0 to (Count-1) do
  31.     begin
  32.       S := '    ' + '''' + Strings[i] + '''';
  33.       case (i < Count-1) of
  34.         True:  S := S + '+';
  35.         False: S := S + ';';
  36.       end;
  37.       Buffer[i] := S;
  38.     end;
  39.     if (Count >= 0) then
  40.     begin
  41.       Insert(0, '  ' + ConstName + ' = ');
  42.       Insert(0, 'const');
  43.       SaveToFile(FileName);
  44.     end;
  45.     Free;
  46.   end;
  47. end;
  48.  
  49. procedure StreamToHexStringList(Input: TMemoryStream; Output: TStringList);
  50. var
  51.   Buffer: array[0..31] of Byte;
  52.   Remain: Integer;
  53.   Todo:   Integer;
  54.   S:      string;
  55.   i:      Integer;
  56. begin
  57.   Input.Seek(0, soBeginning);
  58.   Remain := Input.Size;
  59.   while (Remain > 0) do
  60.   begin
  61.     Todo := 32;
  62.     if (Remain < 32) then
  63.       Todo := Remain;
  64.     Input.ReadBuffer(Buffer, Todo);
  65.     S := '';
  66.     for i := 0 to (Todo- 1) do
  67.       S := S + IntToHex(Buffer[i], 2);
  68.     Output.Add(S);
  69.     Remain := Remain - Todo;
  70.   end;
  71. end;

I used them. It can convert and save any stream data to file so I can open the text file and copy/paste the string to use in my Pascal code. But that just how I do it, I believe many seniors will have better solutions.

I don't think you will understand how to use my code. I recommend you to learn how to use TStream first.

SaraT

  • Jr. Member
  • **
  • Posts: 79
  • A little student
Re: Convert glyph data and assign it to TBitBtn
« Reply #6 on: February 21, 2020, 05:59:46 pm »
You were right Handoko, I wasn't able to use your code, sorry is something advanced to me :/
Can you please try converting the below image data?

If you convert the data, your Image1 control must have the icon check like the attached image (PNG).

Many thanks Handoko.


Code: Text  [Select]
  1. Picture.Data = {
  2.     1754506F727461626C654E6574776F726B477261706869634707000089504E47
  3.     0D0A1A0A0000000D4948445200000020000000200806000000737A7AF4000000
  4.     1974455874536F6674776172650041646F626520496D616765526561647971C9
  5.     653C000006E94944415478DA9C57596C5CD519FEEE328B671C8F27F1123B8EC7
  6.     4EAC246E425228B2828C315850158851D250D2A0AAA01050CB039548CB22E005
  7.     419E22A4BE5455050F08A1A651A3265836200812029E50D290D86984C7CB8C97
  8.     B13D5E66ECF16C77EBFF9F599871265E72ADFF5ECFBDE7FCDFF76FE7FC47C23A
  9.     AFF69750E1AAC149C878C692B03FF75E920AC4C235C9C0874BD378FFDBBF6271
  10.     3D7AA5B5BE3FF81A762815B8E0B4635FC7CF3AD05CEBC3F6AA3A58661AB17414
  11.     895484248A68720163E11066A25184E692304DF4272338FCD5690C931EEB4E08
  12.     280FBF8BBF391C78E18F8FBE8CF63DED58D4C6A12142B3D2B02C138669C0300C
  13.     2203A4B514E61667109A1D4670F6268233314CCE01A68E7FF4BD8A17499FB111
  14.     02B6AED3081CDC7D4FDD5BBF7E0F4BF0236E063111BE86E9F901CC4587914C1A
  15.     C2ED392D0E9B0D1ED7765494EF8453ADC7D0E415DC18BF4E7380C538427D7F81
  16.     8F466AEB21607BE81D8C3EF7C8EFEB0FB71DC3827915530BD771F5C773486926
  17.     643933492A31D3CADE6CAA8A5ACF43E4213BAE0C7F89C9D914266631F9E92B68
  18.     5A4962A51ADBC3A7113CDE7974EB63F73E8EA43282FE91FF6074B21F8A02C852
  19.     69E05B8858193295AE16785DBFC0F7FE5E043824614CF5BD82C642124A51CCDF
  20.     C6DFF736373FF09BF6A7603927F0DFC17F617CE626C8202872167C1D92AB8A84
  21.     360F9302B8B3B68BC2E0472C619437B4A3DEFF157A730ECB1190DA4E6277451D
  22.     3EF8C3AF9E47B957C740E002C6C3FFCB5BBE91CB2A28D19416A57F5268D8DC86
  23.     487C9004F75436E2ECC415CCF11839E77ACF0E9CFFE5DD0FA07C1330BF3488C0
  24.     F4F50CB8BC3EAB59687D208B019D6E7A360C12CD8F24FC50D414766DDB8BFA2A
  25.     A0AA05E719334FA0E97E54D9ED686DDDEE4359998C1F46CEDD193821A6A8D8BA
  26.     F7F6A0A3F90CB4021233B1AFD158B50FD51E098A0DADCD849923A03477E2C4EE
  27.     6DDB44ACA7233790D6A9C4943B0027CB0FB59E45A3E710F66F3D852D653EE111
  28.     1EA3591A910BA1BAC2072F7979C78338814C6AC16E73E1E9CD9BDC703A1D9822
  29.     02228936106F5AF53296EFF927766E3E96FF7674DF65418C07B1BE98368A2A4F
  30.     23DC4EF2BF1B4F33361370CAE4128F5B86CBE9463411142E5B69A1B586E5DDAD
  31.     0CFEDB2272A1D83799B1597D492D046FF9564180310536DD541EAC1B0951BF29
  32.     432B222092CACA08FF6F950267CBBDC5E0430B6771F1E611914BB9B2D4E84F55
  33.     1C19BF674A45CD4121411B8B6EE845B5CE809C481D8D67D0BDAB47B899418BC0
  34.     779706EFF9F138EC6A89445EB112CBB97A4DA497A06B7A7E90882DDDB6B87CD8
  35.     5F7B4A24D6A15D67415B0034127E76EFBA3DB8235B456BE5929C5B8F535A6667
  36.     5BE981A37B2EE707EFF41E23D08F10D3219EB78047087C90C0D972E5362B6729
  37.     02C8BA34915AA618D98A2688442AB85ABCBFC36BF759E2B911700E9B8D74EB46
  38.     8A36A99FC888743092188C2581D9E8385C6A5D7E3DE704BA387844285FED12E0
  39.     7E02B7AD62398953A9C3426C0ACB84C5988CCD04F4D8347AE2F472263A8672B5
  40.     29BF96F31E602785AC7C285A9A04BF17E0B9DD7215A26ED21D8E040501C6646C
  41.     2690BCF1093E5E5802C24B013850275C6565BDC016B15B4B91C883ABAB5BCEBA
  42.     38B4AC7B9630188B31199B09A4170298D612180E472C04E6FA5163EFCCD77B11
  43.     89E1E318899E17E0FCE4DF6B81E7085491CE20E9660CC6624CC656B3BDDAF2C0
  44.     27F893ED187ACA5D03A8A96842A5DA8288E1CF2D621912F4A377F449511DFC5E
  45.     80AFE1761EEB515A60A61DF04F0C883E91B11893B173FD80B9388178DDCFD16C
  46.     D9B047378268A9EE82212D216545F3C63018D7B62A657691B5C0399736298DF0
  47.     CA6DB8ECEFC3C89481B9095CBC760E1FD2A7852202FC23F01DAE3674E0294936
  48.     5CF174002D5BBA08258504E66F3D03ACE172765105592EC0877AA9654F60661E
  49.     7397DEC6B3BC4D70FC57B6641C0AD37F099F561FC4610B69D7223512DB3C6DF0
  50.     D87D347A0CA664E63BC952759EDB7854DA696AD42E285A2D81F709F0B169CC7E
  51.     FE3ABA69C418C962D6E82202ECB1342FFF4397F059CD411C594E1965516AA31C
  52.     72191ADC9D2853B688E38F29C5293C667E97148B8C64834B6E805739002FDAA8
  53.     1D1FA6C6E63B8C840CB67C9EC09F20DDA324EC4E7DD5B69C84BB155FE79FF126
  54.     F5898FD7136E75A584AA4D3EEA6828A6E5755456F6A2E38E61A4699109211C0D
  55.     8A52E36CE7845B0CA1F7EB33788786044866D76ACB0B497849B6D61FC0BEBB9E
  56.     C4BB76179AB893E1BD9C45918B27F0F2CA0B0C0BD7793A8ED1EBFFC61B933FA0
  57.     9F3E4F65934EDBD0D18CC44542F6A3DA5D8DDABD87D15DB91D8FA82E34DF72DA
  58.     234D7A1C2391317C3170013DCB6151E7742E12DD6F7CA347B3C2EFB62C113749
  59.     059735495941475D58F209926836C996B3C0DA9D1E4E4B79C4CE6D54B68B924A
  60.     94BD9E2DAFF4ED2C5E79FD5F800100550AFA734233AE390000000049454E44AE
  61.     426082
  62.   }

Handoko

  • Hero Member
  • *****
  • Posts: 3434
  • My goal: build my own game engine using Lazarus
Re: Convert glyph data and assign it to TBitBtn
« Reply #7 on: February 21, 2020, 06:33:09 pm »
Sorry, I can't. I don't know what encoding is used internally by FPC to generate that data and how the data stored (like endianess, etc ... read more: https://en.wikipedia.org/wiki/Endianness). The readable binary data is not compatible with my functions.

Using my function, the generated data from the image you provided is:

Code: Pascal  [Select]
  1. const
  2.   ImageData =
  3.     '89504E470D0A1A0A0000000D4948445200000020000000200806000000737A7A'+
  4.     'F40000001974455874536F6674776172650041646F626520496D616765526561'+
  5.     '647971C9653C000006E94944415478DA9C57596C5CD519FEEE328B671C8F27F1'+
  6.     '123B8EC74EAC246E425228B2828C315850158851D250D2A0AAA01050CB039548'+
  7.     'CB22E005419E22A4BE5455050F08A1A651A3265836200812029E50D290D86984'+
  8.     'C7CB8C97B13D5E66ECF16C77EBFF9F599871265E72ADFF5ECFBDE7FCDFF76FE7'+
  9.     'FC47C23AAFF69750E1AAC149C878C692B03FF75E920AC4C235C9C0874BD378FF'+
  10.     'DBBF62713D7AA5B5BE3FF81A762815B8E0B4635FC7CF3AD05CEBC3F6AA3A5866'+
  11.     '1AB17414895484248A68720163E11066A25184E692304DF4272338FCD5690C93'+
  12.     '1EEB4E08280FBF8BBF391C78E18F8FBE8CF63DED58D4C6A12142B3D2B02C1386'+
  13.     '69C0300C2203A4B514E61667109A1D4670F6268233314CCE01A68E7FF4BD8A17'+
  14.     '499FB11102B6AED3081CDC7D4FDD5BBF7E0F4BF0236E063111BE86E9F901CC45'+
  15.     '87914C1AC2ED392D0E9B0D1ED7765494EF8453ADC7D0E415DC18BF4E7380C538'+
  16.     '427D7F818F466AEB21607BE81D8C3EF7C8EFEB0FB71DC3827915530BD771F5C7'+
  17.     '73486926643933492A31D3CADE6CAA8A5ACF43E4213BAE0C7F89C9D914266631'+
  18.     'F9E92B685A4962A51ADBC3A7113CDE7974EB63F73E8EA43282FE91FF6074B21F'+
  19.     '8A02C85269E05B8858193295AE16785DBFC0F7FE5E043824614CF5BD82C64212'+
  20.     '4A51CCDFC6DFF736373FF09BF6A7603927F0DFC17F617CE626C8202872167C1D'+
  21.     '92AB8A84360F9302B8B3B68BC2E0472C619437B4A3DEFF157A730ECB1190DA4E'+
  22.     '6277451D3EF8C3AF9E47B957C740E002C6C3FFCB5BBE91CB2A28D19416A57F52'+
  23.     '68D8DC86487C9004F75436E2ECC415CCF11839E77ACF0E9CFFE5DD0FA07C1330'+
  24.     'BF3488C0F4F50CB8BC3EAB59687D208B019D6E7A360C12CD8F24FC50D414766D'+
  25.     'DB8BFA2AA0AA05E719334FA0E97E54D9ED686DDDEE4359998C1F46CEDD193821'+
  26.     'A6A8D8BAF7F6A0A3F90CB4021233B1AFD158B50FD51E098A0DADCD849923A034'+
  27.     '77E2C4EE6DDB44ACA7233790D6A9C4943B0027CB0FB59E45A3E710F66F3D852D'+
  28.     '653EE1111EA3591A910BA1BAC2072F7979C78338814C6AC16E73E1E9CD9BDC70'+
  29.     '3A1D982202228936106F5AF53296EFF927766E3E96FF7674DF65418C07B1BE98'+
  30.     '368A2A4F23DC4EF2BF1B4F33361370CAE4128F5B86CBE9463411142E5B69A1B5'+
  31.     '86E5DDAD0CFEDB2272A1D83799B1597D492D046FF9564180310536DD541EAC1B'+
  32.     '0951BF29432B222092CACA08FF6F950267CBBDC5E0430B6771F1E611914BB9B2'+
  33.     'D4E84F551C19BF674A45CD4121411B8B6EE845B5CE809C481D8D67D0BDAB47B8'+
  34.     '99418BC0779706EFF9F138EC6A89445EB112CBB97A4DA497A06B7A7E90882DDD'+
  35.     'B6B87CD85F7B4A24D6A15D67415B0034127E76EFBA3DB8235B456BE5929C5B8F'+
  36.     '535A66675BE981A37B2EE707EFF41E23D08F10D3219EB78047087C90C0D972E5'+
  37.     '362B672902C8BA34915AA618D98A2688442AB85ABCBFC36BF759E2B911700E9B'+
  38.     '8D74EB468A36A99FC888743092188C2581D9E8385C6A5D7E3DE704BA38784428'+
  39.     '5FED12E07E02B7AD62398953A9C3426C0ACB84C5988CCD04F4D8347AE2F47226'+
  40.     '3A8672B529BF96F31E602785AC7C285A9A04BF17E0B9DD7215A26ED21D8E0405'+
  41.     '01C6646C2690BCF1093E5E5802C24B013850275C6565BDC016B15B4B91C883AB'+
  42.     'AB5BCEBA38B4AC7B9630188B31199B09A4170298D612180E472C04E6FA5163EF'+
  43.     'CCD77B1189E1E318899E17E0FCE4DF6B81E7085491CE20E9660CC6624CC656B3'+
  44.     'BDDAF2C027F893ED187ACA5D03A8A96842A5DA8288E1CF2D621912F4A377F449'+
  45.     '511DFC5E80AFE1761EEB515A60A61DF04F0C883E91B11893B173FD80B9388178'+
  46.     'DDCFD16CD9B047378268A9EE82212D216545F3C63018D7B62A657691B5C03997'+
  47.     '36298DF0CA6DB8ECEFC3C89481B9095CBC760E1FD2A7852202FC23F01DAE3674'+
  48.     'E02949365CF174002D5BBA08258504E66F3D03ACE172765105592EC0877AA965'+
  49.     '4F60661E7397DEC6B3BC4D70FC57B6641C0AD37F099F561FC4610B69D7223512'+
  50.     'DB3C6DF0D87D347A0CA664E63BC952759EDB7854DA696AD42E285A2D81F709F0'+
  51.     'B169CC7EFE3ABA69C418C962D6E82202ECB1342FFF4397F059CD411C594E1965'+
  52.     '516AA31C72191ADC9D2853B688E38F29C5293C667E97148B8C64834B6E805739'+
  53.     '002FDAA81D1FA6C6E63B8C840CB67C9EC09F20DDA324EC4E7DD5B69C84BB155F'+
  54.     'E79FF126F5898FD7136E75A584AA4D3EEA6828A6E5755456F6A2E38E61A46991'+
  55.     '09211C0D8A52E36CE7845B0CA1F7EB33788786044866D76ACB0B497849B6D61F'+
  56.     'C0BEBB9EC4BB76179AB893E1BD9C45918B27F0F2CA0B0C0BD7793A8ED1EBFFC6'+
  57.     '1B933FA09F3E4F65934EDBD0D18CC44542F6A3DA5D8DDABD87D15DB91D8FA82E'+
  58.     '34DF72DA234D7A1C2391317C3170013DCB6151E7742E12DD6F7CA347B3C2EFB6'+
  59.     '2C113749059735495941475D58F209926836C996B3C0DA9D1E4E4B79C4CE6D54'+
  60.     'B68B924A94BD9E2DAFF4ED2C5E79FD5F800100550AFA734233AE390000000049'+
  61.     '454E44AE426082';

Something I'm sure about are, both encoded data are hexadecimal text and the last data are exactly the same: .....426082.

I wasn't able to use your code, sorry is something advanced to me :/

Learning how to use TStream isn't very hard. I believe you can understand it if you spend one or two days playing with it. After you are proficient in using TStream, you can do many powerful tricks. And you will understand how to use my functions by simply looking at the parameters of the functions. You may even able to write your own BinaryToText function.
« Last Edit: February 21, 2020, 07:03:28 pm by Handoko »

circular

  • Hero Member
  • *****
  • Posts: 3149
    • Personal webpage
Re: Convert glyph data and assign it to TBitBtn
« Reply #8 on: February 21, 2020, 07:16:21 pm »
Code: Text  [Select]
  1. Picture.Data = {
  2.     1754506F727461626C654E6574776F726B477261706869634707000089504E47
  3.     0D0A1A0A0000000D4948445200000020000000200806000000737A7AF4000000
  4.     1974455874536F6674776172650041646F626520496D616765526561647971C9
  5.     653C000006E94944415478DA9C57596C5CD519FEEE328B671C8F27F1123B8EC7
  6.     4EAC246E425228B2828C315850158851D250D2A0AAA01050CB039548CB22E005
  7.     419E22A4BE5455050F08A1A651A3265836200812029E50D290D86984C7CB8C97
  8.     B13D5E66ECF16C77EBFF9F599871265E72ADFF5ECFBDE7FCDFF76FE7FC47C23A
  9.     AFF69750E1AAC149C878C692B03FF75E920AC4C235C9C0874BD378FFDBBF6271
  10.     3D7AA5B5BE3FF81A762815B8E0B4635FC7CF3AD05CEBC3F6AA3A58661AB17414
  11.     895484248A68720163E11066A25184E692304DF4272338FCD5690C931EEB4E08
  12.     280FBF8BBF391C78E18F8FBE8CF63DED58D4C6A12142B3D2B02C138669C0300C
  13.     2203A4B514E61667109A1D4670F6268233314CCE01A68E7FF4BD8A17499FB111
  14.     02B6AED3081CDC7D4FDD5BBF7E0F4BF0236E063111BE86E9F901CC4587914C1A
  15.     C2ED392D0E9B0D1ED7765494EF8453ADC7D0E415DC18BF4E7380C538427D7F81
  16.     8F466AEB21607BE81D8C3EF7C8EFEB0FB71DC3827915530BD771F5C773486926
  17.     643933492A31D3CADE6CAA8A5ACF43E4213BAE0C7F89C9D914266631F9E92B68
  18.     5A4962A51ADBC3A7113CDE7974EB63F73E8EA43282FE91FF6074B21F8A02C852
  19.     69E05B8858193295AE16785DBFC0F7FE5E043824614CF5BD82C642124A51CCDF
  20.     C6DFF736373FF09BF6A7603927F0DFC17F617CE626C8202872167C1D92AB8A84
  21.     360F9302B8B3B68BC2E0472C619437B4A3DEFF157A730ECB1190DA4E6277451D
  22.     3EF8C3AF9E47B957C740E002C6C3FFCB5BBE91CB2A28D19416A57F5268D8DC86
  23.     487C9004F75436E2ECC415CCF11839E77ACF0E9CFFE5DD0FA07C1330BF3488C0
  24.     F4F50CB8BC3EAB59687D208B019D6E7A360C12CD8F24FC50D414766DDB8BFA2A
  25.     A0AA05E719334FA0E97E54D9ED686DDDEE4359998C1F46CEDD193821A6A8D8BA
  26.     F7F6A0A3F90CB4021233B1AFD158B50FD51E098A0DADCD849923A03477E2C4EE
  27.     6DDB44ACA7233790D6A9C4943B0027CB0FB59E45A3E710F66F3D852D653EE111
  28.     1EA3591A910BA1BAC2072F7979C78338814C6AC16E73E1E9CD9BDC703A1D9822
  29.     02228936106F5AF53296EFF927766E3E96FF7674DF65418C07B1BE98368A2A4F
  30.     23DC4EF2BF1B4F33361370CAE4128F5B86CBE9463411142E5B69A1B586E5DDAD
  31.     0CFEDB2272A1D83799B1597D492D046FF9564180310536DD541EAC1B0951BF29
  32.     432B222092CACA08FF6F950267CBBDC5E0430B6771F1E611914BB9B2D4E84F55
  33.     1C19BF674A45CD4121411B8B6EE845B5CE809C481D8D67D0BDAB47B899418BC0
  34.     779706EFF9F138EC6A89445EB112CBB97A4DA497A06B7A7E90882DDDB6B87CD8
  35.     5F7B4A24D6A15D67415B0034127E76EFBA3DB8235B456BE5929C5B8F535A6667
  36.     5BE981A37B2EE707EFF41E23D08F10D3219EB78047087C90C0D972E5362B6729
  37.     02C8BA34915AA618D98A2688442AB85ABCBFC36BF759E2B911700E9B8D74EB46
  38.     8A36A99FC888743092188C2581D9E8385C6A5D7E3DE704BA387844285FED12E0
  39.     7E02B7AD62398953A9C3426C0ACB84C5988CCD04F4D8347AE2F472263A8672B5
  40.     29BF96F31E602785AC7C285A9A04BF17E0B9DD7215A26ED21D8E040501C6646C
  41.     2690BCF1093E5E5802C24B013850275C6565BDC016B15B4B91C883ABAB5BCEBA
  42.     38B4AC7B9630188B31199B09A4170298D612180E472C04E6FA5163EFCCD77B11
  43.     89E1E318899E17E0FCE4DF6B81E7085491CE20E9660CC6624CC656B3BDDAF2C0
  44.     27F893ED187ACA5D03A8A96842A5DA8288E1CF2D621912F4A377F449511DFC5E
  45.     80AFE1761EEB515A60A61DF04F0C883E91B11893B173FD80B9388178DDCFD16C
  46.     D9B047378268A9EE82212D216545F3C63018D7B62A657691B5C0399736298DF0
  47.     CA6DB8ECEFC3C89481B9095CBC760E1FD2A7852202FC23F01DAE3674E0294936
  48.     5CF174002D5BBA08258504E66F3D03ACE172765105592EC0877AA9654F60661E
  49.     7397DEC6B3BC4D70FC57B6641C0AD37F099F561FC4610B69D7223512DB3C6DF0
  50.     D87D347A0CA664E63BC952759EDB7854DA696AD42E285A2D81F709F0B169CC7E
  51.     FE3ABA69C418C962D6E82202ECB1342FFF4397F059CD411C594E1965516AA31C
  52.     72191ADC9D2853B688E38F29C5293C667E97148B8C64834B6E805739002FDAA8
  53.     1D1FA6C6E63B8C840CB67C9EC09F20DDA324EC4E7DD5B69C84BB155FE79FF126
  54.     F5898FD7136E75A584AA4D3EEA6828A6E5755456F6A2E38E61A4699109211C0D
  55.     8A52E36CE7845B0CA1F7EB33788786044866D76ACB0B497849B6D61FC0BEBB9E
  56.     C4BB76179AB893E1BD9C45918B27F0F2CA0B0C0BD7793A8ED1EBFFC61B933FA0
  57.     9F3E4F65934EDBD0D18CC44542F6A3DA5D8DDABD87D15DB91D8FA82E34DF72DA
  58.     234D7A1C2391317C3170013DCB6151E7742E12DD6F7CA347B3C2EFB62C113749
  59.     059735495941475D58F209926836C996B3C0DA9D1E4E4B79C4CE6D54B68B924A
  60.     94BD9E2DAFF4ED2C5E79FD5F800100550AFA734233AE390000000049454E44AE
  61.     426082
  62.   }
In fact, this is the PNG content encoded in hexadecimal with some header.

The header is:
1754506F727461626C654E6574776F726B4772617068696347070000

Next is the PNG:
89504E470D0A1A0A...
Conscience is the debugger of the mind

Handoko

  • Hero Member
  • *****
  • Posts: 3434
  • My goal: build my own game engine using Lazarus
Re: Convert glyph data and assign it to TBitBtn
« Reply #9 on: February 21, 2020, 07:24:09 pm »
You have good eyesight.

As far as I remember my code worked, I used it to convert and store images. But why without that header it still worked? Does it mean, that header is not 'really' needed? Maybe a kind of magic number added by FPC Lazarus for internal use or checksum.

lucamar

  • Hero Member
  • *****
  • Posts: 2560
Re: Convert glyph data and assign it to TBitBtn
« Reply #10 on: February 21, 2020, 08:26:31 pm »
Interesting exercise. It can probably be solved by using (or mimicing) the TReader for the glyph but I'll try to see how it could be coded.

Not tonight, though. I'm quite busy (taking a rest now to read the forum ;) )
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.6/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

winni

  • Hero Member
  • *****
  • Posts: 1110
Re: Convert glyph data and assign it to TBitBtn
« Reply #11 on: February 21, 2020, 09:14:08 pm »

In fact, this is the PNG content encoded in hexadecimal with some header.

The header is:
1754506F727461626C654E6574776F726B4772617068696347070000

Next is the PNG:
89504E470D0A1A0A...

The header is

#$17TPortableNetworkGraphicG#07#00#00

whatever the "G" means

Winni

circular

  • Hero Member
  • *****
  • Posts: 3149
    • Personal webpage
Re: Convert glyph data and assign it to TBitBtn
« Reply #12 on: February 21, 2020, 09:50:04 pm »
The header is

#$17TPortableNetworkGraphicG#07#00#00

whatever the "G" means

Winni
I suppose #17 is the length of the name of the class and then 'G'#07 is the size of the embedded data ($0747 = 1863)
Conscience is the debugger of the mind

winni

  • Hero Member
  • *****
  • Posts: 1110
Re: Convert glyph data and assign it to TBitBtn
« Reply #13 on: February 21, 2020, 09:58:22 pm »
Yes, with the two zeros this is Intel 32 bit Integer format!

The bytes are always there where you won't exspect them. Learned it with Motorola ....

Winni

circular

  • Hero Member
  • *****
  • Posts: 3149
    • Personal webpage
Re: Convert glyph data and assign it to TBitBtn
« Reply #14 on: February 21, 2020, 11:21:03 pm »
Indeed

 :D

Conscience is the debugger of the mind