473,508 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get the icon with alpha channel using ExtractIconEx api?

yxq
Hello,
I use the API ExtractIcon to get icon from Shell32, but the returned icon
lost alpha channel, how get back the alpha channel? thank you.

************************************************** ********************************************
Private Declare Function ExtractIconEx Lib "shell32.dll" Alias
"ExtractIconExA" (ByVal lpszFile As String, ByVal nIconIndex As Int32, ByRef
phiconLarge As Int32, ByRef phiconSmall As Int32, ByVal nIcons As Int32) As
Int32
Private Declare Function DestroyIcon Lib "user32.dll" (ByVal hIcon As
Int32) As Int32

Function getIconFromFilename(ByVal filename As String, ByVal iconIndex
As Int16, ByVal largeIcon As Boolean) As Bitmap

Dim iconLarge As Int32
Dim iconSmall As Int32
If (ExtractIconEx(filename, iconIndex, iconLarge, iconSmall, 1) > 0)
Then
Dim iconPtr As IntPtr

If largeIcon = True Then
iconPtr = New IntPtr(iconLarge)
Else
iconPtr = New IntPtr(iconSmall)
End If

Dim iconRes As Icon = Icon.FromHandle(iconPtr)

Dim returnBitmap As Bitmap = iconRes.ToBitmap
iconRes.Dispose()
If iconLarge <> 0 Then DestroyIcon(iconLarge)
If iconSmall <> 0 Then DestroyIcon(iconSmall)
Return returnBitmap
Else
Return Nothing
End If

End Function
Apr 6 '06 #1
0 1657

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
10493
by: Mohammad-Reza | last post by:
Hi I want to extract icon of an exe file and want to know how. I look at the MSDN and find out that I can use ExtractIconEx() Windows API but in there are some changes to that api in c# I made...
3
17356
by: instruo | last post by:
I'm using the System.Drawing.Bitmap class for loading a 32-bit bmp file which includes an alpha channel. The problem is, when it gets loaded (just using the Bitmap(string filename) constructor),...
0
2551
by: morten skrubbeltrang | last post by:
According to KB article 822488 http://support.microsoft.com/default.aspx?scid=kb;en-us;822488 visual c# .net 2002 + 2003 has bug in rendering of alpha channel information when displaying a...
5
1905
by: yxq | last post by:
Hello The icons with the alpha channel are supported in WindowsXP. If use the System.Drawing.Bitmap.ToBitmap on the icon handle(ico.ToBitmap), the alpha channel won't be preserved, resulting in an...
16
7740
by: Dominique Vandensteen | last post by:
I want to get the icon from my application exe file dim myIcon as Icon = ... -> "myApplication.exe,0" how can I do that?
3
8033
by: Jo Franklin | last post by:
I am using icon.save to save icon files I've extracted using ExtractIconEx. when I save the large icon everything is fine, but when I save the small icon it looks distorted, and has a black (not...
1
2248
by: Vic.Dong | last post by:
Hello, all: How to draw a icon of alpha channel from CImagelist to listview control on Windows XP? B.R. VIC
1
968
by: Smokey Grindle | last post by:
Is there any quick way to apply a blue alpha mask over an image? Kind of like windows explorer does when you select an icon by painting the icon over with a blue layer. thanks!
14
12719
by: Ashutosh Bhawasinka | last post by:
Hi, How can I retrieve the system icon associated with a file/folder so that I can show it in the list view adjacent to the file/folder name? Regards, Ashutosh Bhawasinka
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7324
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7042
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7495
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3181
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1556
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.