You are not logged in.
Good afternoon!
I have a code like this:
var
MemStream: TSynMemoryStream;
JPEGImage: TSynPicture;
begin
JPEGImage := TJpegImage.Create;
// DB access to load a JPEG from a database
MemStream := TSynMemoryStream.Create(NewStmt.ColumnBlob('JPEGDATA'));
MemStream.Position := 0;
JPEGImage.LoadFromStream(MemStream);
JPEGImage.SaveToFile('c:\temp\myimage.jpeg');
...
end;
The problem is an empty file is created after the execution "SaveToFile".
I have debugged this method and saw that TSynLibrary is nil (screenshot 1) and the method "SaveAs(...)" exits before it can save something (screenshot 2).
Screenshot 1: http://s27.postimg.org/5ab8ioilf/gdiplus.jpg
Screenshot 2: http://s27.postimg.org/mp024p543/gdiplus2.jpg
Could you help me? :-)
Offline
I don't have use ColumnBlob until now but the framework don't load the blob by default (to save memory) so you may need to force the blob reading.
TSQLRecord work in this mode.
Offline
You have to run Gdip.RegisterPictures to initialize the GDI+ library.
Run it in the initialization section of your project.
I have tried it and I get a message like "EFilerError : A class named TJpegImage already exists".
Do you have any suggestions why!?
Offline
I don't have use ColumnBlob until now but the framework don't load the blob by default (to save memory) so you may need to force the blob reading.
TSQLRecord work in this mode.
I know how the blob fields are handled, the code fetches the blob data, i.e. the picture, and I can load it from the stream object into the image-component. The problem is the TSynPicture or the probmlem is me because I can't use TSynPicture in the right way ;-) :-D
Offline
I see two possibilites:
- Run Gdip.RegisterPictures sooner, e.g. in the initialization section of an unit listed topmost of your uses clause of your .dpr
- Get rid of all reference to the Jpeg.pas unit from your project.
Or, instead of calling Gdip.RegisterPictures, run
Gdip := TGDIPlus.Create('gdiplus.dll');
Offline