Page 1 of 2 12 LastLast
Results 1 to 40 of 45

Thread: Rotating[Solved]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Posts
    127

    Rotating[Solved]

    I found a tutorial for rotating, and after only 2 weeks ( ) I understand almost all of it. Only problem is, there is this wierd thing going on that I just can't seem to figure out how to stop. The picture copys fine, but for some reason in the background of the pic there is some wierd stuff.. Anyone got any ideas?
    Attached Files Attached Files
    Last edited by bobthebobert; Feb 15th, 2004 at 08:51 PM.

  2. #2
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Is it meant to do anything?? I get a blank Black screen .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Posts
    127
    Argg, somehow I got my frm's saved in different folders as the rest of my program... This should be the right one now

  4. #4
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Nope, still the same. I made the change of the project File looking in a DIR but when the program runs it just shows a blank (black) screen with the mouse visible
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Posts
    127
    For the love of god -.- Try it again, think it should work now

  6. #6
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    wooohooo, works now. Give me a min to see whats causing that.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Posts
    127
    Another problem I am noticing, is that every other time I run the program, a little splice off the top right of the ship is missing, yet, sometimes it isn't missing...

  8. #8
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Another problem I'm noticeing is that even the pic that isn't rotated doesn't look like the Ship.bmp file. To sort this out I suggest using 32bit which fixes it slightly.

    For the main problem it looks like your reading the picture wrong, it looks like your reading from memory that the picture isn't in.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Posts
    127
    Yay, I fixed it! Except now, it cuts off portions of the picture, but I think I can fix that just by making the picutre I use have more empty space..
    Last edited by bobthebobert; Feb 15th, 2004 at 03:52 PM.

  10. #10
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    There is lot of code here on the forum that does this very fast. If you want to look at it just make a search. But you probably have to learn more to understand them, but thats not a bad thing is it...:P

  11. #11
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Originally posted by bobthebobert
    Yay, I fixed it! Except now, it cuts off portions of the picture, but I think I can fix that just by making the picutre I use have more empty space..
    Yeah you'll probably just need to make the rotated pic's surface slightley bigger. Mind I agree with NoteMe, I was going to suggest earlier that you can easily do rotation using Direct3D with DirectDraw.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  12. #12
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Yeah that too, but I ment GetPixel SetPixelV...like here....
    Attached Files Attached Files

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Posts
    127
    Hmm, for some odd reason changing the var "dblRMax" from a double to a long, made it now work perfect. Wierd. Except it still looks like crap when you rotate an image inbetween 90,180,270, and 0. Would using your method make it more accurate Note, because the code seems basically the same other then for the hdc stuff.

  14. #14
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Havn't looked at your code...but the code I posted works perfect, and it is fast...

  15. #15
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    When I did it before I started using Dx3D I had an if statement that said when the angle was 90, 180, 270 or 360 (0) it would not use the normal method and would do a kind of flip and mirror method which meant less processing and not a dodgy end result. The code that Note gave seems to work well but by the looks of it it doesn't seem to resize the destination to fit the whole rotated image in .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Posts
    127
    I think the problem is actually with my picture. I made it in mspaint, and it is quite small... To make it look better, should I make say a 1000x1000 image and then resize it down to 100x100 in my code?

  17. #17
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Wouldn't think that will make a differance.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  18. #18
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I reckon you should try using a 24bit bitmap tho.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  19. #19
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    No, a picture always looks best at the size it was created. Every resizing algorithms introduces problems, and only a lot of processing can reduce these problems, never eliminate them. Making things larger is more problematic, but making things smaller is hard enough.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  20. #20

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Posts
    127
    I was using 24 bit, but DX hates it =/

  21. #21
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Are you using DX?

  22. #22

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Posts
    127
    I am using DirectX 7. I have just about given up on having the image look right, maybe I should just make a picture easier to rotate.

  23. #23
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Why didn't you say so....waith a sec....

  24. #24
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    How about using the Direct3D way? Might mean learning how it all works if you've never used it before tho.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  25. #25
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Here.-...


    VB Code:
    1. Public Sub RotateSurface(ByRef surfSource As DirectDrawSurface7, surfDestination As DirectDrawSurface7, lngAngle As Long, XDest As Long, Ydest As Long)
    2.  
    3.   Dim ddsdOrigine As DDSURFACEDESC2, ddsdDestination As DDSURFACEDESC2
    4.   Dim iX As Long, iY As Long
    5.   Dim iXDest As Long, iYDest As Long
    6.   Dim rEmpty As RECT, rEmpty2 As RECT
    7.   Dim sngA As Single, SinA As Single, CosA As Single
    8.   Dim dblRMax As Long
    9.   Dim lngXO As Long, lngYO As Long
    10.   Dim lngColor As Long
    11.   Dim lWidth As Long, lHeight As Long
    12.  
    13.     sngA = lngAngle * PI / 180
    14.     SinA = Sin(sngA)
    15.     CosA = Cos(sngA)
    16.  
    17.     surfSource.GetSurfaceDesc ddsdOrigine
    18.     lWidth = ddsdOrigine.lWidth
    19.     lHeight = ddsdOrigine.lHeight
    20.     dblRMax = Sqr(lWidth ^ 2 + lHeight ^ 2)
    21.     surfSource.Lock rEmpty, ddsdOrigine, DDLOCK_WAIT, 0
    22.     surfDestination.GetSurfaceDesc ddsdDestination
    23.     surfDestination.Lock rEmpty2, ddsdDestination, DDLOCK_WAIT, 0
    24.  
    25.     XDest = XDest + lWidth / 2
    26.     Ydest = Ydest + lHeight / 2
    27.     For iX = -dblRMax To dblRMax
    28.         For iY = -dblRMax To dblRMax
    29.             lngXO = lWidth / 2 - (iX * CosA + iY * SinA)
    30.             lngYO = lHeight / 2 - (iX * SinA - iY * CosA)
    31.             If lngXO >= 0 Then
    32.                 If lngYO >= 0 Then
    33.                     If lngXO < lWidth Then
    34.                         If lngYO < lHeight Then
    35.                             lngColor = surfSource.GetLockedPixel(lngXO, lngYO)
    36.                             If lngColor <> 0 Then
    37.                                 surfDestination.SetLockedPixel XDest + iX, Ydest + iY, lngColor
    38.                             End If
    39.                         End If
    40.                     End If
    41.                 End If
    42.             End If
    43.         Next iY
    44.     Next iX
    45.     surfSource.Unlock rEmpty
    46.     surfDestination.Unlock rEmpty2
    47.     carwidth = lWidth / 2 - (iX * CosA + iY * SinA)
    48.     carheight = lHeight / 2 - (iX * SinA - iY * CosA)
    49.  
    50. End Sub

  26. #26

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Posts
    127
    Hehe, thats what I have The look doesn't mean that much anyway I guess, its good enough.

  27. #27
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by bobthebobert
    Hmm, for some odd reason changing the var "dblRMax" from a double to a long, made it now work perfect. Wierd. Except it still looks like crap when you rotate an image inbetween 90,180,270, and 0. Would using your method make it more accurate Note, because the code seems basically the same other then for the hdc stuff.

    So what was the thingy here then..no problem with this with this code....and I have never had any of the other problems you are talking about either...

  28. #28
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    BTW do you know that rotating in real time in DDraw is slow?? Much faster to do it at design time, and then use a sprite with all the images to Blt to the screen...

  29. #29

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Posts
    127
    Ya, gonna have an array of images, each rotated slightly different then the next.

  30. #30
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    So why did you bother to get this done then?

  31. #31
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    , but D3D.

    .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  32. #32
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I am always wondering if I see a person like CorcnedBee reads a thread like this for so long...what do he do. Does he laugh, do he teach him self something, did he just click the link and went for a walk....hmmmm


    and no. No D3D today Electro...

  33. #33
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Originally posted by NoteMe
    I am always wondering if I see a person like CorcnedBee reads a thread like this for so long...what do he do. Does he laugh, do he teach him self something, did he just click the link and went for a walk....hmmmm
    I think he's just putting a post in there to get the notifications, he hasn't found the "Subscribe to this Thread" link yet .


    Originally posted by NoteMe
    and no. No D3D today Electro...
    .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  34. #34
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Eh?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  35. #35
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by CornedBee
    Eh?

    What. You where looking at this thread for a long time...and I always wonder when you are looking in a VB thread like this....

  36. #36
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Was I looking at it for a long time? Do you mean, in one go or repeatedly for some time?

    I check out such threads once in a while to see if some theoretical question comes up where I can avoid VB while helping out, promoting C++ at the same time


    And in the meantime, I pity all ye people who use VB and know not better, and loathe al ye people who use VB and think there is no better.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  37. #37
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    You where looking in it for a long time....so I was just thinking loud. There is a lot of persons that are not that serious about programming. And I have no problems about them programming in VB. I have done it in 7 years my self...and I don't want to put all of that on the shelf. I still think that using the right tool for the job is the right thing to do....

  38. #38
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I gotta say I'm learning C++ and I'm finding it a lot more interesting, theres millions ways more of making things go wrong . I can see its better in a lot of ways but I too don't want to just thro VB away, its still useful for simple windowed apps.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  39. #39
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Yeah like map editors......but I have become much more aware of how I use variables, classes, functions, parameters and so on after I started C++, so I guess it has to be a good thing. Even ASM have thought me a great deal here...not to forget Java. Even if I don't like JAva...

  40. #40
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    hehe, all my lectures slag off Java so I'm not even going to bother. C++ is gonna be the lingo for me soon. I get to program on GameCubes sometime just after September and that'll be in C++ I'm told.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width