compatiblity between Windows and Linux with Tbitmap.scanline lazarus / 31-LCL ---------------------------------------------------------------------- DrJohn · 2016-11-15 01:20 These days I  tend to live in Linux world, but since I've come by way of Windows, I still go back and forth.  One of the things that I like about Lazarus is that I can make tools that use identical code and perform more or less identically on both platforms.  But, alas, when I wanted to do a bit of simple image processing, that was not to be. I found that when using a Tbitmap and when using the scanline property to access pixels under Windows, although the documentation suggests that you should read and write with a TColor type, actually you need to use (at least in my case where I'm loading from TIFF images) a pixel24 type, i.e.,      pixel24 = packed record       blue: byte;       green: byte;       red: byte;     end; for both reading from and writing to Tbitmaps.  Alas, that doesn't work under Linux.  With Linux, for reading from a Tbitmap, I must use a different pixel24 type, i.e.,     pixel24 = packed record       red: byte;       green: byte;       blue: byte;     end; But, for writing to a Tbitmap under Linux, a TColor type is required or else it won't compile.  Writing with a TColor works just fine under Linux.  Using a TColor to write to a Tbitmap with the scanline property will compile under Windows, but causes the application to crash. The LCL help file documentation says that a TColor type should be used for both reading and writing and to TBitmaps.  It is what I'd prefer since it should hide a lot of issues associated with different underlying image formats.  But, alas, I've found a lot of documentation on the web for Delphi that suggests that the pixel24 type should be used with TBitmaps.  So, probably, for compatibility reasons, that has been what was standardized under Windows. It would be very helpful if it was the same for Windows and Linux and if whatever it is, it would agree with the documentation in the help files.  I'm not sure why the difference between platform even arises if the LCL has identical source code between the platforms.  Probably this is optimistic though. Anyway, I thought I'd give a "heads up" to others who might be in my shoes and ask for this to be corrected. Thanks. ---------------------------------------------------------------------- ps · 2016-11-15 07:03 You can detect format by TRawImage for example (if you are working with 24bpp): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  Raw: TRawImage;begin   Raw := ABitmap.RawImage;  if (Raw.Description.ByteOrder = riboLSBFirst) and (Raw.Description.BlueShift =0 ) then  begin    // format will be BGR  end  else    // format will be RGB  end;  I think 32bpp (with alpha) will be faster but there will be ARGB, ABGR, RGBA, BGRA (win, linux, macos) for more fun