Why does this Seg fault? bgrareplace lazarus / 39-Graphics ---------------------------------------------------------------------- vonskie · 2017-09-13 14:55 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; ---------------------------------------------------------------------- lainz · 2017-09-15 17:37 You can upload a small program that reproduces the error? ---------------------------------------------------------------------- vonskie · 2017-09-15 21:50 i think bgrareplace automatically frees newimage so the finally newimage.free was an issue. ---------------------------------------------------------------------- lainz · 2017-09-15 22:38 Quote from: vonskie on September 15, 2017, 11:50:43 pmi 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. ---------------------------------------------------------------------- circular · 2017-09-17 17:10 Indeed. BGRAReplace frees the destination image.