hi.
i have the code for the graphics effects, but i can't implant. because i can see errors. use the teste project(that is in of my group project) for see the problems. tell me if you can enter in my group project.
thanks
Last edited by joaquim; Jul 12th, 2008 at 05:35 PM.
There are similar problems with teste.vbp and pjtSprite.vbp
I think you can fix this by going through the project and resaving all the different compontants, use SaveAs. Then check to see if that corrects all the pathnames.
hi.
you have right in everything. but i don't know do what is needed.
1-if i change the groupproject i don't have problems;
2-if i change the teste.vbp and pjtSprite.vbp and load the group project i recive errors;
3-i try "save group as" but continue with same path error.
can you help me more?
thanks
ok now i think that is resolved... i think that you can open it without a problems...
heres the group project updated....
now(tomorrow) i think that we can work... i'm so sorry and thanks
Last edited by joaquim; Jul 13th, 2008 at 04:39 PM.
Okay, so this version loads up with no problems...
Can you see the small window in the attached picture? Is it supposed to be there? This window is modal and won't close unless I use ctrl/break which in turn messes everything up. The only way to stop the project is via the taskmanager. Nothing in the main window can be clicked.
There seems to be a problem with the subclassing you are using, do you know an easy way to disable it?
yes is these window. for close these window i, always, use the close window button(teste form). i never use the close IDE button, is why you recive 1 error message in debug window.
for that messagebox appear, you use the joystick, right?
did you teste the graphics effects with every type images?
maybe that window is an error. in form code delete theses lines:
Code:
Private Sub Sprite1_Joystick(JoystickNumber As Long, JoystickDirection As pjtSprite.Direction, JoystickButton As Long)
If JoystickButton <> 0 Then MsgBox JoystickButton
If JoystickDirection <> DirectionNone Then MsgBox JoystickDirection
End Sub
i don't recive that messagebox. only if i use a joystick. but delete theses lines, maybe resolve the problem.
thanks
i found that window problem. in usercontrol there is 1 timer control tmrnewevents. here there is 2 sections(events): 1 for control move and other
for joystick. in joystick section is the error. if you want you can change these line:
Code:
If (blnJoystickActivate = True And StartJoystick(0) = True) Then
Yes that has solved the problem, the close button now works and the animations run. I don't have a joystick.
Here is a table showing whats working and whats not.
Code:
Source Mirror Rotate GreyS 50%Alpha
Gif Yes Yes* Yes No
Cursor No No No No
Bmp Strip No Yes* Yes No
Bmp No No Yes No
*The rotation degrades with the sprite/sheet and does not resize the image, so bits are cut off.
yes the rotate function don't resize the control.
now my problem is why the graphics effects(except the alpha, these one i don't know why it does these) works in some images and others no?
thanks
I'm finding lots of little problems and I'm not sure I have time to run through all this.
Whilst developing a program it's a good idea to disable any subclassing as it makes debugging hard. I suggest you disable it until you have resolved all the problems.
There is a problem with the animated cursor class, you should always destroy graphics objects when you have finished with them...
Code:
Private Declare Function DestroyCursor Lib "user32" (ByVal hCursor As Long) As Long
And you are creating 480x480 pixel pictureboxes, which is why it won't rotate properly.
When rotating images some information is lost, if you rotate an image several times the image will degrade. You should keep a copy of the original and rotate from that, it will improve the quality.
You can't use Alphablend like you are. When you use Alphablend it blends the source image with the background image which in this case is the maskcolour of the control.
I hate to say this, but I think your overall concept might be flawed. A usercontrol is a very heavy way to handle a sprite. I doubt that it will perform well with any more than a handful of sprites. A Sprite class (not control) that renders to a target hDC using either BitBlt or AlphaBlend should be able to handle several hundred animated sprites with no problems.
"I'm finding lots of little problems and I'm not sure I have time to run through all this."
if you don't have time, that's ok... thanks for help me...
"Whilst developing a program it's a good idea to disable any subclassing as it makes debugging hard. I suggest you disable it until you have resolved all the problems."
how i can disable a subclass? i honly do that(i think) when the sprite control is terminate or when is used a Destroy method.
"There is a problem with the animated cursor class, you should always destroy graphics objects when you have finished with them...
Code:
Private Declare Function DestroyCursor Lib "user32" (ByVal hCursor As Long) As Long
"
ok i just did that change...
Code:
Option Explicit
Private Declare Function LoadCursorFromFile Lib "user32" Alias _
"LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Private Declare Function DrawIconEx Lib "user32" (ByVal hdc As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long
Private Declare Function DestroyCursor Lib "user32" (ByVal hCursor As Long) As Long
Const DI_MASK = &H1
Const DI_IMAGE = &H2
Const DI_DEFAULTSIZE = &H8
Const DI_NORMAL = DI_MASK Or DI_IMAGE Or DI_DEFAULTSIZE
Public Function AnimatedCursor(AniFilePath As String, picDestany As Variant)
Dim lngNewCursor As Long
Dim result As Long
Dim i As Long
If picDestany.Count > 1 Then
For i = 1 To picDestany.Count - 1
Unload picDestany(i)
Next i
End If
picDestany(0).Cls
i = 0
lngNewCursor = LoadCursorFromFile(AniFilePath)
Do
If i > 0 Then Load picDestany(i)
result = DrawIconEx(picDestany(i).hdc, 0, 0, lngNewCursor, 32, 32, i, 0, DI_NORMAL)
picDestany(i).Width = 32 * Screen.TwipsPerPixelX
picDestany(i).Height = 32 * Screen.TwipsPerPixelY
If UCase(AniFilePath) Like "*.CUR" Then Exit Do
i = i + 1
Loop Until result = 0
Unload picDestany(i - 1)
DestroyCursor lngNewCursor
End Function
"And you are creating 480x480 pixel pictureboxes, which is why it won't rotate properly." i don't hunderstand what you said...
"When rotating images some information is lost, if you rotate an image several times the image will degrade. You should keep a copy of the original and rotate from that, it will improve the quality." thanks for the information.
i was thinking put 1 method for restore the image(s).
"You can't use Alphablend like you are. When you use Alphablend it blends the source image with the background image which in this case is the maskcolour of the control." why?
"I hate to say this, but I think your overall concept might be flawed. A usercontrol is a very heavy way to handle a sprite. I doubt that it will perform well with any more than a handful of sprites. A Sprite class (not control) that renders to a target hDC using either BitBlt or AlphaBlend should be able to handle several hundred animated sprites with no problems."
i'm using a picturebox array for put the images/subimages and the usercontrol for show it(with help of a timer, if theres is more than 1 subimage).
for AniGif and clsAnimatorCursor, did you think that is better a module(and maybe resolve that error, when we click in close IDE button)?
these is the error message when we click in close IDE button:"Object variable or With block variable not set"
thanks
The scalemode is already set to pixels so 32 * Screen.TwipsPerPixelX = 480
It also assumes the animated cursor is 32x32 pixels which I don't think is always the case. This should be in a module as you only need one instance of it.
Originally Posted by Joaquim
i'm using a picturebox array for put the images/subimages and the usercontrol for show it(with help of a timer, if theres is more than 1 subimage).
An array of pictureboxes is unnecessary and a waste of resources, an array of stdPictures would be less wasteful. Its still not a great way to show animations, direct rendering from a sprite sheet to the target device context is the most efficient way.
To use AlphaBlend properly you will need to pass it the hDC of the control that your sprite control lies in, otherwise it has nothing to blend it with. You would need to use AlphaBlend each time you wanted to render a frame. What you are trying to do simply won't work, it won't ever be transparent.
The scalemode is already set to pixels so 32 * Screen.TwipsPerPixelX = 480"
i did the changes.
"It also assumes the animated cursor is 32x32 pixels which I don't think is always the case."
but the problem is that i don't know how can i see the real size of image.
"This should be in a module as you only need one instance of it."
i change theses classs, animtor cursor and gif animator, for a module.
"An array of pictureboxes is unnecessary and a waste of resources, an array of stdPictures would be less wasteful. Its still not a great way to show animations, direct rendering from a sprite sheet to the target device context is the most efficient way."
for these i must use hdc's(i don't know use it), but i only can do these for animator cursors. because the gif animtor is different.
"To use AlphaBlend properly you will need to pass it the hDC of the control that your sprite control lies in, otherwise it has nothing to blend it with. You would need to use AlphaBlend each time you wanted to render a frame. What you are trying to do simply won't work, it won't ever be transparent."
if i hunderstand, i must do directly with usercontrol, right?
i'm sorry if i'm bored you with so many work... i'm sorry and thanks
Last edited by joaquim; Jul 13th, 2008 at 10:08 AM.
Option Explicit
Private Type tICONINFO
StructureSize As Long
IsIcon As Long
XHotspot As Long
YHotspot As Long
hBmpMask As Long
hBmpColour As Long
End Type
Private Type tBITMAP '24 bytes
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type
Private Declare Function LoadCursorFromFile Lib "user32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Private Declare Function DrawIconEx Lib "user32" (ByVal hdc As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long
Private Declare Function DestroyCursor Lib "user32" (ByVal hCursor As Long) As Long
Private Declare Function GetIconInfo Lib "user32" (ByVal hIcon As Long, Info As tICONINFO) As Long
Private Declare Function GetObjectA Lib "gdi32" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Const DI_MASK = &H1
Const DI_IMAGE = &H2
Const DI_DEFAULTSIZE = &H8
Const DI_NORMAL = DI_MASK Or DI_IMAGE Or DI_DEFAULTSIZE
Public Function AnimatedCursor(AniFilePath As String, picDestany As Variant)
Dim lngNewCursor As Long
Dim result As Long
Dim i As Long
Dim IconInfo As tICONINFO
Dim BmpInfo As tBITMAP
If picDestany.Count > 1 Then
For i = 1 To picDestany.Count - 1
Unload picDestany(i)
Next i
End If
picDestany(0).Cls
i = 0
lngNewCursor = LoadCursorFromFile(AniFilePath)
If lngNewCursor Then
GetIconInfo lngNewCursor, IconInfo
GetObjectA IconInfo.hBmpMask, 24, BmpInfo
Do
If i > 0 Then Load picDestany(i)
result = DrawIconEx(picDestany(i).hdc, 0, 0, lngNewCursor, BmpInfo.bmWidth, BmpInfo.bmHeight, i, 0, DI_NORMAL)
picDestany(i).Width = BmpInfo.bmWidth
picDestany(i).Height = BmpInfo.bmHeight
picDestany(i).Picture = picDestany(i).Image
If UCase(AniFilePath) Like "*.CUR" Then Exit Do
i = i + 1
Loop While result
DestroyCursor (lngNewCursor)
End If
Unload picDestany(i - 1)
End Function
thank you very much... thank you my friend... thanks...
why, when i rotate the image, the cursor and the normal image stay like transparent(some pixels desappear)?
yes after some changes i can do somethings with graphics effects.
thanks
heres the project updated...
i change the mousehover and mouseleave events. now it's great... for mousehover i use another timer control and 1 property for control the timer.
i enable the mousehover timer, mouseleave and mouseenter events with mousemove event.
thanks
Last edited by joaquim; Jul 24th, 2008 at 07:59 PM.