Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB10.0 icon Bitmap
Anyone know of a way of converting an icon to a bitmap that would be larger than 32 x 32? I am trying to display the icon that a user chooses, but 32 x 32 is a tad bit too small. I know I need an icon to be larger than 32 x 32 in the first place, which I do, but the
Icon.ToBitmap
seems to only do 16 x 16 and 32 x 32 regardless how big the icons are.
 
Thanks in advance.
Posted 1-Jul-12 11:43am
Edited 1-Jul-12 11:44am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It makes no sense, usually. Well, how larger? The bitmaps are usually too small; sizes of 40x40 or 64x64 can be considered as very big, you hardly can find any bigger. Also, makes sure you have a legal rights to use some available bitmap the way you want.
 
But the most important factor is this: you can re-sample any bitmap down with acceptable quality, unless extreme cases of a very small ones (16, or 32 pixels are already small), which usually requires manual improvements, which in turn requires special skills and experience. As to the enlargements, all automatic re-sampling methods gives quite lousy quality. (Ever heard of information entropy, http://en.wikipedia.org/wiki/Entropy_%28information_theory%29[^]?)
 
For more or less large images (say, some 50 pixels and more), it's way more beneficial to create and store vector image. Each time you need a bitmap, you should scale a vector image to the size of the bitmap (or more, for subsequent re-sampling down later), and export it as a bitmap. The exported bitmaps can be used to create icons as well. One highly recommended product is the open-source Inkscape, please see:
http://en.wikipedia.org/wiki/Inkscape[^],
http://inkscape.org/[^].
 
[EDIT]
 
Sorry for misunderstanding. There are more than one bitmap in the icon. Extracting them is easy enough. Please see this CodeProject article:
Extracting and displaying icons with VB.NET[^].
 
Pay attention for the class IconImage and see how it works in the code which comes with the article.
 
—SA
  Permalink  
v3
Comments
Rokas Gustys at 1-Jul-12 19:53pm
   
Thanks, for the reply. But there must be a way to do it. There are icon viewers made in VB 6 that allow you to view even a 256 x 256 icon, but I have no idea how to do it in VB.NET 10
Sergey Alexandrovich Kryukov at 2-Jul-12 4:23am
   
To do what? To re-sample a bitmap up and get perfect quality? Did you ever heard that there is no such thing as miracle? Technical means can only assist you. The best method I tries was the fractal compression method, it allows for enlargement, but for bigger source files and with limited quality, which is always limited. Understand finally, that with a small bitmap you have not enough information... Again, use it as a guide to vectorize...
 
By the way, did you vote "3". If you did, why?
--SA
Rokas Gustys at 2-Jul-12 7:11am
   
I though my question was clear enough if you actually read it. I don't want enlargement. Look I have an icon file that has a 256 x 256 32-bit depth quality icon in, and I simply asking for a way to convert that icon data into bitmap data, one file type to another simple as that. So far I only know of one but it limits me to only 32 x 32 in size, which is really small. I appreciate you're answer, but I will not stop until I find away, because I know there is one.
Sergey Alexandrovich Kryukov at 2-Jul-12 15:31pm
   
OOPS! I don't know why I had the impression that you need to re-sample it, probably was distracted by your "larger", sorry about that.
Do you need to extract bitmaps from the icon programmatically, in your code, or you need just to do it somehow?
--SA
Sergey Alexandrovich Kryukov at 2-Jul-12 15:34pm
   
Please see my update above, after [EDIT].
--SA
Rokas Gustys at 4-Jul-12 7:32am
   
Thanks, I've seen it before but it doesn't seem to work, I get all kinds of errors. Fixing one gives me another. Looking at the code it seems he is stripping the very pixels of the icon and putting them into a bitmap format. That is far beyond me. I'm using Visual 'BASIC' for a reason haha XD. I've tried something with it but nothing works. It was also made in Visual Studio 2008, I am using 2010 - maybe that's where the problems are coming from?
 
Hmm... I guess this is much hard to achieve than I thought.
Himachandra at 6-Jul-12 4:00am
   
Nice ...... My 5
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Icon.ToBitmap
 
It works, just gotta must make sure the icon only contains the size you want or try somehow splitting the icon into different sizes and then using it.
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,631
1 Sergey Alexandrovich Kryukov 6,345
2 CPallini 5,230
3 George Jonsson 3,574
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web03 | 2.8.140921.1 | Last Updated 5 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100