my apng image is like this (left image) :
https://www.imageupload.co.uk/images...ledProject.gif
i want when i resize my aic control horizontal so can see right image result.how can do that ?
Printable View
my apng image is like this (left image) :
https://www.imageupload.co.uk/images...ledProject.gif
i want when i resize my aic control horizontal so can see right image result.how can do that ?
The purpose of this thread is to provide code for download and maybe some clarification about its usage.
For more help/support, you should create a thread under Visual Basic 6 and Earlier forum, in order to avoid clutter in this one.
@Black_Storm. Remember that this tool is primarily for displaying images, not an image editor/composer. It isn't a mini-paint program. In addition, I already warned you that once you decided to modify my code for your purposes, my support would be limited, if at all.
Above being said, you have to understand APNG to even attempt to build it frame by frame, which would be needed in this case. It might be doable by filling in a MULTIIMAGESAVESTRUCT and passing that to SavePictureGDIplus. No guarantees.
hi, i want create a simple app like paint but i want use aic control and then i want these parameters :
1-can open a image size more than 7000 px in 7000px.
2-can zoom in or zoom out in it. (mouse wheel support)
3-can move in zoomed image like hand cursor
4-can draw rectange or star or another png image on my master image
5-can draw text on my master image with custom size or font or color
6-can undo or redo
7-and finally can save image edtied in another place.
can u have a simple source code aic used to can use in my project
and my question is about each numbers.
for example :
about 1: can use these sizes(more than 7000 px width or height in aic?) (can u send a sample code or source code to can use?)
about 2: how can zoom in or zoom out with aic?(can u send a sample code or source code to can use?)
about 3: how can move like hand cursor in aic zoomed?(can u send a sample code or source code to can use?)
about 4 : how can draw another aic image on my master aic image control?(can u send a sample code or source code to can use?)
about 5: how can draw text with customize color or font on my aic control?(can u send a sample code or source code to can use?)
about 7-how can merge all layers or images mereged in aic control?(can u send a sample code or source code to can use?)
hi, i tested this code on windows 7 and work good :
for run i should be use 2 aic control names ( aicFace and aicHour ) on form.
i used this code for blend 2 images and then save as png .
but same code not worked in windows 10 because of this part :Code:Dim tmpc As Integer
tmpc = 0
tmpc = Val(ucPic.Tag)
tmpc = tmpc - 1
Dim imgClockFace As GDIpImage
'
Set aicFace.Picture = LoadPictureGDIplus(App.Path & "\actions\temp" & tmpc & ".jpg", True)
aicFace.Left = 0
aicFace.Top = 0
aicFace.Width = aicFace.Picture.Width
aicFace.Height = aicFace.Picture.Height
'
'
Dim idx As Byte
idx = 0
If op(0).Value = True Then idx = 0
If op(1).Value = True Then idx = 1
If op(2).Value = True Then idx = 2
If op(3).Value = True Then idx = 3
'
Set aicHour.Picture = LoadPictureGDIplus(App.Path & "\tmpalamat\idx" & idx & ".png", True)
aicHour.Left = 0
aicHour.Top = 0
aicHour.Width = aicHour.Picture.Width
aicHour.Height = aicHour.Picture.Height
Dim pms As PICTUREMERGESTRUCT
If imgClockFace Is Nothing Then Set imgClockFace = aicFace.Picture
With pms
.CanvasHeight = aicFace.Height
.CanvasWidth = aicFace.Width
.Pictures = 2
ReDim .MIS(0 To 1)
Set .MIS(0).Picture = imgClockFace
.MIS(0).Width = pms.CanvasWidth
.MIS(0).Height = pms.CanvasHeight
Set .MIS(1).Picture = aicHour.Picture
.MIS(1).Left = X - (a(idx).Picture.Width \ 2)
.MIS(1).Top = Y - (a(idx).Picture.Height \ 2)
.MIS(1).Width = aicHour.Width
.MIS(1).Height = aicHour.Height
End With
Set aicFace.Picture = MergePictureGDIplus(pms)
SavePictureGDIplus aicFace.Picture, (App.Path & "\actions\temp" & Val(ucPic.Tag) & ".png"), lvicSaveAsPNG
when i changed lines to comment so program runed but without my result.Code:
With pms
.CanvasHeight = aicFace.Height
.CanvasWidth = aicFace.Width
.Pictures = 2
ReDim .MIS(0 To 1)
Set .MIS(0).Picture = imgClockFace
.MIS(0).Width = pms.CanvasWidth
.MIS(0).Height = pms.CanvasHeight
Set .MIS(1).Picture = aicHour.Picture
.MIS(1).Left = X - (a(idx).Picture.Width \ 2)
.MIS(1).Top = Y - (a(idx).Picture.Height \ 2)
.MIS(1).Width = aicHour.Width
.MIS(1).Height = aicHour.Height
End With
i want know why this source code work on win7 but not work on win10? and how can fix this code to can use in windows 10 too?
Can you be more specific as to what did not work? In the code you posted, are any of the values 0 or image references set to Nothing? You really didn't give me enough information to go on. Could be helpful to post the saved image from Win7 and the saved image in Win10.
Also, ensure your app has write permissions to: (App.Path & "\actions\temp" & Val(ucPic.Tag) & ".png")
Hi Lavolpe,
recently I started to have random crash with AIC as if Microsoft made a patch where the garbage collector make something where the parent container initialize after the init event... anyway,
m_HitTestPts is empty sometime when sptGetHitTest() is called and that result in subscript out of range on line:
If m_HitTestPts(pNew).X > m_HitTestPts(pOld).X Then
any idea how I could fix this ?
it happen only in IDE, but I have to reboot the IDE like hundred of time a day... very annoying. when it happen, any compiled OCX made with AIC crash with the error "there is no licence for this component"
plz help!
Can you reproduce the error on demand?
In the sptGetHitTest() routine, m_HitTestPts array should already be filled and is tested when the HitTest property is either lvicEntirelImage or lvicTrimmedImage, control is enabled (default), has a picture assigned, and mouse events are wanted (default). The sptGetHitTest() routine is called when mouse is over the control or releasing the mouse button during a click/drag event.
Each time the hit test should be recalculated, the m_RenderFlags is updated to include the bit: render_DoHitTest. This is triggered in a couple of events: Paint, changing the HitTest property, and WantMouseEvents property.
You can try adding this:
to the sptGetHitTest() routine, immediately after the statement: If UserControl.Enabled ThenCode:If (m_RenderFlags And render_DoHitTest) Then
If m_HitRegion = 0& Then Call sptCreateHitTestPoints(m_HitRegion)
End If
Theoretically, that could be a valid sanity check that may solve the problem. Just can't think of any combination you are using that could be causing the problem. Only thing that comes to mind is DoEvents possibly, maybe the UserControl_Hide() event not triggering (that releases the timer used to check for mouse over/leave events)
Hi Lavolpe, thanks for your answer.
I'm not using DoEvents (EVER) I consider it a "last" resort that has the potential to crash a program... for many reason you just mentionned.
I can reproduce the bug. it appeared on my dev machine recently (4 month ago) after a Microsoft Patch wich I can't retrace now. Oh... btw, stay FAR away from feb 13 2018 kb 4011686 (126mb) it's a Office 2016 Patch. if you install it, Vb IDE crash when you "open" an Access Database using ADO. Compiled EXE are sane though.
anyway, like I said about AIC, if I make "any" project with it, even an empty one and start the program (F5) in IDE, sometime it work, sometime it crash... normally, less then 5 attempt, make it crash. the time you spend between retry has no incidence, it's not a timing issue.
I'm about to reformat my machine soon to see if that fix the problem. only Vb6 IDE is affected. (safe for Office 2016 patch) ... strange... seem almost intentional ;)
Use a virtualbox with a fresh os.
just wanted to say thanks the control is awesome and helped me to understand alot
Hello, first of all I must say that the control is fantastic. I am very ignorant about programming and I am "very basic user". So I hope you will forgive me for my question: is it possible to copy the image loaded in a standard picturebox and modified with drawing commands (line, circle, ...) in an AIC ? If yes, which is the syntax I would use ? (I tried: Set AIC.picture = Picturebox1.picture but, of course, it does not work). I would like to avoid the need to save to disk the content of Picurebox1 and load again into AIC. Many thanks in advance for your reply
It's a very valuable material to study GDI+ and do photographic programming.
Have anyone converted to .NET?
Awesome control. We use it throughout our programs. Any update on the release of v3 of this control?
I'm not sure - lost a bit of interest. I have torn this thing down at least a dozen times and was never happy with the end result. With the ability to use thunks along with GDI+ to render directly into VB image controls. I'm not even sure something like this control is even worth the effort of maintaining, other than it's a convenience for those not fluent with GDI+.
I wouldn't hold my breath for an update since I have gone in different directions... but never say never.
Are there any examples of copying a part of the current form screen to this AIC control. I have tried several methods and they are not working. Using BitBlt to copy to a picture object and using LoadPictureGDIPlus to load it into the control. I get invalid picture object. The goal is that I then want to use the control to rotate the captured screen image section.
If you open the class: AICGlobals, and look at the samples in the method: LoadPictureGDIplus, you will see a really simple potential solution. You'll also want to set the Rotation, Aspect and other applicable properties of the control.
If you are interested in the code behind that call, then open the module and look at the bottom of the method pvProcessObjectSource for the line: ElseIf TypeOf Source Is Screen ThenCode:AlphaImgCtl1.Picture = LoadPictureGDIplus(Screen)
Note: The above will do the entire screen. Since you only need part of the screen, reviewing the code behind the call would be useful.
I love this control very much! I use it to drag pictures from Chrome to VB6.
It works great.
However, there is a situation where VB6 can hang.
Do you think you could have a look, please?
Could you please start Chrome and then search for an image?
In my case, I have searched for "schleudern".
Then I have dragged the image of the girl onto the LaVolpeAphaImg.
The first time you do this, nothing will happen. The image won't show up in the control, but it won't hang.
Now when you try it again, VB6 will hang.
I have taken a quick look what happens in the control, but I soon got into the complex parts of the code.
Do you think you could take a look?
Thank you so much!!
ps: I have a recorded a https://youtu.be/mZt5wp17WnY to show what I'm doing.
https://i.postimg.cc/021n5VRJ/schleudern.jpg
I just noticed that the control has got its final update.
Also, it works perfectly fine with Firefox, so I guess it's a problem with how Chrome handles this image dragging... it shows this "collection bar" where the user can drop the image.
So I do have a solution for this problem.
Unfortunately the same problem occurs with Firefox. So it's browser independent, but it seems to happen if the google collection bar appears.
Can Alpha Image Control be used to draw a 8bit transparency image in a transparent form? I'm failing to do it.
I can make the form transparent, but alpha image controls mix the backcolor of the form instead of transparency.
Attachment 171411
Version 3 is on my list of things to do. Not done yet and don't know when it will get done.
[QUOTE=LaVolpe;4073183]Regarding cropping: Well, you can already do that with existing methods:
Edited yet again. The above code works extremely well if Aspect is actual size; otherwise, it doesn't because resizing the control changes the dimensions of rendered image which means it isn't really designed to crop while stretched or scaled without a lot of extra calculations from you, including drawing in the PrePaint event (or saving the image to a new GDIpImage object with scaled dimensions ahead of time)Code:Option Explicit
' in this example, the control's parent scalemode is pixels
Private Sub AlphaImgCtl1_Click()
CropImage AlphaImgCtl1, 30, 30, 100, 100
End Sub
Private Sub CropImage(theImage As AlphaImgCtl, X As Long, Y As Long, _
Width As Long, Height As Long)
' the AlignCenter property should already be set to False for better runtime visual change
With theImage
.SetRedraw = False
.AlignCenter = False
.AutoSize = lvicNoAutoSize
' ensure X, Y are pixel scalemode
.SetOffsets -X, -Y
' ensure X, Y, Width, Height are appropriate container scalemode
.Move .Left + X, .Top + Y, Width, Height
.SetRedraw = True
End With
End Sub
*********************************************************
Hi Lavolpe I just now try this code for cropping function. It's work very well.
but I have an issue.
:CropImage AlphaImgCtl1, 30, 30, 100, 100:
Now I altered the values to this
CropImage AlphaImgCtl1, 0, 0, AlphaImgCtl1.Picture.Width , AlphaImgCtl1.Picture.Height
After result Image Crop height size is Ok but Image width size is crop to my desktop screen resolution width only.
Selected Image width size is 1800 pixels. After result it crop to my desktop screen resolution (1366) width only
Please help me how to crop an image actual width.
Thanks Advance.:wave:
Replied to your PM. Basically, there are some restrictions made within the code to prevent the AIC from being sized larger than a full screen. The restrictions can be found, and commented out, in sptGetScaledSizes
Dear LaVolpe.
A photo when opened in image editing programs is displayed correctly, however when loaded in Alpha Image Control it is automatically rotated counterclockwise.
Attachment 175171
Attachment 175173
The image is 3456x4608 72 dpi jpg photo from a smartphone.
Any guess about what is happening?
Thank you in advance!
Thank you very much shagratt!!!
I think there is a bug in the SetClipRect method:
'/// sets optional clipping on the rendered image. Border usage is exempt from clipping
Public Sub SetClipRect(ByVal X As Long, ByVal Y As Long, ByVal Width As Long, ByVal Height As Long, Optional ByVal Refresh As Boolean = True)
Attribute SetClipRect.VB_Description = "Method clips the control's graphic output"
' pass width and/or height as zero to remove clipping rectangle
If (Width Or Height) = 0 Then
SetRect m_ClipRect, 0&, 0&, 0&, 0&
If Refresh Then UserControl.Refresh
ElseIf (Width > 0& And Height > 0&) Then
SetRect m_ClipRect, X, Y, Width + X, Height + X
If Refresh Then UserControl.Refresh
End If
End Sub
It should be Height + Y instead of Height + X
@Zeilo. Yes, should be Hieght + Y
Regarding JPG. To address the camera orientation, the information should exist in the JPG's metadata and if it does exist, auto-orientation can be applied to correct it. Here's how to adapt the AIC for those types of JPGs.
1. In modCommon LoadImage function, find this line: Case lvicPicTypeJPEG
Immediately after that line, insert this: Call pvAutoOrientateJPG(cImageData)
2. At the bottom of modCommon, add the new pvAutoOrientateJPG method
3. Add this new API towards top of modCommonCode:Private Sub pvAutoOrientateJPG(cImageData As cGDIpMultiImage)
Dim lSize As Long, lValue As Long
Dim arrData() As Byte, lOrient As Long
Dim tImageData As cGDIpMultiImage, hBmp As Long
Const PropertyTagOrientation As Long = &H112&
GdipGetPropertyItemSize cImageData.Handle, PropertyTagOrientation, lSize
If lSize = 18& Then
ReDim arrData(0 To lSize - 1&)
If GdipGetPropertyItem(cImageData.Handle, PropertyTagOrientation, lSize, arrData(0)) = 0& Then
CopyMemory lSize, arrData(4), 4&
If lSize = 2& Then
CopyMemory lValue, arrData(8), 4&
If lValue = 3& Then
lOrient = arrData(16) Or arrData(17) * &H100&
Select Case lOrient
Case 2, 4: lOrient = lOrient + 2 ' RotateNoneFlipX, Rotate180FlipX
Case 6, 8: lOrient = lOrient - 5 ' Rotate90FlipNone, Rotate270FlipNone
Case 1, 3: lOrient = lOrient - 1 ' Rotate180FlipNone
Case 5, 7 ' Rotate90FlipX, Rotate270FlipX
Case Else: lOrient = 0& ' invalid value
End Select
End If
End If
End If
End If
If lOrient > 0& Then
GdipImageRotateFlip cImageData.Handle, lOrient
GdipCreateHBITMAPFromBitmap cImageData.Handle, hBmp, -1&
If hBmp <> 0 Then
Set tImageData = New cGDIpMultiImage
pvProcessGDIhandleSource tImageData, hBmp, False
Set cImageData = tImageData
End If
End If
End Sub
With the above changes, all JPGs will be tested for non-standard orientation and auto-corrected. If auto-correction is needed, then the JPG will be converted to a Bitmap and no longer be a JPG. If no auto-correction is needed, no action taken.Code:Private Declare Function GdipImageRotateFlip Lib "GdiPlus.dll" (ByVal pImage As Long, ByVal rfType As Long) As Long
Thank you very much LaVolpe!!!
Great job! Now is working perfectly!
Thank you very much LaVolpe!!!
Great job! Now is working perfectly!
i have new problem for open orginal source.when i want open source just see this error : expersion too complex how can fix that?
Search the code for "Not Not". I don't think I use that code in that project, but am not looking at the code right now. You may have that code in another part of your project somewhere. If so, post the question in the general questions portion of the forum. If you find it in the alpha image control, let me know. I can take a look tomorrow when I get home from work.
Ugh, I see you posted the question several times elsewhere. At least figure out which control is generating the error vs. sending this question to each person that wrote a control you are using, hoping one of them will do your debugging for you.
i find a way for fix this porblem but i think this is not good idea,i unchecked ax-tools code smart 2013 from add in manager and then restart vb and no problem now,i think this porblem is about IDE editor.
but i have a simple question now
i loaded a image from https like as this :
for example this image is 300*300 pixel,now i want save this picture to png format croped to 230*230.Code:Private myloader As AICGlobals
Set myloader = New AICGlobals
'img is alpha image control
Set img.Picture = myloader.LoadPictureGDIplus("https://.... url",,false)
this code workd for me for save just
but how can crop and save?Code:myloader.SavePictureGDIplus img.Picture, SavePath, lvicSaveAsPNG
Cropping? Start on page 7, post 245. Read that one and the next few. There are a couple options & sample code
i used your code :
Code:
With tmpimg
.SetRedraw = False
.AlignCenter = False
.AutoSize = lvicNoAutoSize
' ensure X, Y are pixel scalemode
.SetOffsets -0, -0
' ensure X, Y, Width, Height are appropriate container scalemode
.Move .Left + 0, .Top + 0, .Width - (70 * Screen.TwipsPerPixelX), .Height - (70 * Screen.TwipsPerPixelY)
.SetRedraw = True
End With
myloader.SavePictureGDIplus tmpimg.Picture, SavePath, lvicSaveAsPNG
i changed that line to :
but saved as orginal size alltimes,why?Code:.Move .Left + 0, .Top + 0, Width - 70, Height - 70)
'or
.Move .Left + 0, .Top + 0, 3000, 3000)
i want saved croped image for example from 300*300 orginal pixel to 230*230pixel as png
Try to better understand the control you are using. That code crops the image within the display, it is not editing the image, is it? If you would have did as I asked and read the next few after post #245, you would have seen an example of creating a cropped image that you can save.
i used wia like as this for crop png file (my problem fixed now) :
Code:
Dim img As New WIA.ImageFile
Dim IP As New WIA.ImageProcess
img.LoadFile orginalfilename
IP.Filters.Add IP.FilterInfos!Crop.FilterID
IP.Filters(1).Properties("Left") = 0
IP.Filters(1).Properties("Top") = 0
IP.Filters(1).Properties("Right") = 0
IP.Filters(1).Properties("Bottom") = 70
IP.Filters(1).Properties("FrameIndex") = 0
IP.Apply(img).FileData.ImageFile.SaveFile "path and png file name"
This is a real 32-bit transparent PNG control. It uses dozens of modules and class files. Is there a way to minimize the code?
but it's can zorder on button1,button2
it's only like StdPictureEx.cls
image1.picture=*.png
image2.picture=*.png
Great, amazing and wonderful control. Congratulation!!! :)
Just wondering to know if there is the possibility to change the rotation point.
Currently the rotation of the image pivots exactly in the center; I would be grateful to anybody who could give me an hint or maybe the solution.
Thanks :wave:
how can change this user control to standard exe,i want just use in my exe not like as ocx,i did try for change type to standard exe and so some user definition and public varibales is not worked and i did try for create standard exe and add this user control like as custom user control but same errors about changing classess and variables.
any body can attach standard exe version with this user control
You can try to load the OCX control without registration
Hi Lavolpe ,
How can I get a pixel color for a GIF animated image while it is playing frames ?
Lavolpe shipped a global helper class with the control . It is AICGlobals
It has many methods . One of them is : GetPixelGDIplus .
For animated pictures , use this code in the AnimationFrameChanged eventCode:Form1.BackColor= GetPixelGDIplus (AlphaImgCtl1.Picture , 5 ,5)
I don't know if I'm a layman or not, but I couldn't run the uncompiled project, could anyone help me?
Hi LaVolpe, I have a question. I've been trying to load a transparent PNG for hours, and there's no way to load it at runtime in VB6. How do I load a transparent PNG at runtime? It loads perfectly in design time, but not at runtime?
If you're up for it, I've looked at the whole issue and can't find a solution...
Greetings and sorry for the inconvenience...Attachment 194564
James,
LaVolpe is long gone. He officially gave us his sayonara a couple of years ago now, and hasn't been seen since. IIRC, he took a job that wasn't VB6 related at all, and threw himself into that.
There are several others around here who use this work, but you might do better to post a question about it in the regular Q&A section of these forums, rather than the CodeBank.
Good Luck.
It is a bit nonobvious...
Code:Private mImage As GDIpImage
...
Set mImage = LoadPictureGDIplus("C:\path\to\image.png")
Set AlphaImgCtl1.Picture = mImage
This is genius!!
Has anyone modified this for use as a .ctl?
The public UDTs make it quite a bit of work to change, just wondering if anyone has gone ahead and done it already.