[Lazarus] TImageList.AddMasked not working with TBitmap.PixelFormat := pf32bit

Boian Mitov mitov at mitov.com
Tue Apr 14 11:01:56 CEST 2009


      Hi Mark,

Thank you!
The reason I need to use pf32bit is that I manipulate the raw image, and I 
access the pixels as integers. I can't do that if the image is 24 bit. I 
actually don't care about the Alpha channel in this case.

  AScanLineImage:=TLazIntfImage.Create(0,0);
  AImgFormatDescription.Init_BPP32_B8G8R8_BIO_TTB(Images.Width,Images.Height);
  AScanLineImage.DataDescription := AImgFormatDescription;

    for Y :=0 to AScanLineImage.Height-1 do
      begin
      Ptr := AScanLineImage.GetDataLineStart( Y );
      for X := 0 to AScanLineImage.Width-1 do
        begin
        AColor := TColor( Ptr^ and $FFFFFF );
         if( AColor = clWhite ) then
          Ptr^ := AGlyphColor

        else if( AColor = clGray ) then
          Ptr^ := ABorderColor

        else if( ASecondaryArea and ( AColor = clRed )) then
          Ptr^ := ABorderColor

        else if( AColor = clLtGray ) then
          Ptr^ := AHalfToneColor

        else if( AColor = clBlack ) then
          Ptr^ := AButtonColor
   ....
   ....
    AIntfImage.CopyPixels( AScanLineImage );
    ABitmap.LoadFromIntfImage( AIntfImage );

    Images.ReplaceMasked( ImageIndex, ABitmap, InvertColor( AUniqueColor ));

As you can see I need this so I can access the pixels fast as a raw image, 
and need to get the image back. This is significantly more complex in 24 bit 
image, so the need for 32 bit image being added as masked is obvious.

With best regards,
  Boian Mitov

-------------------------------------------------------
Mitov Software
www.mitov.com
-------------------------------------------------------
----- Original Message ----- 
From: "Marc Weustink" <marc.weustink at cuperus.nl>
To: "General mailing list" <lazarus at lazarus.freepascal.org>
Sent: Tuesday, April 14, 2009 1:29 AM
Subject: Re: [Lazarus] TImageList.AddMasked not working with 
TBitmap.PixelFormat := pf32bit


> there is not a good reason to add a 32bit alpha image using a mask.
> Anyway, in the current implementation, the added images are converted
> first. This is still a todo to fix.




More information about the Lazarus mailing list