Menge Posted September 10, 2003 Posted September 10, 2003 hi guys! i'm posting here because i really couldn't find anywhere else on the net a way to create a bitmap from a 32bit icon. no matter what i do i ALWAYS get a icon with a black border (if it uses alpha) here's what i'm doing. DockTypes.SHFileInfo FileInfo=new DockTypes.SHFileInfo(); SHGetFileInfo(ItemPath, 0, ref FileInfo, (uint)System.Runtime.InteropServices.Marshal.SizeOf(FileInfo), 0x200 | 0x100 | 0x0); Icon ItemIcon=Icon.FromHandle(FileInfo.hIcon); Bitmap IconBitmap=ItemIcon.ToBitmap(); and no matter what i do, it just saturates the alpha channel as if it were 1-bit. All i need is just a bitmap of the icon. nothing more. can anyone please help? Quote Menge
*Gurus* divil Posted September 10, 2003 *Gurus* Posted September 10, 2003 I'm afraid you'll have to keep it in Icon format and draw it using DrawIcon(). There's a bug in .NET where the alpha channel on 32bit icons is not preserved, as you have discovered. If you are adding this in to an image list, add the icon straight in to it (no intermediate bitmap), make sure the image list has the correct colour depth and make sure your application has a manifest to use common controls 6. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Menge Posted September 11, 2003 Author Posted September 11, 2003 i really need this on Bitmap format b/c i need to create a Direct3DTexture out of this... dang... i even tried this ItemIcon=Icon.FromHandle(FileInfo.hIcon); Bitmap IconPic=new Bitmap(128,128); Graphics g=Graphics.FromImage((Bitmap)IconPic); g.DrawIcon(ItemIcon, new Rectangle(new Point(0,0),new Size(128,128))); g.Dispose(); and EVEN SO it gets black borders around it... dang... any help? Quote Menge
NicoVB Posted September 18, 2003 Posted September 18, 2003 I got the same problem.... Use like divil says, the DrawIcon method to Draw an item... I have designed the IconBox control... see NicoLibrary on this forum... Nico Quote Visit http://www.nico.gotdns.com Now ONLINE!
Menge Posted September 19, 2003 Author Posted September 19, 2003 it's because i need this explicitly on a Bitmap object. because DirectX requires a bitmap to create a texture from :\ Quote Menge
AndreRyan Posted September 20, 2003 Posted September 20, 2003 Why do you need to put an icon in Direct3D? You could create the texture from the Bitmap and use a transparency key to remove the background if it's all the same color Quote .Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
Menge Posted September 20, 2003 Author Posted September 20, 2003 it's for a program which i'm making. its a laucher program. but i'm adding more features to it. the thing is. i have an Item type which is an alias to a folder on the hard drive... so clicking this item makes my program open the folder and display its contents. and for its UI, i'm using Direct3D. i find it very cool :) u can get an internal preview here AndreRyan, transparency keys doesn't work on XP-styled icons... that's where i'm having problems... on icons with an 8-bit alpha channel. usual 1-bit alpha channelled icons display just great :) Quote Menge
AndreRyan Posted September 20, 2003 Posted September 20, 2003 This may be useless because it'll probably have the same effect but you can make Bitmaps directly from hIcons DockTypes.SHFileInfo FileInfo=new DockTypes.SHFileInfo(); SHGetFileInfo(ItemPath, 0, ref FileInfo, (uint)System.Runtime.InteropServices.Marshal.SizeOf(FileInfo), 0x200 | 0x100 | 0x0); Bitmap IconBitmap=Bitmap.FromHicon(FileInfo.hIcon); Quote .Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
Menge Posted September 21, 2003 Author Posted September 21, 2003 AndreRyan, thx :P but it doenst do too well either :\ hehe really angry about this, i am. :) Quote Menge
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.