
Originally Posted by
Bigweld
... Anyway, Googling I found this code that actually do the effect that I looking for... BUT it is based on PictureBoxes and transparencies will not work
http://www.canalvisualbasic.net/foro...s-grados-2816/
I wondering if it can be modified by using some kind of custom PictureBox
Do you think that can be possible?
Actually conversion is extremely simple. The PlgBlt API used in that project is very similar to GDI+'s GdipDrawImagePointsRectI mentioned in my previous post.
Here's how to convert that project, using my image control
1. Add an AlphaImgCtl on the form
2. Search & replace everywhere, the following
... Find: Picture2.ScaleWidth Replace with: AlphaImgCtl1.Picture.Width
... Find: Picture2.ScaleHeight Replace with: AlphaImgCtl1.Picture.Height
... Find: Picture1.ScaleWidth Replace with: AlphaImgCtl1.Picture.Width
... Find: Picture1.ScaleHeight Replace with: AlphaImgCtl1.Picture.Height
3. Add this before exiting the DoRedraw routine: AlphaImgCtl1.Refresh.
Then within the DoReDraw routine, rem out or remove the following lines
Code:
Picture1.Cls
SetStretchBltMode Picture1.hdc, vbPaletteModeNone
Call PlgBlt(Picture1.hdc, PtList(0), Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, 0, 0, 0)
Picture1.Refresh
4. In Form_Load event, remove any code related to the pictureboxes. You can even remove the picboxes because they won't be used.
Also add following before the line "Call DoRedraw", within that event
Code:
AlphaImgCtl1.WantPrePostEvents = True
5. Add this code to the AlphaImgCtl1_PrePaint() event
Code:
Dim hGraphics As Long
If AlphaImgCtl1.Picture.Handle Then
GdipCreateFromHDC hDC, hGraphics
If hGraphics Then
GdipDrawImagePointsRectI hGraphics, AlphaImgCtl1.Picture.Handle, ByVal VarPtr(PtList(0)), 3&, 0&, 0&, _
AlphaImgCtl1.Picture.Width, AlphaImgCtl1.Picture.Height, 2&, 0&, 0&, 0&
GdipDeleteGraphics hGraphics
Cancel = True
End If
End If
6. Add the following API declarations to the form and then add an image to the AlphaImgCtl and play
Code:
Private Declare Function GdipDrawImagePointsRectI Lib "gdiplus" (ByVal graphics As Long, ByVal pImage As Long, ByRef pPoints As Any, ByVal Count As Long, ByVal srcX As Long, ByVal srcY As Long, ByVal srcWidth As Long, ByVal srcHeight As Long, ByVal srcUnit As Long, ByVal imageAttributes As Long, Optional ByVal pcallback As Long = 0&, Optional ByVal callbackData As Long = 0&) As Long
Private Declare Function GdipCreateFromHDC Lib "gdiplus" (ByVal hDC As Long, hGraphics As Long) As Long
Private Declare Function GdipDeleteGraphics Lib "GdiPlus.dll" (ByVal mGraphics As Long) As Long
What the above does is take advantage of the control's ability to allow you to draw the image vs. the control drawing the image. Let me know how things worked.
Edited: The line "AlphaImgCtl1.WantPrePostEvents = True" can be toggled true or false. Setting it to false prevents that event from being called. This way you can set it to true, automate the flip/rotation via a timer, then set it back to false after automation. Just thinking out loud.
Sorry if you saw this before I last updated. I forgot to give you the most important step: #5 above.