I need to extract RGB byte values of each pixel of a small GIF stored on a PC (16x16 pixels) as I need to send them to a LED display that accepts RGB 6 byte color code.
After opening the test file and converting it to a 1D byte array I get some byte values, but I am not sure if that decodes the GIF frame and as a result will return my desired pure 192 byte RGB array?
'img = Image.FromFile("mygif.gif");
FrameDimension dimension = new FrameDimension(img.FrameDimensionsList[0]);
int frameCount = img.GetFrameCount(dimension);
img.SelectActiveFrame(dimension, 0);
gifarray = imageToByteArray(img);`
//image to array conversion func.
public byte[] imageToByteArray(System.Drawing.Image imageIn)
{
MemoryStream ms = new MemoryStream();
imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
return ms.ToArray();
}
Or maybe there is another method for doing that?