Hello Hope your doing well Thanks for reaching out!
- Load the GIF
Image gif = Image.FromFile("your.gif");
- Get Frame Count
FrameDimension dimension = new FrameDimension(gif.FrameDimensionsList[0]); int frameCount = gif.GetFrameCount(dimension);
- Select a Frame
gif.SelectActiveFrame(dimension, 0); // Select first frame
- Convert Frame to Editable Bitmap
GIF frames are not editable directly. So we copy the frame to a new bitmap:
Bitmap editableFrame = new Bitmap(gif.Width, gif.Height, PixelFormat.Format32bppArgb); using (Graphics g = Graphics.FromImage(editableFrame)) { g.DrawImage(gif, 0, 0); }
- Change Pixel
Now you can safely change a pixel:
editableFrame.SetPixel(10, 10, Color.Red); // Example: set pixel at (10,10) to red
- Save the Edited Frame
You can save the modified frame as a new image
editableFrame.Save("edited_frame.png", ImageFormat.Png);