NOTICE :: NOTICE :: NOTICE
Version 2 of the control came to an end. No new enhancements will be added to version 2. Bug fixes may be applied as they are discovered. Support for version 2 will eventually cease.
Version 3 of the control will replace version 2 and will be DPI-aware. This will result in how images are loaded and displayed on a PC based on DPI settings (XP and above). In the case of icons/cursors, it may also result in which sized icon is displayed, based on current DPI settings. Externally, how you use this control will not change very much. Internally, a logical coordinate space will be used for all measurements and storage of properties, unlike the physical coordinate space now used. Like VB, this control will use twips internally. Externally to control users, pixels will still be used. DPI awareness will also be a customizable property. To properly support DPI-awareness, binary compatibility will be broken; hence a new version.
15 Jan 2012. Minor patch applied. See change history below
Purpose: A control that allows viewing & creating many image formats, particularly alpha-blended ones.
This control is very similar in appearance and functionality to VB's Image Control. However, this control is super-sized. Requires GDI+ on the computer. Not a major issue nowadays. And GDI+ v1.0 can be redistributable if it doesn't exist. Advanced effects supported if system has GDI+ v1.1 installed (see posts #2 & 3 below).
Image formats supported: PNG (animated PNG too), TIFF (multi-page ones too), Icons, Cursors, Animated Cursors, JPEG, TGA, GIF (all frames), Bitmap, WMF, EMF, PCX, PBM, PGM, PPM, PAM, AVI, and those same formats contained inside MP3/WMA files, if they can be parsed out.
Image sources supported: Files (unicode supported), arrays, stdPicture object, Clipboard object, Screen object (snapshots), OLE Drag/Drop Data object, this control's .Picture property, VB's LoadResData/LoadResPicture functions, bitmap/icon handles and URLs to images (unicode & async requests supported). Also can extract images from binaries such as exe, dll and ocx files. Supports loading images from strings containing Base64 encoding. Control can now be data-bound to a database table/field.
See LoadPictureGDIp.rtf & SavePictureGDIp.rtf files included in zip.
For more advanced users: special Pre & Post painting events allow you to modify the control's content during its rendering process. This literally allows the control to act as a blank canvas. Don't respond to those events & image renders as usual. Respond and you can change the background before image is rendered & even prevent image from rendering; you can also modify the control after the image is rendered but before it is displayed. Two of the sample projects use those events to show how powerful they are.
Unlike VB's image control, a few global methods are designed to allow you to draw directly to any DC you desire. TilePictureGDIplus will tile a source image and can fill a form very quickly. PaintPictureGDIplus will draw an image to any DC. The control, itself, has a method to draw itself to another DC also: PaintControlAsDrawnToHDC. Additionally, there are methods that can be used for non-drawing: the UnicodeFileDialog class can be used from your project; giving you a unicode-aware common dialog substitute. The global ConvertRGBtoARGB & ConvertARGBtoRGB methods are useful conversion utilities that also accept VB system colors (i.e., vbButtonFace). The global GetScaledContainerSize & GetScaledImageSize methods are useful for scaling a container to image or vice versa. As long as the global GDIplusTokenExists method returns true, you never have to create your own GDI+ startup/shutdown routines; the GDIplusTokenVersion method lets you know which version of GDI+ is running
** Control performance is degraded while uncompiled. When compiled, you will experience far better performance
Recommend you open the AICGlobals class and read the detailed comments for usage of the main functions. You can get more information about the control's properties, methods and events by reading the code or using your Object Browser (F2).
See next post for a summary of the properties, methods, and classes this control exposes.
To add an image during design time, simply add a control to the form, right click on it, and select Properties.
You can also double click on the "Custom" property sheet item.
Look closely at the screenshot below.
See toucan's shadow over the playing card? See the grid dots in the shadows?
That's alpha-blending at work!!!
Following is history of most recent changes. The control itself has complete change history included
Any changes to the control may have spawned updates to 1 or more sample projects.
For the 8 sample projects provided...Code:15 Jan 2012, version 2.1.32: Final update barring bugs - UnicodeBrowseFolders class can now be created/called from within your projects - Property page could return 32 & 48 sized associated icons in PNG format & shouldn't. Fixed 8 Jan 2012, v2.1.31 - property page for dragged/pasted files now coded to have them relate to associated icons, as appropriate 7 Jan 2012, v2.1.30 - can load icons associated with file system objects - modified property page for associated icon selection - added ASSOCIATEDICON structure, SHILIconSizeEnum & AssocIconTypeEnum enumerations - added UnicodeBrowseFolders global class - updated LoadPictureGdip & SavePictureGDIp RTF files - fixes a logic error where control may not resize while it is hidden - fixes issue where app may create metafile of text copied to clipboard & control loads that metafile instead of using the text to load an image 26 Nov 2011, v2.1.29 - Error converting black/white icons/cursors when loaded by handle. Fixed 16 Nov v2.1.28 - Allows saving unmodified AVI to other destinations (i.e., file, array, etc) - Found & fixed several minor bugs -- cFunctionsICO.HICONtoArray custom header changes prevented loading icons by handle -- cFunctionsPNM.LoadPNMResource invalid flag setting could invert PBM formats -- cFunctionsPNM.pvBuildPNM saved invalid token when writing 32 bpp alpha PAM formats -- cFunctionsTGA.SaveAsTGA could save image upside down -- cFunctionsPCX.SaveAsPCX could save image upside down - Property page did not offer AVI as an image source 7 Nov v2.1.27 - test code from a few versions ago remained by mistake. Could crash project. Fixed 6 Nov v2.1.26 - error in MP3 tag parsing routine could occur with tags of less than 30 bytes. Fixed 3 Nov v2.1.25 - added WMA files as an image source - enabled control to be bound to a database table/field. See LoadPictureGDIp.RTF for more - added UpdateDataboundImage event to allow changing what will be saved before image written to database (databound control) - rewrote the MP3 parsing logic; more robust & should properly handle v2,3,4 ID3 tags + unsynchronized tags
1) Open the uncompiled alpha image project first (contained in the AlphaImgControl.zip file)
2) From the IDE menu: File | Add Project
3) Navigate to & select a sample project
4) Right click on it in the project explorer (treeview) & select: Set as Start Up
Now run the sample project. When done playing, remove the sample project, navigate to one of the others & run it.
Ensure you change the start-up project. You do not want the attached image control as the start-up project.
You will really like the "custom buttons" project. Shows how flexible this control really is.
Note: Sometimes I occasionally get an error when trying to load a sample project. This almost always happens after I've modified the uncompiled alpha image control. If that happens to you, simply close the sample project without saving changes, close the alpha image control project. Now try again.
1. Extract both zips, into same parent folder, using the "Use Folder Names" option
2. When recompiling this control over an existing, compiled, version always opt for Binary Compatibility from the project properties window, on the Component tab. See this thread for a bit more information on binary compatibility. Binary compatibility if used allows already compiled/distributed apps using the control to continue using a newer version when it is distributed. I will make every effort in future revisions to maintain binary compatibility.