Jump to content

Using C# Unigine.Image convert to a System.Drawing.image


photo

Recommended Posts

Hi!

You can convert Unigine.Image to System.Drawing.Image pixel by pixel.

Here is the example how you can do it:

Unigine.Image img = new Unigine.Image("my_image.png");
int width = img.Width;
int height = img.Height;

Bitmap newImage = new Bitmap(width, height);

for (int x = 0; x < width; x++)
{
	for (int y = 0; y < height; y++)
	{
		var pix = img.Get2D(x, y);
		Color newColor = Color.FromArgb(pix.i.w, pix.i.x, pix.i.y, pix.i.z);
		newImage.SetPixel(x, y, newColor);
	}
}

new_image.Save("new_image.png");

 

Link to comment
  • 1 month later...
×
×
  • Create New...