1

Hi there I am looking to create a image dynamically from an array[500][500] (500x500pixel) Each array item has the pixel color data,

Does anyone know which .NET library/interface would be best for this? Could point me in right direction? I need to create/save the file.

Also, The image is a composite of the data from many images, I am wondering if it is possible to use various formats, or if I need to first convert the small images into one format,

Also which image format is best to use (the most compatible?) JPG/PNG24? (for web)

Thanks for your input!

3 Answers 3

2

if you can use unsafe code in your website (in other words, your code runs under full trust), just use the Bitmap class, and use the LockBits method, then you can use pointers just like in C++ to access the pixels (tip: create a Pixel struct to hold RGB values). You will see GetPixel and SetPixel methods, DO NOT EVER use them. The performance is terrible, more than 100 times slower than using pointers. Just go with BitmapData.Scan0.ToPointer() and then iterate with for.

Sign up to request clarification or add additional context in comments.

Comments

1

You could use the System.Drawing.Bitmap class.

If you are able to use unsafe code, construct the bitmap using pointers and BitmapData rather than SetPixel

var bitmap = new Bitmap(500, 500);

// Update the pixels with values in you array...

bitmap.Save("myfilename.jpg", ImageFormat.Jpeg);

Comments

0

The format depends on what you need (for example png can support transaprency, jpg does not).

You could start wich System.Drawing.Bitmap .

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.