p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   C# (http://p2p.wrox.com/forumdisplay.php?f=22)
-   -   Display icon on a webpage (http://p2p.wrox.com/showthread.php?t=38912)

rroohhiitt February 23rd, 2006 07:30 AM

Display icon on a webpage
 
Hi

I need to display an .ico file on a webpage. i have the image/icon saved as bytes in the database. From there i read it and have to render on a webpage. The problem is that to display i need to convert it to bmp format and set teh mime type to image/bmp. this causes the icon to loose its transparency and instead black color appears. Any ideas how to sole this

thanks


adam_kahtava February 23rd, 2006 07:36 PM

Your problem is a documented bug (822488), here's a work around.

System.Drawing.Icon Icon1;
Icon1 = new System.Drawing.Icon("c:\\Example.ico");
e.Graphics.DrawIcon(Icon1,0,0);

See the following link for more details: http://www.kbalertz.com/Feedback_822488.aspx

- A.Kahtava

rroohhiitt February 24th, 2006 06:37 AM

Thanks for the reply.
But my prblem is displaying on a webpage.


adam_kahtava February 24th, 2006 08:12 PM

Take a look at the IconExtractor class on the following link:

http://www.codeproject.com/aspnet/As...IconsImage.asp

The Author of the above tutorial seems to have solved the problem.

The Author writes:
IE has a flaw in transparent PNG rendering, causing the transparent areas to render gray. The code includes comments that help you change the implementation from PNG to GIF, losing the transparent background.

The implementation of transparent background in GIF images is way too complicated in .NET, involving unsafe blocks of code, so I decided not to include it in this sample, for the sake of simplicity.

- A.Kahtava


All times are GMT -4. The time now is 12:47 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.