Harry Rogers Posted August 30, 2018 Share Posted August 30, 2018 Hi Whats the way to save a png image file to disc from a Tuniimage that gets its image from a url? Dragging the image to the desktop from the browser creates a png file in the desktop directory yet the standard programmatic file and stream based methods just result in a zero length file. e.g. uniimage1.picture.savetofile('afile.png') uniimage1.picture.graphic.savetofile('afile.png') uniimage1.picture.bitmap.savetofile('afile.png') So far I've used an additional TidHttp to Get the data from the same url as the Tuniimage and write it to a filestream which works fine but it would be nice to just use the one resource if possible. Thanks Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted August 30, 2018 Administrators Share Posted August 30, 2018 In my test below code worked: UniImage1.Picture.SaveToFile('c:\temp\x.png'); Quote Link to comment Share on other sites More sharing options...
Harry Rogers Posted August 30, 2018 Author Share Posted August 30, 2018 Thanks for the rapid response Farshad The attached illustrates the issue. The uniimage gets its picture form a google api that draws a QR code. the savetofile method results in a zero length file. Many thanks TestImg.zip Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted August 30, 2018 Administrators Share Posted August 30, 2018 SaveToFile() only works for images that are intenally stored in memory or a cahce file. If source of image is an URL then it can not be saved directly using Picture property. Quote Link to comment Share on other sites More sharing options...
Harry Rogers Posted August 30, 2018 Author Share Posted August 30, 2018 Ok thanks - I'll carry on the way I was then. All the best Quote Link to comment Share on other sites More sharing options...
andyhill Posted December 10, 2019 Share Posted December 10, 2019 I have a Mobile Image that I create the bitmap at runtime, how can I export it (I am using an ajax event to allow stability) ? procedure TUniServerModule.UniGUIServerModuleCreate(Sender: TObject); begin EXEDir:= UniServerModule.StartPath; ... procedure TMainmForm.PanelAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if SameText(EventName, 'ExportImage') then begin Image.Picture.SaveToFile(UniServerModule.EXEDir+'\files\temp\tmp.png'); // CLAIMS D:\nnnn\files\temp Directory Not Found when it exists ... Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 10, 2019 Share Posted December 10, 2019 10 minutes ago, andyhill said: I have a Mobile Image that I create the bitmap at runtime, how can I export it Can you make a simple testcase for this? Quote Link to comment Share on other sites More sharing options...
andyhill Posted December 10, 2019 Share Posted December 10, 2019 I moved the ajax request to FormReady and all OK now (stability issue) procedure TMainmForm.UnimFormReady(Sender: TObject); begin UniSession.AddJS('ajaxRequest(MainmForm.Panel, "ExportImage", []);'); end; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.