How to: Convert Bitmap to Image?

  • Thread starter Thread starter Danyel Meyer - dialog-it GmbH
  • Start date Start date
D

Danyel Meyer - dialog-it GmbH

Hallo!

When using OpenNetCF´s ButonEx I´d like to put transparent images onto them.
I have created a function that fakes transparency of a given Image-object
and returns a Bitmap-object.
The ButtonEx of the SDF only accepts Image-objects for its Image-attribute,
so how do I convert a Bitmap-object to an Image-object?

Thanks in advance,

--
Danyel Meyer
-------------------------------------------
dialog-it GmbH
Röllinghäuser Strasse 55a
31061 Alfeld/Leine

Tel +49 (0) 5181 900 814
Fax +49 (0) 5181 900 815
E-Mail danyel.meyer <at> dialog-it.de
 
Since Bitmap inherits from Image you can assign it to the Image property of
ButtonEx.

Bitmap bmp = new Bitmap("somefile.gif");
buttonEx1.Image = bmp;

Peter
 
Thanks Peter, but that is what I have tried, and it does not work. I get an
"Not supported" exception on it... thats why I asked ;)


--
Danyel Meyer
-------------------------------------------
dialog-it GmbH
Röllinghäuser Strasse 55a
31061 Alfeld/Leine

Tel +49 (0) 5181 900 814
Fax +49 (0) 5181 900 815
E-Mail danyel.meyer <at> dialog-it.de
 
Well, ok...

It needs something like the following to work:

buttonEx1.Image = New Bitmap(myFunction(New Bitmap(the Image),
Color.WhatEver))

Thanks Peter ;)


--
Danyel Meyer
-------------------------------------------
dialog-it GmbH
Röllinghäuser Strasse 55a
31061 Alfeld/Leine

Tel +49 (0) 5181 900 814
Fax +49 (0) 5181 900 815
E-Mail danyel.meyer <at> dialog-it.de
 
It should work, but maybe try to explicitly cast it:

Bitmap bmp = new Bitmap("mypic.bmp");
buttonex1.Image = (Image)bmp;

-Chris
 
Back
Top