Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
Originally Posted by LaVolpe
Start with the last few posts on previous page and post #562 on this page.
Got it, passed an hour reading your material and reference on MSDN. it raised some question... (see below)
Originally Posted by LaVolpe
If passing the handle worked but passing the picture object did not work, then what I described in my previous reply is the reason. Just FYI.
Forgive me, can you be more specific ? What cause the problem ?
Ok, here from component 2.1.32
Code:
If ipic.KeepOriginalFormat Then
ipic.SaveAsFile ByVal ObjPtr(IStream), False, lResult
If lResult = 0& Then ipic.SaveAsFile ByVal ObjPtr(IStream), bSaveMemCopy, lResult
Else
ipic.SaveAsFile ByVal ObjPtr(IStream), bSaveMemCopy, lResult
End If
Of, I'm not sure I understand something...
bSaveMemCopy is Declared as Boolean but never Initialized... (so it was false all the time) So Let replace all code but removing the unused bSaveMemCopy
We got this:
Code:
If ipic.KeepOriginalFormat Then
ipic.SaveAsFile ByVal ObjPtr(IStream), False, lResult
'old: If lResult = 0& Then ipic.SaveAsFile ByVal ObjPtr(IStream), bSaveMemCopy, lResult
'If lResult = 0& Then ipic.SaveAsFile ByVal ObjPtr(IStream), False, lResult
Else
'old: ipic.SaveAsFile ByVal ObjPtr(IStream), bSaveMemCopy, lResult 'Wich MEAN FALSE
'bug Fix 2.1.33 (not released yet)
ipic.SaveAsFile ByVal ObjPtr(IStream), True, lResult
End If
That work as Intended, bug fixed.. now my question is about the other part
Code:
If ipic.KeepOriginalFormat Then
ipic.SaveAsFile ByVal ObjPtr(IStream), False, lResult
'If lResult = 0& Then ipic.SaveAsFile ByVal ObjPtr(IStream), False, lResult
Else
Return Value: IPicture.SaveAsFile Return Value Link
E_FAIL = 0x80004005 'Unspecified failure
E_INVALIDARG = 0x80070057 'One or more arguments are not valid
S_OK = 0x00000000 'Operation successful
so, if lResult = 0 mean S_OK, why are we doing the same operation a second time ?
is there any benefit ?
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
Originally Posted by VbNetMatrix
so, if lResult = 0 mean S_OK, why are we doing the same operation a second time ?
is there any benefit ?
just wondering... I'm confused.
You're confused? So was I as to why it failed on occasion.
lResult is not the return value of ipic.SaveAsFile. It is the number of bytes copied to the stream (3rd parameter of the function). If zero bytes, then failure.
Reason why doing it twice was mentioned in the routine's comment I believe. Inconsistencies. However, I think part of the problem I was having, discovered couple years later, could be the parameter being passed. Is it boolean? Is it long? Is it something else? Per object explorer in VB (F2 key), it is "Boolean". But that may not be trustworthy. For example, ipic.Render states parameters as long, but if you pass long you get type mismatch unless you pass single.
As to why passing FALSE can work when passing a boolean variable doesn't work is likely due to imperfect documentation and/or my misunderstanding of the function.
Insomnia is just a byproduct of, "It can't be done"
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
Originally Posted by LaVolpe
lResult is not the return value of ipic.SaveAsFile. It is the number of bytes copied to the stream (3rd parameter of the function). If zero bytes, then failure.
Oups!! How could have I been so distracted! lool...
Originally Posted by LaVolpe
...could be the parameter being passed. Is it boolean? Is it long? Is it something else?
as per "non official" version 2.1.33 of mine, I have changed the parameter for LONG and I also have put something like:
if (lresult=0) then
msgbox "nope, wasn't that..."
end if
so if it glitch in any of my program in like next 6 month, I'll know, otherwise, I'll consider the matter fixed for good.
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
Originally Posted by DEXWERX
It's a typo in the original stdole2.tlb. How it doesn't crash every time boggles the mind.
OCIdl.idl uses BOOL (32bit) while stdole2.tlb uses VARIANT_BOOL (16bit)
Have you tried invoking SaveAsFile using DispCallFunc() instead?
DispCallFunc()?? didn't know... but the fix work now, so...
Got a couple of question though...
1. where can we get documentation about OCIdl.idl and stdole2.tlb for the matter at hand ??
2. I saw you did a vb6.tlb, what does it does and would it be possible to create a vb6.tlb to fix and replace stdole2.tlb ?
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
Originally Posted by VbNetMatrix
DispCallFunc()?? didn't know... but the fix work now, so...
Got a couple of question though...
1. where can we get documentation about OCIdl.idl and stdole2.tlb for the matter at hand ??
I always read the source, as MSDN documentation can be lacking and is often wrong.
stdole2.tlb can be decompiled to IDL using the OLE-Com Object viewer (which comes with Visual Studio)
OCIdl.idl comes with any of the Windows or Driver Development kits (or visual studio / visual c++)
Originally Posted by VbNetMatrix
2. I saw you did a vb6.tlb, what does it does and would it be possible to create a vb6.tlb to fix and replace stdole2.tlb ?
thanks
VB6.tlb's main use is to allow easier use of pointers, by aliasing some of the built in runtime functions.
like getting the safearray reference of an array, and read/write access to memory via pointer,
as well as r/w access to the pointers of VB's reference types (string/array/object).
It's also declares often used functions like CopyMemory.
It's possible to correctly VB-Ize the IPicture definition from OCIdl.idl and include it in a typelib like my VB6.lib
That's actually a great idea. I need to finish adding in Control Array interfaces anyway, might as well add a fixed IPicture.
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
hi i completed my game project but have2 problem with AIC
movie of result : here
1-i have a one sprite sheet png file and one alpha image control,my images is like this :
i want when mouse entered on normal state then "fade in" to over state and show over state image and stop and then when mouse down pressed on over state then fade in to down state and then start animation frame 1 to 100 play with custom duration speed for example (500 miliseconds)
matter is for me to make fade in simulation
i dont want make frames for simulate fade in
how can do that ?
and my question 2 : how can mirror face from left to right or from top to down without reverse frame? i hv a sprite sheet for walking but when i used mirror method AIC mirrored and frames reversed but i want just face mirror and dont want frame reveres too.
in my project i designer each left view animation of characher like as sperate because i cant use mirror or AIC(alpha image control).
Last edited by Black_Storm; Sep 26th, 2017 at 05:39 PM.
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
hi i wantt use AIC user control in another user control
i set backstyle of myusercontrol to transparent and then i used aic user control in my user control.
when i puted my user control on a test form background of my user control was been transparent but AIC was been white backcolor !!!
i have this problem with ImgEx or stdPicEx.
how can fix it? (i want use my user control with transaparent AIC or ImgEx or stdPicEx in same time on a form)
Last edited by Black_Storm; Dec 6th, 2017 at 05:57 PM.
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
I'll try to get back with you this weekend. My system just updated with latest Win10 update & things are not working right. Took me quite awhile to get VB up and running again (reinstalled it), but it's still not quite right. Only decision I have now is to try to figure out to fix what still needs fixing or rollback the Win10 update. Until then...
Insomnia is just a byproduct of, "It can't be done"
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
From your screenshot, I'd expect the bkg color to be gray not white. In any case, if you make your UC transaprent, then also set its Windowless property to true. Then transparency should be shown throughout. If that is not an acceptable solution, you can try compiling the AIC to a separate OCX and see if the issue continues. Or try different combinations of your usercontrol. Changing any combination in the AIC will fail to produce the desired effect.
Bottom line, the AIC gets its hDC, that it draw on, from VB. If VB gives it a solid fill background, that's what is drawn on.
Insomnia is just a byproduct of, "It can't be done"
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
i tested with windowless but now how can move my custorm usercontrol on form with mouse?
and can u answer to my old question?
how can mirror face from left to right or from top to down without reverse frame? i hv a sprite sheet for walking but when i used mirror method AIC mirrored and frames reversed but i want just face mirror and dont want frame reveres too.
in my project i designer each left view animation of characher like as sperate because i cant use mirror or AIC(alpha image control).
Last edited by Black_Storm; Dec 8th, 2017 at 04:18 PM.
The behavior you are seeing can be replicated with VB's Image Control too.
1. Create a new UC, set these properties: BackStyle=transparent, ClipBehavior=none, Windowless=true
2. Add a VB image control and place a transparent GIF on the UC. This is kinda like my AIC
3. Now, create another UC and place the first UC in it. Without setting this UC's BackStyle=transparent & Windowless=true, the GIF background is no longer transparent.
Insomnia is just a byproduct of, "It can't be done"
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
i write my problem on picture.
my porblem is with mirror animation.
i want mirror animation to horizontal or vertical and when mirrored,animation play from first frame to last frame(when i used aic mirror animation play from last to first frame).
i want just turn back my animation face to left or right or top to bottom without reverse frames too.
and if u can help me in this thread
any way to use nine patch picures(png) in vb6? can i use aic for nine patch too?how?
Last edited by Black_Storm; Dec 10th, 2017 at 04:11 PM.
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
i am use segment images, i sent picture used in #615 but i attachment here too.make a animation with this attachment for test and then check with horizontal mirror too.
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
Now I can better understand and found a logic flaw too
1. Open the class GDIpImage and find this routine SegmentImage
2. Change this line: newSEQ(0, lCount) = Val(sSeq(lCount)) - 1&
to this: newSEQ(0, lCount) = Val(sSeq(lCount - 1)) - 1&
3. Provide the new sequence manually... example:
Code:
With AlphaImgCtl1
.Animate2.PauseAnimation
.Mirror = lvicMirrorHorizontal
.Picture.SegmentImage 5, 2, , , "5,4,3,2,1,10,9,8,7,6"
.Animate2.ResumeAnimation
End With
Insomnia is just a byproduct of, "It can't be done"
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
i changed class GDIpImage and routine SegmentImage to :
Code:
newSEQ(0, lCount) = Val(sSeq(lCount - 1)) - 1&
and then i writed manual code :
Code:
With AlphaImgCtl1
.Animate2.PauseAnimation
.Mirror = lvicMirrorHorizontal
.Picture.SegmentImage 5, 2, , , "5,4,3,2,1,10,9,8,7,6"
.Animate2.ResumeAnimation
End With
and worked but if i hv been more than 10 sprites images and each image have been random frames for example more than 100 frames so i should be write code manual for each animation .
how can fix this problem to work always without this part :
Code:
With AlphaImgCtl1
.Animate2.PauseAnimation
.Mirror = lvicMirrorHorizontal
.Picture.SegmentImage 5, 2, , , "5,4,3,2,1,10,9,8,7,6"
.Animate2.ResumeAnimation
End With
my means is i want just set mirror to horizontal mirror in property page.
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
Originally Posted by Arnoutdv
You have to mirror the cells in the image, so don't mirror the complete image.
Another option. The SegmentImage function also can accept a byte arrray (if the class comments are read). Now, it's only a matter of sizing an array for 100 items and creating a short loop to populate the array. This, in my opinion, is minimal effort.
@BlackStorm. Suggest the method just described. I won't be modifying the class for this purpose. One of the beauties of this project is that is open source and nearly anything that one may want to add or alter can be done outside of the control. I really concentrated on trying to expose every possible thing to the coder via control/class properties and methods. The goal was not to have to make custom tweaks to the UC, simply call its methods/properties to change the control's behavior.
Insomnia is just a byproduct of, "It can't be done"
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
i simulated this model :
Code:
'example :
'when columns is 5 and rows is 2
'5 4 3 2 1 10 9 8 7 6
'example :
'when columns is 4 and rows is 3
'4 3 2 1 8 7 6 5 12 11 10 9
'example :
'when columns is 4 and rows is 2
'4 3 2 1 8 7 6 5
'example :
'when columns is 3 and rows is 4
' 3 2 1 6 5 4 9 8 7 12 11 10
and then i changed this part from SegmentImage rutin :
orginal code :
Code:
else
For lCount = 1& To TileCount
newSEQ(0, lCount) = lCount - 1&
newSEQ(1, lCount) = FrameDuration
Next
to :
Code:
Dim MySeq() As String, MyTempSeq() As String: ReDim MyTempSeq(TileCount)
Dim MyMasterSeq As String
Dim s As Long, cnt As Long, cnt2 As Long
Dim Lngi As Long, Lngi2 As Long
cnt = 0: cnt2 = 0: s = Columns
For Lngi = 1 To Rows
s = Lngi * Columns
cnt = s
For Lngi2 = s To (s - (Columns - 1)) Step -1
cnt2 = cnt2 + 1
MyTempSeq(cnt2) = cnt
cnt = cnt - 1
Next
Next
MyMasterSeq = Join(MyTempSeq, ",")
MyMasterSeq = Replace(MyMasterSeq, ",", "", 1, 1, vbBinaryCompare)
MySeq() = Split(CStr(MyMasterSeq), ",")
For lCount = 1& To TileCount
newSEQ(0, lCount) = Val(MySeq(lCount - 1)) - 1&
' newSEQ(0, lCount) = Val(sSeq(lCount)) - 1& ' ensure values in range of 1-TileCount
If Err Then ' internally, range is 0 to TileCount-1
Err.Clear
newSEQ(0, lCount) = 0&
ElseIf newSEQ(0, lCount) > TileCount - 1& Then
newSEQ(0, lCount) = TileCount - 1&
ElseIf newSEQ(0, lCount) < 0& Then
newSEQ(0, lCount) = 0&
End If
newSEQ(1, lCount) = FrameDuration
Next
and now i can set mirror with property page without any codes needed.is that correct?
Last edited by Black_Storm; Dec 12th, 2017 at 04:53 PM.
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
If it works for you, then it's correct. But one of my long-standing principles apply... you break it, you fix it; no more help from me. In other words, once someone modifies my code for their purposes, I don't offer advice on how to fix it if it fails.
Insomnia is just a byproduct of, "It can't be done"
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
Originally Posted by LaVolpe
If it works for you, then it's correct. But one of my long-standing principles apply... you break it, you fix it; no more help from me. In other words, once someone modifies my code for their purposes, I don't offer advice on how to fix it if it fails.
work for me but i want ask from you because i dont know other method means used in that class or any classes maybe used inthis class too.i want know any idea for any problem to maybe happen in feature.what problem maybe happen?
and apng not added to imgex or stdex yet?when time will be start?(i am waiting to apng support too)
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
Originally Posted by Black_Storm
work for me but i want ask from you because i dont know other method means used in that class or any classes
Yes, already mentioned it. Build your array outside the AIC, i.e., in your form, and pass the array. Don't customize a generic routine to no longer be generic.
Insomnia is just a byproduct of, "It can't be done"
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
Originally Posted by LaVolpe
My system just updated with latest Win10 update & things are not working right. Took me quite awhile to get VB up and running again (reinstalled it), but it's still not quite right.
Hi Lavolpe, hope you fixed your problem with last version of Win10. As for myself, I gave up on "Win10 & Vb6"
I installed Oracle VM and on my Win10 machine, I ran a VirtualBox of Win7 in full screen. work like a charm
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
hi,i have this png sprite picture and used in aic :
i changed AIC to segment type and then i want extract one of splited picture in to a image box with keep transparent? can i do that?
or can extract and then use imgex for show in image box? (image box is matter for me).
i dont want save as png on hard drive i need just use my image index selected from aic control (segmented images) and show direct to imagebox with transparency.
Last edited by Black_Storm; Dec 15th, 2017 at 05:52 AM.
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
VB's image control won't do transparency except for GIF, WMF, icons less than 32 bit.
You can extract the tile to another AIC using the SavePictureGDIp function with the optional SaveStruct parameter.
1. Set the image index to the tile you want
2. In the SaveStruct, set the ExtractCurrentFrameOnly member to true
3. Save the tile as a stand-alone image, probably as PNG if sending to ImageEx
Also, the AIC can display any tile in a segmented image simply by changing the .Picture.ImageIndex property
Insomnia is just a byproduct of, "It can't be done"
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
Hi Keith, I have just started to use your control.
I am showing Album Art to the user in a 200 x 200 AIC. If the file does not contain a picture in the metadata, I am downloading just 10 images and placing them in 10 36 x 36 AIC's for the user to choose.
I have already discovered by playing that the AIC's picture property always contains the original picture size and quality, no matter how small I have scaled it. This, I think, is great.
My question is do I really need 10 mini AIC's or is there some way I can display the 10 images in 1 AIC and the user select which one they want?
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
You can do that a couple of ways, here is maybe the easiest?
Use a picturebox sized 360x36, borderless if desired
As you load each image, you can paint it to the appropriate tile in the picture box. Simple math will tell you which tile the user clicked on. Use the Render method of the Picture property.
If that isn't good enough, you can actually create one 360x36 AIC but requires more effort. That process is basically the same principle and that can be done at least two ways. But I won't go into the details if the easier option suits your needs.
Edited: Since one of the options requires drawing into an AIC, I whipped up an example because I don't think I've provided one of those yet...
This is probably the next easiest method that allows you to keep the "combined" image in an AIC. Note in this example, I'm creating a horizontal strip of images. Obviously just a sample, and you'd need to adjust for any scaling you may want and/or creating a grid vs strip.
Code:
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
' don't need to initialize GDI+ for your form since the AIC already using it
Private Sub Command1_Click()
Dim tImg As GDIpImage, SS As SAVESTRUCT
Dim x As Long, y As Long, cx As Long, cy As Long
Dim hGraphics As Long
cx = AlphaImgCtl1.Picture.Width
cy = AlphaImgCtl1.Picture.Height
Set tImg = New GDIpImage ' create a new image 10x original width & same height
SS.Height = cy
SS.Width = cx * 10
SS.ColorDepth = lvicConvert_TrueColor32bpp_ARGB
' special purpose call to create a new image from nothing (documented)
SavePictureGDIplus Nothing, tImg, lvicSaveAsPNG, SS
' get GDI+ hDC-like pointer from the newly created image
GdipGetImageGraphicsContext tImg.Handle, hGraphics
' render each 'tile' to the strip
For x = 0 To tImg.Width - 1 Step cx
AlphaImgCtl1.Picture.Render 0&, x, y, cx, cy, , , , , , , hGraphics
Next
GdipDeleteGraphics hGraphics ' release that pointer
Set AlphaImgCtl2.Picture = tImg ' assign to a new/existing control & size the control
With AlphaImgCtl2
.Move .Left, .Top, Me.ScaleX(cx * 10, vbPixels, Me.ScaleMode), Me.ScaleY(cy, vbPixels, Me.ScaleMode)
End With
End Sub
Last edited by LaVolpe; Dec 16th, 2017 at 08:32 PM.
Insomnia is just a byproduct of, "It can't be done"
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
Originally Posted by VbNetMatrix
Thanks for this code... was waiting for it long time
Sorry if I didn't reply to a request -- may have just missed it. Hope the example helps.
Note: there are restrictions (bit depths & image format types) regarding usage of GdipGetImageGraphicsContext. Bottom line: suggest bitmap, png and 16bpp or better.
Insomnia is just a byproduct of, "It can't be done"
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
Originally Posted by LaVolpe
Sorry if I didn't reply to a request -- may have just missed it. Hope the example helps.
Note: there are restrictions (bit depths & image format types) regarding usage of GdipGetImageGraphicsContext. Bottom line: suggest bitmap, png and 16bpp or better.
Thanks Keith, very much appreciated...
as a side note, I work ONLY with BMP and PNG
(for image quality purpose)
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
hi,i hv two problem now.
1- i created new user control and then i used aic control in it too.i want create new property or new method for use some of functions or others to use it.
for exampe i created this sub :
Code:
private sub loadimage()
' i want use LoadPictureGDIplus from aic control
LoadPictureGDIplus (...)
end sub
my porblem is about functions called from aic control in my user control.
when i want write function name.vb can know it but when i type ( for example "LoadPictureGDIplus(" vb dont know this function with parameters.
and when i use LoadPictureGDIplus with parameters and when i want use my user control vb show error to me about LoadPictureGDIplus unknow function or ... .
how can fix it?
Last edited by Black_Storm; Dec 24th, 2017 at 11:52 PM.
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
hi,my problem in #636 not fixed yet and i am waiting to answers.
and i hv 2 problem now,can help me for fix it?
1- i writed my problem in my picture :
my problem is about when i want use aic control compiled(ocx of it) on vb.net form.
when i add and set image i can not see image in box on form.how can fix it?
2-i designed my user control and used aic control in it too.i set properties like picture and i compiled and worked in vb6 good but when i wanted test my ocx(my user control compiled) in vb.net i can see just background of aic control without any image(my user control is transparent but aic control is just opaque and dont show images too),how can fix it?
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
I can't answer your questions regarding vb.net
There is a lot of documentation on requiring VB user controls to be modified for .net. I think Microsoft event created some conversion/migration functions, but not sure. You may want to browse the .NET portion of the forums for answers regarding VB6 user controls. Key search terms: VB6 usercontrol migration
Insomnia is just a byproduct of, "It can't be done"
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
Originally Posted by LaVolpe
I can't answer your questions regarding vb.net
There is a lot of documentation on requiring VB user controls to be modified for .net. I think Microsoft event created some conversion/migration functions, but not sure. You may want to browse the .NET portion of the forums for answers regarding VB6 user controls. Key search terms: VB6 usercontrol migration
1-#636 not answered yet ( its about vb6) ( i can not call loadgdipplus or other functions when i used aic user control in my user control)
2-i created a user control in vb6 and properties seted to transparent backstyle and tested in vb.net and worked good so my problem is not about user control my question is about aic user control because when i want use aic user control in vb.net backcolor is opaque so problem is about aic.
3-i hv a question about how use UserDocument class , i want get percent ( 0 to 100 progress) of download and show percent in form too,i readed about UserDocument class and events in it like AsyncReadProgress(AsyncProp As AsyncProperty) and AsyncProp.BytesMax,AsyncProp.BytesRead.can u send a sample code for download more than 1 pictures as async and with percent downloading(0 to 100)?
Re: [vb6]Alpha Image Control v2 - Final Update (15 Jan 2012)
You should really start a new thread for your problems.
The problems you have are not bugs in the control, but have to do with how you want to use the control.
And if you are not satisfied with the control you should ask for a refund.