Seems that VFP8 will enlarge 16x16 .ico image files specified in the picture property of a command button if it's size is less than 32x32.
After extensive searching, I did find one other post on google indicating this behavior and can confirm that when you save a 16x16 .bmp image as a 16x16 .ico, it will be enlarged to a 32x32 pixel image in the command button. FYI - I'm setting the caption to (none).
The solution to get around this behavior is to resize the bmp image to 32x32, center the actual image you want within that area, then save it as an icon image.
I want to get away from using .bmp files since it's a pain to create and manage mask files (.msk), but right now I'm not sure exactly which is more work, dealing with .msk's or going through the gyrations needed to get around VFP's habit of enlarging .ico's
-- William Fields
You could try using other formats like GIF, JPG, PNG, etc. Starting with 8.0, VFP will respect transparency in those formats. -- Joel Leach
Not quite. If your videocard is in 32-bits color mode, the transparency appears white. I can't find any workaround for this but using a BMP+MSK or the trick below from MouradHammiche (see below) with a Disabled Picture property. -- Emmanuel Huybrechts
Gave it a go and came up with these results:
GIF - is limited to 256 colors, so we can't use WindowsXP style true color palettes (24bit+Alpha). And when I try to convert a WinXP icon to a 256 color icon, the colors get all wacky.
PNG - for some reason doesn't have the same transparency (in VFP) as when the image is saved as an ICO, but does support WindowsXP true color.
JPG - Well, my icon editor doesn't support saving ICO's as JPG.
Thanks, any other suggestions? Can someone verify if the icon enlarging bug is in VFP9?
-- William Fields
Transparency is supported in image control but not in Command Button. However, Visual Foxpro retain internally one instance of the image resource. we can use the behavior to display images with transparency in Command Button. First load the picture in image control, then use the image in the commandButton. The image does not have to be visible. I created a class to manage the image cache and it works perfectly. -- MouradHammiche
Do you load a picture object for each png?
Thanks, do you have VFP9 installed? If so, could you check to see if the problem is fixed? - William Fields
Not that perfect, if you disable the button, the picture doesn't change it's appearance, you have to use the Disabled Picture property. And it's not fixed in VFP9. -- Emmanuel Huybrechts
I found the following tidbit here:
Graphics Support in Visual FoxPro
(Can also be found in VFP Help, "Reference" - "File Structures" - "Graphics Support in Visual FoxPro" entry.
If Visual FoxPro does not recognize a particular version of a natively supported format such as a .bmp, .dib, .cur, .ani, or .ico, it passes them to GDI+ for rendering. Therefore, as new static file formats become supported in future versions of GDI+, Visual FoxPro can support them automatically.
Armed with this information, I changed the extension of my 16 pixel icons from .ico to .icon, and et voila they rendered at the proper size and with transparency intact. -- Alan Stevens
The trick of renaming the file will work, but then GDI+ takes over and out goes your transparent background, replaced with a white background. From the frying pan to the fire with this one. I prefer my backgrounds transparent even if they are all resized to 32x32. If I really wanted a different size I'd use a BMP anyway. -- Bernard Bout
( Topic last updated: 2007.11.07 11:25:59 PM )