Mr. lavolpe...
how to integrated ListView n LavolepeImageList???
Lavolpe ImageList
http://www.Planet-Source-Code.com/vb...69621&lngWId=1
please help me.... :confused::confused::confused:
Printable View
Mr. lavolpe...
how to integrated ListView n LavolepeImageList???
Lavolpe ImageList
http://www.Planet-Source-Code.com/vb...69621&lngWId=1
please help me.... :confused::confused::confused:
You cannot. That was mentioned in the comments/feedback section of that link. That control was designed for users of custom drawn controls (i.e., buttons, grid controls, image controls, etc) where the image is not assigned to a property, but drawn manually on the control. Hope that answers your question. I've stopped supporting all code on PSC when I left PSC. I won't be making any changes to that project nor re-creating it.
Updated 1 Jun 2011
- Added support for creating animated GIFs
- Added support for creating multi-image icons/cursors
- Added support for creating PNG-embedded icons/cursors (Vista and above can read these)
See the comments/examples in AICGlobals.SavePictureGDIplus class and also the SavePictureGDIp.rtf file
Thanks Lavolpe for the bug explanation,
I'm sorry I missed it in the forums I'll look more into it.
regards
Hi Folks,
I recently recieved a requiriment that should be addressed with rotated transparent text in different angles even with different font sizes and colors.
Does anyone has ideas on how to accomplish that?
I saw this code http://www.vbaccelerator.com/codelib...o/sidelogo.htm
but unfortunatly it seems that could not handle transparencies and font colors.
Thanks in advance
B.
Hi All,
Sorry. You are right. Is there any way to remove it from the current thread?
Thanks
B.
Don't worry about it. It'll serve as a reminder for others. I think I read somewhere that the 'privilege' of deleting your posts was tied to some magic number of overall posts one has made as a forum member. Anyway, here's the "how to" if you are enabled to.
Hi Lavolpe
I'm trying to present images using AlphaImgCtl controls dynamically generated.
The last dynamically created image should be presented at the top in the zOrder but I could not get it.
Regardless the ZOrder I set, the firt presented image remains at the top and the rest are presented behind it.
There is the code that I made:
a) This is the part that dynamically creates the set of images to be used. This set is not visible to the user while the program runs.
b) This is the part that uses the previous generated controls and then sets the image according the desired index when necessary.Code:Sub LoadDeck()
Dim f As Byte
Dim Lavolpe(51) As AlphaImgCtl
For f = 0 To 51
Set Lavolpe(f) = Controls.Add("LaVolpeAlphaImg.AlphaImgCtl", "Lavolpe" & CStr(f))
Lavolpe(f).Picture = LoadPictureGDIplus(CARD_BASE_PATH & CStr(f) & PNG_EXTENSION)
Next
End Sub
Would you like to take a look to it, please?Code:Sub ShowCard(OffsetMultiplier As Byte)
Static z As Byte
Dim a As AlphaImgCtl
Set a = Controls.Add("LaVolpeAlphaImg.AlphaImgCtl", "c" & CStr(z), Me)
With a
.Top = CARD_INITIAL_POSY - (POSY_CARD_OFFSET * OffsetMultiplier)
.Left = 527
.Width = 180
.Height = 270
Set .Picture = Lavolpe(m.CardID).Picture
.ZOrder z
.Enabled = True
.Visible = True
End With
z = z + 1
End Sub
Not sure if there is an issue of the AlphaImgCtl or mine
Thanks in advance
B.
PS: Its seems like the 'delete post' option is not avalible. I see just the 'edit post' option while trying to remove my previous post. Sorry.
You have to understand the ZOrder method. Your z variable is useless. The only two values allowed for the ZOrder method are: vbSendToBack or vbBringToFront.
Edited: Has nothing to do with the Alpha Image Control. The ZOrder method is one that all VB controls have, including usercontrols created with VB. The control itself does not process that, VB does for the control.
Thank you, for pointing me the error.
B.
FYI: Small enhancement added today... The Interpolation property.
By default the image quality is always highest possible. It will render with high-quality bicubic interpolation whenever the image is rotated or scaled to a different size than the original. There may be cases when a lower quality rendering is desired. Basically lower quality means faster renders, while higher qualities mean slower renders. Now you have that option to render at any of the other 5 quality settings offered.
A question came up recently how one can use rotation to animate a "knob" manually. Here's one idea.
1. Add an AlphaImgCtl to your form
2. Assign that control a nice picture of a knob or something circular
3. If the picture is not circular
-- change the control's .AutoSize property to lvicMultiAngle & control will resize itself
-- change the control's .AutoSize property to lvicNoAutoSize & adjust size as needed
-- set the control's .Rotation property to several settings at 45 degree intervals to ensure image is not cropped at those angles
-- if image is cropped at a certain angle, enlarge your control size a bit & repeat previous 2 steps
4. Paste this code in your form
5. Now run your form, hold mouse down on the control and start rotating it.Code:Private m_StartAngle As Single
Private Sub AlphaImgCtl1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
With AlphaImgCtl1
' want zero degrees due North, so passing an offset of -90
m_StartAngle = CalculateAngle(X - .ScaleWidth \ 2, Y - .ScaleHeight \ 2, -90)
End With
End If
End Sub
Private Sub AlphaImgCtl1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
' want zero degrees due North, so passing an offset of -90
X = CalculateAngle(X - AlphaImgCtl1.ScaleWidth \ 2, Y - AlphaImgCtl1.ScaleHeight \ 2, -90)
Y = (X - m_StartAngle)
If Y Then
AlphaImgCtl1.Rotation = AlphaImgCtl1.Rotation + Y
m_StartAngle = X
' perform whatever action the knob would do: change sound volume, rotate some other image, etc
End If
End If
End Sub
Private Function CalculateAngle(ByVal X As Single, ByVal Y As Single, _
Optional AngleOffset As Single, Optional AngleStep As Single = 1!) As Single
' returns a Degree vs Radian usable for properties that require angles in degrees vs. radians
' X & Y must be offset from a reference point
' -- the reference point is usually the center of whatever you want rotated
' -- So X may be: X - CenterPoint
' and Y may be: Y - CenterPoint
' AngleOffset is used to change what 0 degrees is relative to
' -- by default, 0 degrees is due West
' -- if you want due North to be 0 degrees, then pass AngleOffset as -90
' -- Why -90? If 0 is really due West then due North is 90 (clockwise rotation),
' so to make due North zero, we need to subtract 90
' AngleStep is used to restrict returned degrees to a fixed step value
' -- If you want the degrees to be returned in increments of 10, then pass 10
' -- If AngleStep is 10, then degrees < 10 will be returned as zero, < 20 returned as 10, etc
Dim Radian As Single
Dim xDiff As Single
Dim yDiff As Single
Dim Angle As Single
Const PI As Single = 3.14159265358979
xDiff = -X
yDiff = -Y
If Abs(xDiff) < 0.00000001 Then xDiff = 0!
If Abs(yDiff) < 0.00000001 Then yDiff = 0!
If xDiff <> 0! Then
Radian = Atn(yDiff / xDiff)
If xDiff < 0 Then Radian = Radian + PI
Else
If yDiff < 0 Then
Radian = 3! * PI / 2! '90
Else
Radian = PI / 2! '270
End If
End If
If Radian < 0! Then Radian = Radian + PI * 2!
Angle = Radian * (180! / PI) + AngleOffset
If Angle < 0! Then Angle = Angle + 360!
' restrict rotation to n degree increments
If AngleStep Then
CalculateAngle = Int((Angle \ AngleStep) * AngleStep)
Else
CalculateAngle = Angle
End If
End Function
Edited: Using above code, you will notice that sensitivity to changes is greater while mouse is closer to center of control and less sensitive the further away the mouse is from that center.
Edited yet again. For those that use the above logic, the assumption is that the image is rendered center of control. If image is rendered top left, adjust the center point in MouseDown & MouseMove
If you get an error saying .ScaleWidth & .ScaleHeight are not supported, you are using a previous version of the control.
Good algorithm (CalculateAngle) for rotation using 'knob' manually. But we can resize AIC & rotate pic at the same time with a bit of modification of CalculateAngle (using xDiff and center position of AIC to determine the zoom changes).
One annoying thing is GDI+ doesn't draw Anti-aliasing for two edges of a rotated pictures.
Another nice routine.
version 1.1 of GDI+ library has some niffty effects but not available to v1.0 of GDI+. One such effect is a blur. v1.1 has a true gaussian blur routine. If you want a blur routine for v1.0, the following may be useful. It is not a true blur but produces good results.
You'll need these 2 GDI+ API delcarations
1. On a new form, add 2 AlphaImgCtl controls and 1 command buttonCode:Private Declare Function GdipGetImageGraphicsContext Lib "gdiplus.dll" (ByVal pImage As Long, ByRef graphics As Long) As Long
Private Declare Function GdipDeleteGraphics Lib "gdiplus.dll" (ByVal mGraphics As Long) As Long
2. Add an image to AlphaImgCtl1
3. Make the AlphaImgCtl2 same size as AlphaImgCtl1
4. Copy & paste following code. Run project & click on the button. Play with different blur depths
Code:Private Sub Command1_Click()
' modified from this source: http://www.autohotkey.net/~tic/Gdip.ahk
Dim tImg As GDIpImage
Dim SS As SAVESTRUCT, hGraphics As Long
' create a new blank image same size as source image & place in 2nd image control
SS.ColorDepth = lvicConvert_TrueColor32bpp_pARGB
SS.Width = AlphaImgCtl1.Picture.Width
SS.Height = AlphaImgCtl1.Picture.Height
Set tImg = New GDIpImage
SavePictureGDIplus Nothing, tImg, , SS
Set AlphaImgCtl2.Picture = tImg
' create new temp blank image a fraction size of source image
' change the percentage to smaller values for greater effect & higher for lesser effect
SS.Width = AlphaImgCtl1.Picture.Width * 0.33
SS.Height = AlphaImgCtl1.Picture.Height * 0.33
If SS.Width = 0 Or SS.Height = 0 Then
MsgBox "Blur depth is too great"
Exit Sub
End If
Set tImg = New GDIpImage
SavePictureGDIplus Nothing, tImg, , SS
' render the source image onto temp image at fraction of size
GdipGetImageGraphicsContext tImg.Handle, hGraphics ' function only works for 24bpp & above
AlphaImgCtl1.Picture.Render 0&, , , SS.Width, SS.Height, , , , , , , hGraphics, , lvicHighQualityBicubic
GdipDeleteGraphics hGraphics
' render temp image to full size and update 2nd control
GdipGetImageGraphicsContext AlphaImgCtl2.Picture.Handle, hGraphics
tImg.Render 0&, , , AlphaImgCtl1.Picture.Width, AlphaImgCtl1.Picture.Height, , , , , , , hGraphics, , lvicHighQualityBicubic
GdipDeleteGraphics hGraphics
AlphaImgCtl2.Refresh
Set tImg = Nothing
End Sub
FYI. Updated version posted today.
- Fixed couple minor errors in ICO & GIF creation routines
- Added ability to load image from Base64 encoded string
- Added AlphaMask & RenderSkewed functions to GDIpImage class (see class comments)
- Updated couple sample projects using newly added functions (see Change History on post #1)
WOW lavolpe
Good day
Very good and interesting your project, excuse my question, is there any way to remove the rest of the form and only leave the control and also encourage you, thank you for your answer
astronald, welcome to the forums.
The zip file containing the control. Unzip it to a folder and open the .vbp file. Compile it. It will become a stand-alone OCX that you can add to your toolbox whenever you want. Should I update the control and you re-download, be sure to compile future revisions with binary compatibility. There is a link in post #1 I point people to, to better understand binary compatibility if this is a new topic to you.
The zip file containing the sample projects are there just for educational purposes. They have no bearing on the actual control.
:):):)
Thanks Lavolpe, I liked the clock project would be done without you see the gray background of the form, thanks again for your help.
:wave::wave:
I have a memory leak in my project which is loading and unloading alpha image controls in a control array. It seems as though every time I add another object to the array it will add two gdi objects however when I unload an object either one or no gdi objects will go away. I’ve attached a simple project which shows the problem.
Edited: For others reading this post. If you read my "Memory Leak FAQ", linked in my signature below, you'll know what we are talking about, regarding GDI counts.
I can't reproduce the problem. Well, I can sort of
1. My baseline GDI count is 513 let's say. That's the count before running the project
2. I run the project (ensuring no other VB MDI child widows open). Count = 525
3. I add 5 new controls & count rises to 534
4. I then remove those 5 controls & count drops to 529
It does appear 1 leak per object. But it isn't & here's why:
5. Close form normally. Count now reads: 513
When VB loads DLLs/OCXs. It doesn't exactly clean up memory right away when the instance of it is removed. I can't tell you the intricacies of how VB's garbage collection works because I don't know. However, the fact that the GDI count did not change from starting the project to ending the project, indicates no leaks. Agreed?
Thanks. I can see what you're saying. Great control.
You're welcome & thanks for the compliment.
FYI: Using your sample code, you can reduce memory usage. Add this before making your control visible
When you dynamically load a control that already contains a picture, that picture's data & GDI+ objects are replicated not shared. You can verify this by printing out the object(object.UBound).Picture.Handle property. Using the above tweak, all is shared. However, in post #3 back on page #1, read the gotchas about sharing multi-image formatsCode:Set object(object.UBound).Picture = object(object.LBound).Picture
Hello
I've been using LaVolpeAlphaImg.
To become a better control
I hope the following features are added.
1. picturebox, grid control with the features that happens when you come to a top layer
2. Png in the form to apply full-screen window (like the splash window)
Pay as you think, if this feature has to pay.
Have a nice day.
There is one other thing that i've been trying to do. Is there a way to have vb compile the alpha image control pictures without putting them in a resource file? I tried running my program on another computer and got an error that said "Component 'LaVolpeAlphaImg3.ocx' or one of its dependancies not correctly registered: A file is missing or invalid."
#1. Have no idea what you are suggesting. Are you asking for a picturebox control version of the Alpha Image Control? If so, won't happen. This control cannot be made to be a container of other controls, especially windowed controls.
#2. Not sure what you meant there either. If you want the control & image to size to the form, simply change the control's dimensions in the form's resize event. Also set the Aspect & AlignCenter properties for the stretching/alignment of the contained image, as desired.
The pictures assigned to a control during design time are stored in the hosting form's .frx file & compiled within your app when app is compiled. That isn't the reason for your error. You can't just copy the ocx to another pc and expect it to work, the ocx needs to be registered on that other pc. Suggest creating a proper install setup.exe for your application
Okay, I'll need to learn how to do that. Sorry to bother you.
Thanks Lavolpe, I liked the clock project.
would be without you see the gray background of the form, thanks again for your help.
If you are asking how to make something like a clock widget that would show up on the desktop and without a form's background showing thru, that is a project all in itself. I'll give you these hints. But for assistance you should post your questions in the graphics or VB6 portion of the forums, not here in the codebank or in this thread. This is all the help I'll provide since your question isn't related to how my project works.
1. Use SetLayeredWindowAttributes & UpdateLayeredWindow APIs to draw your clock on a transparent form. The form should be made an owned window to the desktop if clock is to appear on the desktop
2. This usercontrol cannot be used as is because of how UpdateLayeredWindow works. But you can still draw the clock parts to the form every second (if second hand is displayed) or every minute if no second hand used. The usercontrol's PaintImageAsDrawnToHDC function would be helpful here or accessing the Picture property's .Render function directly.
Search the forums for examples of the 2 APIs I mentioned. Good luck.
Hi. I use the control, but found some problem.
please see the attachment.
I read the contact.jpg use GDIpImage.
But I get the different color value in point (x,y) = (0,64) form photoshop or paint.
use GDIpImage, I get
'Red:255;Green:255;Blue:251;Alpha:255
when use photoshop or paint or other soft ,I get
'Red:255;Green:255;Blue:255;Alpha:255
Plese help me see what's wrong?
Thanks!
Hi, LaVolpe,
I found the problem.
It's my mistake, (x, y) should be (y, x).
now, the value is the same with other software.
Thanks!
Updated control. See 1st post
- Can now create animated PNG
- Prevented control from trying to process 64bit binaries for images
- GDIpImage.AnimationLoops property returns animated PNG loop count
- New control method Animate2 is class-based version of older Animate method
- Added ability to do a screen capture to 24bpp bitmap
Edited: To test animated PNGs without using my control, use FireFox to open the animated PNG file
Hi.
When AlphaImgCtl1.WantPrePostEvents = True, then AlphaImgCtl can't resize correct.
//////////////////////////////////////////////////////////////
Option Explicit
Private Sub Form_Load()
AlphaImgCtl1.WantPrePostEvents = True
End Sub
Private Sub Form_Resize()
AlphaImgCtl1.Move Me.ScaleLeft, Me.ScaleTop, Me.ScaleWidth, Me.ScaleHeight
End Sub
///////////////////////////////////////////////////////////////
Above code can't run correct, if AlphaImgCtl1.WantPrePostEvents = false then it is correct.
Please see the attachment!
Thanks!
Thanx for the bug report. An undiscovered bug that's persisted through last several versions.
I think I know what is happening and will look into it. In the mean time, setting WantPrePostEvents in the property sheet instead of form_load will have expected results
Update: Figured out the problem... logic error. I never coded for scenario where WantPrePostEvents without an image assigned to the control - not enough foresight there. Requires tweaks in 2 routines & will upload patch by Aug 17th after a bit more testing
Hi
SaveControlAsDrawnToGDIpImage
e.g
///////////////////////////////
Set AlphaImgCtl2.Picture = AlphaImgCtl1.SaveControlAsDrawnToGDIpImage(True)
//////////////////////////////
Above Code is invalid.
And SaveImageAsDrawnToGDIpImage may have the same problem.
Thanks!
Can you be more specific? What's invalid about it? If the following resolves the issue, please let me know also
If AlphaImgCtl2 isn't showing the complete image, try this:
Also note that AlphaImgCtl1 must be visibleCode:AlphaImgCtl2.AutoSize = lvicSingleAngle
Set AlphaImgCtl2.Picture = AlphaImgCtl1.SaveControlAsDrawnToGDIpImage(True)
Edited: If there is no image assigned to the usercontrol, there is a check for that to abort the routine. I can see where this may not be desirable. I'll include that modification also. Simply remove the following line from the usercontrol's SaveControlAsDrawnToGDIpImage function:
If m_Image.Handle = 0& Then Exit Function
The same scenario for SaveImageAsDrawnToGDIpImage does not apply. That function relates to the loaded image only, not any background graphics. Therefore if no image loaded, SaveImageAsDrawnToGDIpImage will abort
Hi.
Please see the attachment, the copy button has no effect.
Thanks!
Now I understand. Thanx for the example. Need to think this over a bit.
AlphaImgCtl1 is user-drawn in that example. The PrePaint event draws the image itself then tells the control to not draw its copy. So, that does explain why no graphics were returned to AlphaImgCtl2 since AlphaImgCtl1 was told not to draw the image
I'll be considering this. The following scenarios are possible along with what I consider commonsense responses
I. If WantPrePostEvents is True then graphics may or may not be user-drawn
a. If the control is told to abort painting by passing the PrePaint event's Cancel parameter as True
-- SaveControlAsDrawnToGDIpImage has no choice but to return the graphics as drawn by the user since the control will not be drawing the image. This will include any background fill/graphics since the user dictates everything
b. If the control is NOT told to abort painting then
-- SaveControlAsDrawnToGDIpImage should function as intended
II. If WantPrePostEvents is False then no user-drawn graphics to worry about
-- SaveControlAsDrawnToGDIpImage should function as intended
III. The SaveImageAsDrawnToGDIpImage function is not affected. It uses the control's image and any image properties (i.e., rotation, grayscaling, etc)