You are not logged in.
Pages: 1
Hi, Synopse and Arnaud!
Many thanks for your highly useful GDI unit!
During my development I've found that using SynGdiPlus (I use only LoadFromFile/ToBitmap/SaveToFile to work with tif files) in background thread sometimes leads to "black squares" instead of normal image in bitmaps.
Usually it is symptom of multithreading problems with Canvas.
SynGdiPlus uses Canvas.Draw without Lock/Unlock.
I've added the following changes:
begin
if not fHasContent then
...
else begin
...
result.Canvas.Lock;
try
result.Canvas.Draw(0,0,self);
finally
result.Canvas.Unlock;
end;
end;
end;
procedure SaveAs(...)
...
Bmp := TBitmap.Create;
try
...
Bmp.Canvas.Lock;
try
Pic.Draw(Bmp.Canvas,R);
finally
Bmp.Canvas.Unlock;
end;
SynGdiPlus.SaveAs(Bmp,Stream,Format,CompressionQuality,0,BitmapSetResolution);
finally
Bmp.Free;
end;
After that I see no problems in intensive tests.
(Also for all who want to use SynGdiPlus in background thread: don't forget to use CoInitializeEx/CoUninitialize.)
Offline
Please check https://synopse.info/fossil/info/93f8369d36
Thanks a lot for your input!
Offline
Pages: 1