Results 1 to 8 of 8

Thread: Bit Map Stuff

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2002
    Location
    Racine, WI
    Posts
    36

    Bit Map Stuff

    I'm developing a program that requires many bitmaps to be manipulated about a picture box with a bit map background(drawing area). I attempt to capture a bitmap in the drawing area as I know its coordinates via a mouse down event and "drag" it around via a mousemove event. As the bitmap is moved I redraw the background and other bitmaps present in he drawing area back to their current locations. It seems to "sort of" work, but I start getting weird stuff happening. It seems a bit resource intensive to redraw everything as the bitmap is dragged.
    I'm using Visual Basic with no DirectX. Can I do this In VB only or do I need all or some of DirectX? Thanks for any help.

  2. #2
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    No you don't need to use DX to pull it off...BTW don't redraw the whole screen all the time. Store the part of the bitmat that is behind what you are drawing, and then blt it to the "surface" again before next movement...

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2002
    Location
    Racine, WI
    Posts
    36
    That's sounds like an excellent solution, but would you happen to have an example?

  4. #4
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by Don Jahns
    That's sounds like an excellent solution, but would you happen to have an example?
    Sorry, I had one once, but I think I have deleted it because I never use a static background in my games, so that thing don't sped up my game anyway...But I will tell you if I find anything...

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2002
    Location
    Racine, WI
    Posts
    36
    Ok. Thanks for all of your help.

  6. #6
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    BTW look at this...

    VB Code:
    1. Dim rTemp as Rect
    2.  
    3. rTemp.Left = SpriteX
    4. rTemp.Top = SpriteY
    5. rTemp.Right = rTemp.Left + ddsdSprite.lWidth
    6. rTemp.Bottom = rTemp.Top + ddsdSprite.lHeight
    7. ddBackBuffer.BltFast SpriteX, SpriteY, ddBackground, rTemp, DDBLTFAST_WAIT


    This is a DX example...(I'm always using DX, so thats why my code is in DX... ...It makes a rect called rTemp. The code sets the left,RIght,Top,and bottom properties that the sprite had. Then in the last line it Blt the background to the "screen", but it is only Blting the part of the background that rTemp is telling it to....you will have to write the last line here in your code using the form of blitting you are using....I don't know how you have written your code, so I can't tell you more specific...

  7. #7

    Thread Starter
    Member
    Join Date
    Mar 2002
    Location
    Racine, WI
    Posts
    36
    Thanks again. I'll try that!

  8. #8

    Thread Starter
    Member
    Join Date
    Mar 2002
    Location
    Racine, WI
    Posts
    36
    Sorry to bother you again, but you've been very helpful. But how would that translate to VB bitblt as it calls for a source Hdc and dest HDC?
    Private Declare Function BitBlt Lib "gdi32" ( _
    ByVal hDestDC As Long, _
    ByVal X As Long, ByVal Y As Long, _
    ByVal nWidth As Long, ByVal nHeight As Long, _
    ByVal hSrcDC As Long, _
    ByVal xSrc As Long, ByVal ySrc As Long, _
    ByVal dwRop As Long _
    ) As Long

    My attempt:
    bitblt picboard.hdc,SpriteX,SpriteY,SpriteWidth,SpriteHeight,?.hdc,?,?...
    ---------
    Dim rTemp as Rect

    rTemp.Left = SpriteX
    rTemp.Top = SpriteY
    rTemp.Right = rTemp.Left + ddsdSprite.lWidth
    rTemp.Bottom = rTemp.Top + ddsdSprite.lHeight
    ddBackBuffer.BltFast SpriteX, SpriteY, ddBackground, rTemp, DDBLTFAST

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