Transparent PNG

P

Peter Carlson

I have searched all the articles and tried various things, but cant seem
to get this to work. CF 3.5 targetting Winmo 6+. I have a png in a
picturebox. Then I have another png that is transparent. the
background is a compass frame and the foreground is the compass rose. I
update the image like this:

Bitmap b2 = Properties.Resources.pngRose;
Graphics gpCompass = Graphics.FromImage(pbCompass.Image);
gpCompass.DrawImage(b2, 0, 0,
new Rectangle(0, 0, b2.Width, b2.Height),
GraphicsUnit.Pixel );
pbCompass.Refresh();

However it draws the rose with a solid white background.

So I thought maybe I need to load the png from a file, but I am not sure
how to do this in the emulator?

So 2 questions:
1. can this be done by embedding the resource?
2. Where do I place the png in the file system of the project in order
to get it onto the emulator?

Peter
 
P

Peter Carlson

Yes,
I drew it in photoshop and it shows there as transparent as well in IE
and windows photo viewer. It is 32bpp

Peter
 
B

badzio

I have searched all the articles and tried various things, but cant seem
to get this to work.  CF 3.5 targetting Winmo 6+. I have a png in a
picturebox.  Then I have another png that is transparent.  the
background is a compass frame and the foreground is the compass rose.  

Hi, not sure how it works in CF 3.5. But in CF 2.0 transparent means
that background is taken from parent control.
You can implement transparency yourself or use some library :) I've
found alphamobilecontrols, it's on LGPL and works fine. But it's for
CF 2.0, you must check if it works on CF 3.5
 
M

Matt Evans

Hi Peter

if I recall correctly, the problem you are seeing is because the .net
cf bitmap loaders don't respect the alpha channel. If you are using
WM5.0 or above you can use the GDI+ and the imaging library api to
load your png files with transparency.

Take a look at this blog post:

http://blog.opennetcf.com/afeinman/PermaLink,guid,e59ee005-91b0-4807-8142-22394b368826.aspx

The OpenNETCF SDF has managed wrappers for the imaging api, and I have
used that to successfully load my transparent png files from the file
system and then draw them to controls.

HTH

Matt
 
V

Vladimir Gregor

Hello Peter.

You can use Bee Mobile TPictureBox component which was designed specifically for this purpose. Just try Bee Mobile iPack (a package of 25 .NET Compact Framework components) and you will find the TPictureBox there.
The download link is:
http://beemobile4.net/?mod=download&packID=2

Good luck with your project.

Best regards
Vladimir Gregor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top