I tried changing the icon to an external hard drive but when I try to use any image - png, jpg, icns, ico - the icon will display as the default/generic version of the file type. The rest of my drives still display the custom images from before the update. I deleted the generic change to the system default yellow drive icon. Feb 28, 2019 Create icons. There are tons of tools for creating icons from PNG and JPG/JPEG images but we recommend using IcoConvert. It can resize images as well as apply a shape style. We strongly recommend that you use an image that is a square or it will be stretched or squished.
![]() ![]()
I have a project that converts an image format file into an icon file. However, after converting the image, the color of the image changes.Here is my code Bitmap theBitmap = new Bitmap(theImage, new Size(width, height));IntPtr Hicon = theBitmap.GetHicon;// Get an Hicon for myBitmap.Icon newIcon = Icon.FromHandle(Hicon);// Create a new icon from the handle.FileStream fs = new FileStream(@'c:Icon' + filename + '.ico', FileMode.OpenOrCreate);//Write Icon to File StreamAnybody know how to solve this? Bitmap.GetHicon is very good at creating icons that work well on any Windows version that can run.NET code. Including the old ones, Windows 98 and Windows 2000. Operating systems that did not yet support fancy icons.So what you get is an icon with only 16 colors, using a pre-cooked palette with basic colors. This tends to generate disappointing results, to put it mildly.The Bitmap or Icon classes do not have an option to get a better result.
In general you'll need to use an icon editor to create good icons. Which should include multiple images in different sizes and color depths so they'll work well with any video adapter setting and any operating system version. Particularly color reduction from 16 million to 256 or 16 colors is a non-trivial operation with multiple ways to do it, none of them perfect. A good icon editor has the tools you need to make that work well enough.UPDATE: getting to be a very dated problem, XP is yesteryear.
![]()
Today you can generate a very good looking icon with. If you only need 32-bit icons, you can use FreeImage string icoFile = 'C:pathtofile.ico';FreeImageBitmap fiBitmap = new FreeImageBitmap(theBitmap);fiBitmap.Rescale(48, 48, FREEIMAGEFILTER.FILTERBICUBIC);fiBitmap.Save(icoFile);fiBitmap.Rescale(32, 32, FREEIMAGEFILTER.FILTERBICUBIC);fiBitmap.SaveAdd(icoFile);fiBitmap.Rescale(16, 16, FREEIMAGEFILTER.FILTERBICUBIC);fiBitmap.SaveAdd(icoFile);If you want full support for 32, 8, 4, and 1-bit icons, you will have to create your own ico format writer. I ran into this problem while developing my own C# based png to ico converterIt actually isn't too difficult; the ico file format specifications you will need are here:You will also need the Bitmap header specification from here, as ico is a subset of bitmap.
![]() Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |