#1 2018-01-17 13:39:09

bartvde
Member
Registered: 2018-01-17
Posts: 1

Transparency png images

Hello,

I have a quickreport with some png-images on it with transparent background.

When I render this report, the images get a black background instead of being transparent.

This is the code I use:

function TfrmMain.ExportPdf(aReport: TQuickRep; aFileName: String): Boolean;
var
  I: Integer;
  PdfDocument: TPdfDocumentGDI;
  Page: TMetafile;
begin
  Result := False;

  PdfDocument := TPdfDocumentGDI.Create();
  PdfDocument.UseUniscribe := True;

  try
    aReport.Prepare;

    for I := 1 to aReport.QRPrinter.PageCount
    do begin
      PdfDocument.AddPage;

      Page := aReport.QRPrinter.GetPage(I);

      try
        PdfDocument.Canvas.RenderMetaFile(Page);
      finally
        Page.Free;
      end;
    end;

    Result := PdfDocument.SaveToFile(aFileName);
  finally
    PdfDocument.Free;
  end;

end;

this is the result in the pdf. Is there a fix for this?

Thx!
Bart
Not_Transparent.png

Offline

#2 2018-01-17 13:49:52

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,238
Website

Re: Transparency png images

As documented, transparency is not handled yet for images.

PDF is pretty complex to implement in this matter.

The only workaround is to render the alpha channel into a regular bitmap, then draw the bitmap.

Offline

Board footer

Powered by FluxBB