Lazarus
Programming => Graphics and Multimedia => Graphics => Topic started by: vonskie on September 13, 2017, 04:55:48 pm
-
Why does this Seg fault here
>>>>bgrareplace(bmp,newimage);
Here is the code
Am I using bgrareplace correctly?
bmp := TBGRABitmap.Create;
bmp.LoadFromfile(imageselected.Text);
try
newimage := TBGRABitmap.Create(screen.Width, screen.Height, BGRABlack);
newimage.PutImage(0, 0, bmp, dmDrawWithTransparency);
bgrareplace(bmp,newimage);
finally
newimage.free;
end;
bmp.SaveToFile(filepath + 'wallpaper.bmp');
bmp.free;
-
You can upload a small program that reproduces the error?
-
i think bgrareplace automatically frees newimage so the finally newimage.free was an issue.
-
i think bgrareplace automatically frees newimage so the finally newimage.free was an issue.
BGRAReplace is designed to replace the same image, like
BGRAReplace(bmp, bmp.Resample(...) as TBGRABitmap);
Because some methods creates a new bitmap, usually you want to be the same bitmap as output, like when you do, for example, resample, blur and other filters.
-
Indeed. BGRAReplace frees the destination image.