The behavior of ppImage with EMF
Hi, there
I want to print some graphs dynamically at running time.
I draw then graph on canvas and save them as EMF file and then
assign them to the ppimage.picture.
I am annoying with the following drawing. ppImage can not be print
correctly with EMF that use FloodFill command.
What is the different between FillRect and FloodFill?
var
MetaFile: TMetafile;
//canvas
MFCanvas: TMetafileCanvas;
lDC: THandle;
begin
MetaFile := TMetafile.Create;
try
MetaFile.Width := 500;
MetaFile.Height:= 500;
//
lDC := GetDC(0);
MFCanvas := TMetafileCanvas.Create(MetaFile, lDC);
try
MFCanvas.Pen.Color := clBlack;
MFCanvas.Pen.Width := 1;
//
MFCanvas.Rectangle(10, 10, 400, 110);
MFCanvas.Rectangle(10, 210, 400, 310);
//style
MFCanvas.Brush.Style := bssolid;
//color
MFCanvas.Brush.Color := RGB(255,255,0);
//The following is OK
MFCanvas.FillRect(rect(11,11,399,109));
MFCanvas.Brush.Color := RGB(255,0,255);
//The following can not be draw when printing, but display normally at preview
MFCanvas.FloodFill(20,250,clBlack,fsBorder);
finally
MFCanvas.Free;
end;
//save to file
MetaFile.SaveToFile('D:\testEMF.emf');
finally
MetaFile.Free;
end;
end;
Thanks for your information
regards
Yong
I want to print some graphs dynamically at running time.
I draw then graph on canvas and save them as EMF file and then
assign them to the ppimage.picture.
I am annoying with the following drawing. ppImage can not be print
correctly with EMF that use FloodFill command.
What is the different between FillRect and FloodFill?
var
MetaFile: TMetafile;
//canvas
MFCanvas: TMetafileCanvas;
lDC: THandle;
begin
MetaFile := TMetafile.Create;
try
MetaFile.Width := 500;
MetaFile.Height:= 500;
//
lDC := GetDC(0);
MFCanvas := TMetafileCanvas.Create(MetaFile, lDC);
try
MFCanvas.Pen.Color := clBlack;
MFCanvas.Pen.Width := 1;
//
MFCanvas.Rectangle(10, 10, 400, 110);
MFCanvas.Rectangle(10, 210, 400, 310);
//style
MFCanvas.Brush.Style := bssolid;
//color
MFCanvas.Brush.Color := RGB(255,255,0);
//The following is OK
MFCanvas.FillRect(rect(11,11,399,109));
MFCanvas.Brush.Color := RGB(255,0,255);
//The following can not be draw when printing, but display normally at preview
MFCanvas.FloodFill(20,250,clBlack,fsBorder);
finally
MFCanvas.Free;
end;
//save to file
MetaFile.SaveToFile('D:\testEMF.emf');
finally
MetaFile.Free;
end;
end;
Thanks for your information
regards
Yong
Comments
When you say "Print the report" are you printing to a printer or are you perhaps exporting to PDF?
Below are links to the documentation for FillRect and FloodFill. One fills a rectangle and the other fills the area of a certain color.
FillRect:
http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/Graphics_TCanvas_FillRect.html
FloodFill:
http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/Graphics_TCanvas_FloodFill.html
Another note, instead of saving a metafile as an image to file then loading it to a TppImage, you can use the TppPaintBox component to draw directly to the report.
http://rbwiki.digital-metaphors.com/rcl/paintbox/how-to-use-the-paintbox-component/
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thank you very much for your information.
best Regards,
Yong