Jump to content
  • Advertisement
Sign in to follow this  
EricLeeFriedman

C# Image and alpha

This topic is 2753 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

I have a C# Image class (System.Drawing) that contains a texture of just RGB data. I also have a byte array of alpha values that correspond to each texel in the C# Image.

I was wondering if there was any built in way to combine these two into the current Image object, or a new Image object such that I could easily save the texture to the hard drive as a PNG file.

Thank you,
Eric

EDIT: Figured this out. Copying the Image object into a Bitmap object allows for editing of the texels.

Share this post


Link to post
Share on other sites
Advertisement
As an aside, Bitmap.GetPixel() and Bitmap.SetPixel() are fairly slow operations as they lock/unlock the Bitmap each time. A faster way to manipulate a Bitmap's pixels is to first lock it manually then read or write pixel data by copying arrays. The LockBits documentation has an example of the technique.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!