|
-
Mar 29th, 2006, 10:57 AM
#1
[2003] Icon only saved as 16 colors?
I am trying to convert a BMP to an icon, and all goes well, however it is only saved with 16 colors . The method I am using:
VB Code:
Dim MyBMP As New Bitmap(MyPictureBox.Image)
Dim MyIcon As Icon = Icon.FromHandle(MyBMP.GetHicon)
Dim st As System.IO.Stream = New System.IO.FileStream(MyFileName, IO.FileMode.Create)
Dim wr As New System.IO.BinaryWriter(st)
MyIcon.Save(st)
wr.Close()
When testing a JPG with lots of colors as the source image, the resulting Icon is saved with only 16 colors, so the image looks all screwey. Is there a way to go about changing the format to support 16 bit or 32 bit color? Or at least 256? Another method perhaps? I checked the Icon class and there doesnt seem to be much there...
***Note - if you want to test, make sure your original image is 16x16 or 32x32... an attached 32x32 image (of yours truly ) is included in the attachments if you dont feel like making one, as well as the ugly result that shows...
Last edited by gigemboy; Mar 29th, 2006 at 12:17 PM.
-
Mar 29th, 2006, 03:43 PM
#2
Re: [2003] Icon only saved as 16 colors?
hmmm no matter what I do it seems that I cannot save an icon with no more than 4 bits per pixel (16 colors)...
I found this link, http://vbaccelerator.com/home/NET/Ut...or/article.asp . There is an IconEX class in the project that I was hoping would maybe allow me to do it, but it seems like it was a dead end when trying to use it.
Has no one else tried making icons in .NET?? Surely someone out there knows how to make 8, 16, or 32 bit color.... The icon file does show up as having a 32 bit-depth, however, there are only 16 colors that show...
Last edited by gigemboy; Mar 29th, 2006 at 03:46 PM.
-
Mar 29th, 2006, 04:09 PM
#3
Re: [2003] Icon only saved as 16 colors?
This project in VBAccelerator is VB6, but the ZIP contains the EXE to test it. Is this what you want to do? Maybe, it could be translated to VB.Net code..Alpha Icon Creator
-
Mar 29th, 2006, 04:17 PM
#4
Re: [2003] Icon only saved as 16 colors?
Well I can definitely take a look and see if that can be handy, but you would think that .NET would have this simple ability natively... but it seems that it does not, unless someone wants to prove me wrong? Ohhh, how I wish someone would prove me wrong...
-
Mar 29th, 2006, 04:23 PM
#5
Re: [2003] Icon only saved as 16 colors?
Yes, it would be much easier with some native skills from vb.net, it seems there is nothing, still thinking about the SAVE method of a bitmap, that allows to specify the format as icon, why would thay create it if it doesn't work?
I've been looking the code in the VB6 project in my previous link, it's a biggggggg project.
-
Mar 29th, 2006, 04:34 PM
#6
Re: [2003] Icon only saved as 16 colors?
Did you see this one? It's C# but looks easy to translate, there is an example also but it seems just members can download..Dynamically Generating Icons (safely)
-
Mar 29th, 2006, 06:32 PM
#7
Re: [2003] Icon only saved as 16 colors?
The first code in that post that lists "Icon.FromHandle(bmp.GetHicon());" I had already tried, and worked fine, up until you try to save it. It seems that no matter what you do, the Icon.Save method gives you an icon with only 16 colors... a further link in that post directed me to this knowledgebase article that gives me the definite proof.
SYMPTOMS
When you use the Image.Save method to save a graphic image as a Windows Metafile Format (WMF), Enhanced Metafile Format (EMF), or ICON file type, the resulting file is saved as a Portable Network Graphics (PNG) file instead.
CAUSE
This behavior occurs because the GDI+ component of the .NET Framework does not have an encoder that allows you to save files as WMF, EMF, or ICON files.
So I got my answer finally... .NET doesnt have an encoder for WMF, EMF, or ICON formats, it only supports read-only functionality. Haven't tried the other methods he stated yet, but it did leave me feeling better knowing that I wasn't going crazy 
P.S. I can't rate you jcis since I seem to not spread it around enough
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|