Important alert: (current site time 7/15/2013 8:16:21 AM EDT)
 

winzip icon

AlphaFix

Email
Submitted on: 8/27/2003 5:56:08 AM
By: Mick Doherty 
Level: Intermediate
User Rating: By 7 Users
Compatibility: VB.NET
Views: 11621
 
     Tired of those ugly black shadows you get from WindowsXP Alpha Icons? Sure DrawIcon solves the problem, but sometimes you just want to pass a bitmap, created from an Icon, to an Image property. This project shows you how.

 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 6 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
8/29/2003 11:33:10 AMDaniel Novak

Love this code! Keep up the good work m8. And I sure hope you continue with this shadow thing going on because you are the only one that have done such thing on .NET that I KNOW OF. :)
(If this comment was disrespectful, please report it.)

 
8/29/2003 1:23:12 PMMick Doherty

Yes. I've seen several posts in newsgroups (mainly c#) pointing people in the general direction, but no actual solution. I tried to do this back in March and failed miserably, I even posted a query at WindowsForms.Net and was offered no solution. At the time I resorted to using an Imagelist set at 16bpp as you can see in my [How Do You Do That... (Menu's)] submission. I just didn't know how close I was to a solution while I was pulling my hair out at that time.
(If this comment was disrespectful, please report it.)

 
8/31/2003 12:13:24 AM

Yeah, from what I know Mick is the ONLY one who has done this. Good job my friend.
(If this comment was disrespectful, please report it.)

 
8/31/2003 2:35:41 PMMick Doherty

I'm sure I'm not the first, others just kept it to themselves, but now everyone will be doing it, unless Bill releases a patch to close up this workaround ;)
(If this comment was disrespectful, please report it.)

 
9/4/2003 6:23:02 AM

Great work! Small but good! Not an intermediate level! ;)
(If this comment was disrespectful, please report it.)

 
9/4/2003 6:53:20 AMMick Doherty

I don't think beginners should be playing with interop or memory structures, so It's not a beginner category (unless, like me, they are converting from VBClassic :) ), and I certainly would not call it advanced (still a few problems to sort out).
(If this comment was disrespectful, please report it.)

 
11/20/2003 1:37:35 AM

i get an error during compile on the Marshal.copy line, and the code is pretty intermediate, how do i use the code for a bitmap i made with a drop shadow?
(If this comment was disrespectful, please report it.)

 
11/20/2003 6:26:18 AMMick Doherty

I don't know what error you were getting, but it was probably due to the bitmap you passed going out of scope(Garbage Collector is not always helpful). I have been working on this and have made some improvements(Marshal.Copy no longer used). I will now update this submission.
This function should work with any 32bppArgb bitmap. What format is the bitmap you created?
(If this comment was disrespectful, please report it.)

 
8/16/2004 8:20:32 AMThe New iSoftware Company!

Theres a way without any coding. Get a editor like gifmoviegear and export the 32 bit png. Use that as your image. Works great.
(If this comment was disrespectful, please report it.)

 
8/16/2004 10:39:40 AMMick Doherty

You don't need any code if you simply want to convert the image. Just draw it to a PictureBox and save it. The point of this code is that, for example, Windows XP 32 bit Icons have Alpha Content. Everyone with Windows XP already has these Icons so why would I want to distribute them with my application, even if the licensing permitted it? If I want to show these Icons in a control which accepts an Image Property rather than an Icon property then I need to convert them first.

There is an updated example of this method on my site which returns a bitmap even when the Icon does not contain Alpha.
http://dotnetrix.co.uk/misc.html
(If this comment was disrespectful, please report it.)

 
2/13/2005 5:12:16 PMThomas Yates

Bah to all that say converting images! By a method like this (which i spent a great 1-2 weeks looking for) you can hold ONE resource Icon in your APP and load it to this function thereby SAVING size of the program and allowing a more uniform look if you need to change the image in the future. Also note that this is not just for the alpha icons from microsoft but there are royalty free icons out there if you know where to get them. I havent looked at the code yet but it looks VERY promising. a 5 from me. Very good!!!!!
(If this comment was disrespectful, please report it.)

 
5/9/2006 3:10:57 PMmojtaba

this is power of programmer
(If this comment was disrespectful, please report it.)

 
9/8/2006 5:30:24 PMShimirel Information Systems

You don't need any of the above, at least not for VB 2005. Just extract the icon you want to display into an icon object rather than a bitmap object. You need to add the icons as 32bit pictures to the imagelists do both of those and your sorted no shadow icons.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.