Bitmap and Icons

J

jaumef_2000

Hello, I'm developing a Standard Windows App and I need to deal with
Icons.

I've read lots of posts about them and I'm missing something. I put
this code in a button click in a new brand new solution:

Bitmap bmp = new
Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsApplication1.Bitmap1.bmp"));
Icon ic = Icon.FromHandle(bmp.GetHicon());
Icon ic2 = new
Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsApplication1.App.ico"));;
this.pictureBox1.Image = bmp;
this.pictureBox2.Image = ic.ToBitmap();
this.pictureBox3.Image = ic2.ToBitmap();

Results are:

bmp is displaying OK.
ic, that should be a copy of bmp is a black square.
ic2 is displaying but with black background instead of transparent.

What I'm missing?? I must work with Icons and none ways work correctly.
I'm using .net Framework 1.1 with SP1. The App.ico is the automatically
generated by VS, the bitmap is generated by VS....

I've tried everything writen in all posts I found and no results.....
When creating an Icon from a bitmap always get a black square,
different bpp = black square, creating a bmp from an icon OK the an
icon from that bmp = black square, I've changed securitypermission to
allow unmanaged code due to the Hicon = black square. I've ran out of
ideas and time....

Please Help needed

Thanks in advance.

Jaume Figueras.
 
F

Frans Bouma [C# MVP]

Hello, I'm developing a Standard Windows App and I need to deal with
Icons.

I've read lots of posts about them and I'm missing something. I put
this code in a button click in a new brand new solution:

Bitmap bmp = new
Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestRe
sourceStream("WindowsApplication1.Bitmap1.bmp")); Icon ic =
Icon.FromHandle(bmp.GetHicon()); Icon ic2 = new
Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestReso
urceStream("WindowsApplication1.App.ico"));; this.pictureBox1.Image =
bmp; this.pictureBox2.Image = ic.ToBitmap();
this.pictureBox3.Image = ic2.ToBitmap();

Results are:

bmp is displaying OK.
ic, that should be a copy of bmp is a black square.
ic2 is displaying but with black background instead of transparent.

What I'm missing?? I must work with Icons and none ways work
correctly. I'm using .net Framework 1.1 with SP1. The App.ico is the
automatically generated by VS, the bitmap is generated by VS....

I've tried everything writen in all posts I found and no results.....
When creating an Icon from a bitmap always get a black square,
different bpp = black square, creating a bmp from an icon OK the an
icon from that bmp = black square, I've changed securitypermission to
allow unmanaged code due to the Hicon = black square. I've ran out of
ideas and time....

You can also create the .ico files yourself. Use iconsushi for that:
import a .bmp and save it as .ico. Make sure the bmp has an alpha
channel.

http://www.towofu.net/soft/e-index.php

FB


--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 
J

jaumef_2000

Hello,

there's no benefit using an external application. I'm getting a black
box with other windows icons that are correctly generated. I also need
to generate icons at runtime.

Thanks.

Jaume.
 

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