|
-
Oct 5th, 2011, 08:54 PM
#11
Re: [vb6]Alpha Image Control (PNG, AniGIFs, TIFF, & more) [5 Oct 2011]
Control updated today to fix a gradient anomaly, a bonehead mistake, and for enhancements...
- Added BkgImage property. BkgImage will paint over solid/gradient background (if applies) and under the control's Picture property
- Added BkgImageStretch property. BkgImage will be clipped in the control or stretched
- Added AsyncDownloadDoneBkgImg event to support async download of BkgImage
- Added SetFixedSizeAspect method to enable aspect of fixed-size during runtime
- Modified main property page to allow insertion of BkgImage
- Rewrote gradient routine to use GDI+ vs. msimg32.dll
- Bonehead mistake: last update somehow broke the PrePaint event (mistakenly deleted a line of code)
Example of layered backgrounds:
The following image has a gradient background and the new BkgImage property (semi-transparent bubble png) drawn over the gradients, then the actual control's Picture (my avatar) drawn over the BkgImage.

1. The BkgImage property is limited in how it is drawn. It is either drawn clipped by the control (if applicable) or stretched to the control's dimensions. Since the BkgImage property is a GDIpImage class, you have full access to it for other properties, like setting the ImageIndex and/or segmenting it if desired. If you desire a specifically, run-time, drawn image that is rendered with custom attributes/effects, sizes, etc, you'll want to create a new image and assign it to the BkgImage property; i.e., use SavePictureGDIplus, MergePictureGDIplus or maybe TilePictureGDIplus
2. The right-side image above was done using the PrePaint event. The PrePaint & PostPaint events will always give you far more control. Sample code looked like this:
- AlphaImgCtl1 had my avatar in it. WantPrePostEvents property is True
- AlphaImgCtl2 was hidden and had a 48x48 blue tile in it
- PrePaint & PostPaint events are runtime events only, so image not displayed as drawn while in design
Code:
Private Sub AlphaImgCtl1_PrePaint(hDC As Long, Left As Long, Top As Long, Width As Long, Height As Long, HitTestRgn As Long, Cancel As Boolean)
Dim xOffset As Long
If AlphaImgCtl1.Border Then xOffset = 1
TilePictureGDIplus AlphaImgCtl2.Picture, hDC, xOffset, xOffset, _
AlphaImgCtl1.ScaleWidth, AlphaImgCtl1.ScaleHeight, _
AlphaImgCtl2.Picture.Width, AlphaImgCtl2.Picture.Height
End Sub
Last edited by LaVolpe; Oct 5th, 2011 at 10:32 PM.
Tags for this Thread
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
|