|
-
Oct 13th, 2004, 04:02 PM
#1
Thread Starter
PowerPoster
code for working with .ico files?
This may be a toughy, but here goes.
Does anyone know how to read an .ico file and (1) identify the types of images it contains (i.e. "32X32 256 color", "16X16 256 color", "48X48 etc.") and (2) save off to a new file a file with only the image sizes I want (i.e. just 32x32, or just 32x32 and 16x16, etc.).
Now - really pushing it - does anyone know how to create a "gray-scale" image, given a color image (i.e. read in a normal color-icon, apply gray scale to it, and output the gray scale "disabled-looking" image)?
Any help would be appreciated.
"It's cold gin time again ..."
Check out my website here.
-
Oct 13th, 2004, 04:26 PM
#2
Looks like maybe the CopyImage API would be of some help.
VB Code:
Declare Function CopyImage Lib "user32" (ByVal handle As Long, ByVal imageType As Long, _
ByVal newWidth As Long, ByVal newHeight As Long, ByVal lFlags As Long) As Long
The CopyImage function creates a new image (icon, cursor, or
bitmap) and copies the attributes of the specified image to the
new one. If necessary, the function stretches the bits to fit the
desired size of the new image.
· hinst
Identifies an instance of the module that contains the image to be copied.
· uType
Specifies the type of image to be copied. This parameter can be one of the following values:
IMAGE_BITMAP
Copies a bitmap.
IMAGE_CURSOR
Copies a cursor.
IMAGE_ICON
Copies an icon.
· cxDesired
Specifies the desired width, in pixels, of the image.
· cyDesired
Specifies the desired height, in pixels, of the image.
· fuFlags
Specifies a combination of the following values:
LR_COPYDELETEORG
Deletes the original image after creating the copy.
LR_COPYRETURNORG
Creates an exact copy of the image, ignoring the cxDesired and cyDesired parameters.
LR_MONOCHROME
Creates a new monochrome image.
LR_COPYFROMRESOURCE
Tries to reload an icon or cursor resource from the original
resource file rather than simply copying the current image. This is
useful for creating a different-sized copy when the resource file
contains multiple sizes of the resource. Without this flag,
CopyImage stretches the original image to the new size. If this
flag is set, CopyImage uses the size in the resource file closest to
the desired size.
This will succeed only if hImage was loaded by LoadIcon or LoadCursor, or by LoadImage with the LR_SHARED flag.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 13th, 2004, 04:32 PM
#3
Also may be useful...
VB Code:
Declare Function ExtractIconEx Lib "shell32.dll" Alias "ExtractIconExA" _
(ByVal lpszFile As String, ByVal nIconIndex As Long, phiconLarge _
As Long, phiconSmall As Long, ByVal nIcons As Long) As Long
· lpszFile
Pointer to a null-terminated string specifying the name of an executable file, DLL, or icon file.
· nIconIndex
Specifies the index of the icon to retrieve. If this value is 0, the
function returns the handle of the first icon in the specified file. If
this value is -1 and phIconLargeand phiconSmall are both NULL,
the function returns the total number of icons in the specified file.
· phiconLarge
Pointer to an array of handles of large icons returned. This parameter can be NULL.
· phiconSmall
Pointer to an array of handles of small icons returned. This parameter can be NULL.
· nIcons
Specifies the count of the number of icons to extract.
Edit: This post puts me in the top 40!
Last edited by RobDog888; Oct 13th, 2004 at 04:36 PM.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 13th, 2004, 06:00 PM
#4
Thread Starter
PowerPoster
Thanks, Rob, I'll take a look at these.
"It's cold gin time again ..."
Check out my website here.
-
Oct 13th, 2004, 08:59 PM
#5
No prob. Let me know if it works for you.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 13th, 2004, 09:47 PM
#6
Hyperactive Member
If you're into writing your own algorithems and such:
http://www.wotsit.org/search.asp?page=2&s=windows
Disiance
-
Oct 14th, 2004, 12:08 AM
#7
Hey BruceG, there is a Icon Editor Control on www.vbaccelerator.com which does everything u want and with less efforts.
-
Oct 14th, 2004, 06:40 AM
#8
Thread Starter
PowerPoster
Wow - good tip, Deepak, thank you.
"It's cold gin time again ..."
Check out my website here.
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
|