No, it's not a matter of resource generation, but of resource reading.
A possible solution: At the place where the BitmapInfoHeader is expected, but the BitmapFileHeader is found, the reader could check whether the first 2 bytes read are the bitmap signature 'BM'. If this is true it very probably has detected the BitmapFileHeader, must advance the stream position by the size of the BitmapFileHeader to get to the BitmapInfoHeader, and repeat from where it started reading.
To be more specific:
- Open unit IntfGraphics (from folder lcl of the Lazarus installation)
- Find procedure TLazReaderDIB.InternalReadHead.
- Before the "begin" add a variable "Magic: Array[0..1] of ansiChar absolute BIH"
- After the "{$ENDIF}" closely after the "begin" insert the following highlighted lines
var
...
Magic: array[0..1] of AnsiChar absolute BIH;
begin
StreamStart := theStream.Position;
TheStream.Read(BIH.biSize,SizeOf(BIH.biSize));
{$IFDEF FPC_BIG_ENDIAN}
BIH.biSize := LEtoN(BIH.biSize);
{$ENDIF}
// ------------------ wp: insert this ...
// Workaround for bitmaps in RT_RCDATA resources not being read correctly.
// These resources have the BitmapFileHeader at the place where the stream is
// here atm. The stream expects a TBitmapInfoHeader or TBitmapCoreHeader, though.
if (Magic[0] = 'B') and (Magic[1] = 'M') then
begin
TheStream.Position := StreamStart + SizeOf(TBitmapFileHeader);
TheStream.Read(BIH.biSize,SizeOf(BIH.biSize));
{$IFDEF FPC_BIG_ENDIAN}
BIH.biSize := LEtoN(BIH.biSize);
{$ENDIF}
end;
// ------------------- ... until here.
if BIH.biSize = 12
Kind of "brute force"... but it seems to work. I am aware that the assumption about having the complete file structure has been made also at another place, and this makes me think that this change introduces another issue somewhere else...