#1 2018-08-25 10:09:56

gunix
Member
From: china
Registered: 2015-06-06
Posts: 5

Draw bmp Graphic Error When picture with Transparent:=True

var
  Fpdf:TPdfDocumentGDI;
  Apic:TGraphic;
begin
  Fpdf:=TPdfDocumentGDI.Create;
  Apic:=TBitmap.Create;
  try
    Fpdf.DefaultPaperSize:=psA4;
    Fpdf.ScreenLogPixels:=Screen.PixelsPerInch;
    Fpdf.AddPage;
    Apic.LoadFromFile('d:\z.bmp');
    Apic.Transparent:=True;
    TBitmap(Apic).TransparentColor:=clWhite;
    Fpdf.VCLCanvas.StretchDraw(Rect(20,20,20+Apic.Width,20+Apic.Height),Apic);
    Fpdf.SaveToFile('d:\test.pdf');
  finally
    Apic.Free;
    Fpdf.Free;
  end;
------------------------------------------------
when pictuere with Transparent property set to be True,can not draw picture in pdf.

Offline

#2 2018-08-25 12:27:27

gunix
Member
From: china
Registered: 2015-06-06
Posts: 5

Re: Draw bmp Graphic Error When picture with Transparent:=True

i Understand:
image is no Transparent  property in pdf,so, should draw image first,then text out words.

Offline

#3 2018-08-25 13:28:48

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

Re: Draw bmp Graphic Error When picture with Transparent:=True

Yes, the SynFPC unit doesn't support transparency.

Workaround is indeed to make the transparency at bitmap level, then draw it below the text.

Offline

Board footer

Powered by FluxBB