This project is read-only.

Convert System.Drawing.Image to PlataformAPI.IImage

Mar 1, 2009 at 7:44 PM
Hi everyone!

First, much congrats for this project.

But... I decided to improve the designer suport of the controls (well, my customer decided this).
Then, I want to create a property Image in the AlphaPictureBox that work like the standart image (property of type System.Drawing.Image).
Now I need a way to convert the System.Drawing.Image to PlataformAPI.IImage or AlphaImage class.

I tried something like this:
var stream = new MemoryStream();
image.Save(stream, ImageFormat.Png);
var alphaImage = AlphaImage.CreateFromStream(stream);
alphaImage.Draw(gx, Bounds);

The code runned, but the alpha channel was lost (image displayed with a white background).
I tried too much others ways, but all didn't worked.

Anybody have other ideas to convert Image (or Bitmap) to IImage or AlphaImage without losing the alpha channel?
Thanks in advance!

Oct 2, 2009 at 8:16 PM
Edited Oct 2, 2009 at 8:17 PM

Well, this is an issue.

Aparently, the visual studio designer, removes the alpha channel in png files prior to deploy (in design time the alpha is still there).

But when stored as embedded resources, the files remains intact. in my test while in design time, i load the images from the PC file system, but in run time i load them from resources (or even files copied to the device)

Also, for proper design time experience you shoul detect the current os platform and avoid calling p/invokes from WinCe in the desktop (this leads to white boxes with no custom paint)

 Best regards, and i hope this post dont come too late ;)

Rodrigo Ruiz