Hello,
Please note that when exporting () to GIF an access violation is raised:
procedure TImageFormat_GIF.SaveToStream(stream: TStream; img32: TImage32);
var
gif: TGIFImage;
begin
gif := TGIFImage.Create;
with gif.Bitmap do
try
Width := img32.Width;
Height := img32.Height;
if GetCurrentThreadId <> MainThreadID then Canvas.Lock;
try
img32.CopyToDc(gif.Bitmap.Canvas.Handle,0,0, false);
finally
if GetCurrentThreadId <> MainThreadID then Canvas.Unlock;
end;
gif.SaveToStream(stream);
finally
gif.Free;
end;
end;
After TGIFImage creation, the property of Bitmap is set to nil which caused the AV.
When saving to Bitmap using SaveToStream(Stream,'bmp'), the output is not Bitmap compatible and it seams that the header is missed.
Best regards.
Hi Hafedh.
Thanks for the feedback, and I've verified that that this is indeed a bug.
Hopefully this will work ...
Dear Jhonson,
Thank you for your prompt response.
The Bitmap still exported without BMP File Header.
This function would resolve the problem:
Best regards.
Sorry, I missed your earlier comment re BMP file headers.
Yes TImageFormat_BMP.SaveToStream intentionally omits the file header because they are only required when saving to file streams, and the TImageFormat_BMP.SaveToFile function does include the file header. However, when saving to other streams, eg BMP resource streams, the file header is not required and can cause problems. If you really need the file header in a 'non-file' stream, then you'll need to manually copy the header into the stream before the image (just as is done in TImageFormat_BMP.SaveToFile).