if I use TWPFGGraphicPicture.LoadFromFile(myfile) and then I delete myfile next time I open the form the image has been lost.
There is a way to save the image embedded in the form file ?
thank you
if I use TWPFGGraphicPicture.LoadFromFile(myfile) and then I delete myfile next time I open the form the image has been lost.
There is a way to save the image embedded in the form file ?
thank you
There may be a more elegant way to do it, but here's a way that will work for an existing graphic object assuming the twpformEditor (FE) has a selected graphic object and assuming the graphic is not of the vector variety:
var s:TmemoryStream; p:Tpicture;begin p.LoadFromFile('graphic.bmp'); s:=tMemorystream.Create; with FE do begin p.Bitmap.SaveToStream(s); TWPFGGraphicPicture(SelectedObject).Picture.Bitmap.FreeImage; TWPFGGraphicPicture(SelectedObject).LoadFromStream(s); TWPFGGraphicPicture(SelectedObject).PictureStreamType:='BMP'; s.Free; end;end;
If you want to add a new graphic object:
var
p:Tpicture;
w,h,whRatio:real;
begin
p.LoadFromFile('graphic.bmp');
w:=p.graphic.width;
h:=p.graphic.height;
whRatio:=w/h;
w:=1; // 1 inch default width. user can resize
h:=w/whRatio;
with FE do
begin
SelectObject(InsertGraphic(p.Graphic),false);
SelectedObject.ScaleTo(w,h);
SelectedObject.SetPosition(0,0,w,h);
end;
end;
Alles anzeigen
Hope this helped.
Thanks for the example.
To create the the code blocks I added the CODE tags in brackets.
Julian