Forum > Packages and Libraries
BGRABitmap GIF animation save error
(1/1)
shock:
I have been trying to create a GIF animation using BGRABitmap. I have no trouble creating each frame (24-bit colour plus transparency) as a TBGRABitmap object. I run a simple loop to generate each frame, then call AddFullFrame to add each frame to a TBGRAAnimatedGif object. I get an Access Violation error message when writing the animation to disk ('animation.gif'), though a file is created but with only the first frame in it. If I change the file type to APNG ('animation.apng') the file is written correctly with all frames in the file.
image := TBGRABitmap.Create(1920, 1028, BGRAPixelTransparent);
animation := TBGRAAnimationGif.Create;
animation.SetSize(image.Width, image.Height);
for i := 1 to n_frames
do begin
generate_frame(i, image);
animation.AddFullFrame(image);
end;
animation.SaveToFile('animation.gif');
When writing a single GIF image I find I have to use TRGBAColorQuantizer to reduce the colour depth to 256 before saving the image. I have tried doing the same for each image before passing to AddFullFrame but I still get the Access Violation.
q := TBGRAColorQuantizer.Create(image, acIgnore, 256);
dithered := q.GetDitheredBitmap(daFloydSteinberg, image);
animation.AddFullFrame(dithered);
q.Free;
I have looked through the BGRABitmap sources but can find nothing obvious that would cause this error.
Any help to track this down will be appreciated. Thank you.
Handoko:
Can you provide the whole source code? It will be much easier for us to help you if we have the compile-able source code, so we can run, inspect and find where you did it wrong.
Copy all the source files into a new folder but excluding the binary (exe file), *.bak, lib and backup folders. Compress the folder and sent the zip file to the forum.
Navigation
[0] Message Index