Lazarus BitsPerPixel 错误

Lazarus BitsPerPixel error

有一个用 Lazarus 编写的简单应用程序。当它尝试打开图形文件时出现 "incompatible BitsPerPixel" 错误。 OS:Debian。拉撒路:1.4.0。关于如何解决它的任何想法?

ERROR in LCL: TGtk2WidgetSet.CreateBitmapFromRawImage Incompatible BitsPerPixel

Creating gdb catchable error:
[=10=]0000000050B225 line 720 of lazloggerbase.pas
[=10=]000000004BCBDE line 1414 of lclproc.pas
[=10=]000000004BAB0B line 859 of lclproc.pas
[=10=]000000005E38A6 line 417 of gtk2lclintf.inc
[=10=]00000000568A45 line 152 of include/lclintf.inc
[=10=]000000004DB208 line 3622 of intfgraphics.pas
[=10=]0000000054A7BA line 554 of include/rasterimage.inc
[=10=]0000000045FDC3 line 86 of unit1.pas
[=10=]00000000460258 line 144 of unit1.pas
TApplication.HandleException Failed to create handles
Stack trace:
[=10=]000000004DB22E line 3623 of intfgraphics.pas
[=10=]0000000054A7BA line 554 of include/rasterimage.inc
[=10=]0000000045FDC3 line 86 of unit1.pas
[=10=]00000000460258 line 144 of unit1.pas
[=10=]000000006346A8 line 2724 of include/control.inc
[=10=]000000006636E6 line 54 of include/buttoncontrol.inc
[=10=]00000000663FD6 line 169 of include/buttons.inc
[=10=]000000006635E9 line 20 of include/buttoncontrol.inc
[=10=]0000000042E411
[=10=]000000006241C1 line 5341 of include/wincontrol.inc
[=10=]0000000070B585 line 112 of lclmessageglue.pas
[=10=]0000000071ADB2 line 2423 of gtk2wsstdctrls.pp

代码:

        procedure TForm1.ReadFromImage(var img: TRGBArray);
        var px,py: integer;  
            row: pRGBTripleArray;
            lazImage : TLazIntfImage;
            rawImage: TRawImage;
        begin
           If OpenPictureDialog1.Execute then
          begin
            rawImage.Init;                                   
            rawImage.Description.Init_BPP24_B8G8R8_BIO_TTB(0,0);
            rawImage.CreateData(false);                         

            lazImage:=TLazIntfImage.Create(0,0);    
            lazImage.SetRawImage(rawImage);        
            lazImage.LoadFromFile(OpenPictureDialog1.FileName);
            SetLength(img,lazImage.Width,lazImage.Height);     

            Image1.Picture.Bitmap.LoadFromIntfImage(lazImage); 
            lazImage.Free;
          end;
        end;         

xwininfo 结果:

xwininfo: Window id: 0x1a0002d "RGB<->XYZ<->Lab"
Absolute upper-left X:  642
Absolute upper-left Y:  37
Relative upper-left X:  2
Relative upper-left Y:  0
Width: 636
Height: 1041
Depth: 24
Visual: 0x20
Visual Class: TrueColor
Border width: 0
Class: InputOutput
Colormap: 0x22 (installed)
Bit Gravity State: NorthWestGravity
Window Gravity State: NorthWestGravity
Backing Store State: NotUseful
Save Under State: no
Map State: IsViewable
Override Redirect State: no
Corners:  +642+37  -642+37  -642-2  +642-2 
-geometry 636x1041+640-0

不知道为什么,考虑到 24 位 window 深度,但切换到 Init_BPP32_B8G8R8A8_M1_BIO_TTB();解决了问题。