Home RAP
New Blog Posts: Merging Reports - Part 1 and Part 2

DBImage.OnGetPicture transparency

edited April 2011 in RAP
Hi,

My program has a couple png images in a timagelist and I want to give the
user a way to use these images
I created a passthru function that can be called from
DBImage.OnGetPicture().

The problem is alpha transparency for the png images is lost.
It seems normal mask transparency works. What am I missing?

class function TRapDrawContactCategoryIcon.GetSignature: String;
begin
Result := 'procedure DrawContactCategoryIcon(const APicture: TPicture;
const AImageIndex: integer; const ASmallIcons: boolean);';
end;

procedure TRapDrawContactCategoryIcon.ExecuteFunction(aParams:
TraParamList);
var Picture: TPicture;
ImageIndex: integer;
SmallIcons: boolean;
begin
GetParamValue( 0, Picture );
GetParamValue( 1, ImageIndex );
GetParamValue( 2, SmallIcons );

if Assigned(Picture) or (ImageIndex < 0) or
(ImageIndex >= DMResource.imgEvent.Count)
then begin
Picture.Bitmap.Transparent := True;
if SmallIcons
then DMResource.imgEventSmall.GetImage(ImageIndex, Picture.Bitmap)
else DMResource.imgEvent.GetImage(ImageIndex, Picture.Bitmap);
end;
end;


Using RB11.08

Regards,
Jeroen.

Comments

  • edited April 2011
    Hi Jeroen,

    Are you able to see the image correctly if you use Delphi instead of
    RAP? What happens if you simply load the image into a TppImage
    component manually? If you would like, you can send me the image you
    are trying to view and I can try to recreate the problem here on my machine.


    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2011
    Hi Nico,

    I did test it with Delphi and TImage with the same results.
    I managed to get the desired result using some classes from DevExpress.
    There the code:

    uses dxGDIPlusClasses;

    procedure TDMResource.GetPNGImage(const AImageList: TcxImageList; const
    AItemIndex: integer; const APicture: TPicture);
    var srcBmp: TcxAlphaBitmap;
    PNG: TdxPNGImage;
    begin
    if Assigned(APicture) and Assigned(AImageList)
    then begin
    srcBmp := TcxAlphaBitmap.Create;
    PNG := TdxPNGImage.Create;
    try
    AImageList.GetImage(AItemIndex, srcBmp);
    PNG.SetBitmap(srcBmp);
    APicture.Assign(PNG);
    finally
    srcBmp.Free;
    PNG.Free;
    end;
    end;
    end;


This discussion has been closed.