Results 1 to 10 of 10

Thread: Working with DC's

  1. #1

    Thread Starter
    Addicted Member DarkMoose's Avatar
    Join Date
    Jul 2000
    Location
    in a box
    Posts
    185
    I am having trouble with storing graphics. I created a new DC and BitBlted my tileset on it. Now I need to copy the tiles from there and paste them right below the tileset to make the actual map of the current area. All of the code is working except the part that BitBlts the tiles from the set to the map. I wanna do this all on the same DC but it doesn't work... What am I doing wroooong ohh someone TELL MEEEE I'M GOING INSANE!!!!!!!! ...er..sorry. :)
    To understand recursion, one must first understand the concept of recursion.

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    YOu shouldn't have the map area and the tileset on the same DC, but if you just pasted your code here then we could understand what's not working?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Addicted Member DarkMoose's Avatar
    Join Date
    Jul 2000
    Location
    in a box
    Posts
    185
    Why can't I use the same DC for map and tiles? I thought the whole idea of VB is to save space... :| Anywayz, let's forget about what DC I save it on for now. I just need to know how to BitBlt something to a DC. The way i got the tileset there was with this:

    Code:
    MyDC = CreateCompatibleDC(Form1.hdc)
    TilePic = SelectObject(MyDC, LoadPicture(AppPath & TileSet & ".gif"))
    BitBlt MyDC, 0, 0, 493, 493, TilePic, 0, 0, vbSrcCopy
    This works ok. The tileset goes into the DC and is stored there. Now, I need to copy individual tiles from there and BitBlt them elsewhere to build the map. I currently have the code inside 2 for loops and it is like this:

    Code:
    BitBlt MyDC, ReadTilesX * 46, ReadTilesY * 46 + 493, 46, 46, MyDC, TileArray(ReadTilesX, ReadTilesY).TileSrcX, TileArray(ReadTilesX, ReadTilesY).TileSrcY, vbSrcCopy
    So all that does is copy a tile from the DC and BitBlts it elsewhere, on the same DC. Well, I WANT it to do that anyway... I think I'm missing something here...do I need to use that select object thing again? Or is it because i'm blting to the same DC!? Someone tell me what iz wrong!!
    To understand recursion, one must first understand the concept of recursion.

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    It may ofcourse be that you blt out of the contents of the bitmap, and that will automatically fall off without any errors. Now why don't you try to blit it to another DC that surely is empty and has the size you need to make a map? Use createcompatiblebitmap and you'll have another bitmap.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    Addicted Member DarkMoose's Avatar
    Join Date
    Jul 2000
    Location
    in a box
    Posts
    185
    Ok It still doesn't work but I'm not really sure if I'm doing it right. I tried this:

    Code:
    MapBitmap = CreateCompatibleBitmap(Form1.hdc,MapWidth,MapHeight)
    Then I just substituted MyDC with MapBitmap in that piece of code in my last reply. Please tell me i'm doing something wrong here.
    To understand recursion, one must first understand the concept of recursion.

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    did you use selectobject with thatone on the new DC?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7

    Thread Starter
    Addicted Member DarkMoose's Avatar
    Join Date
    Jul 2000
    Location
    in a box
    Posts
    185
    Ahh, I thought it might be because of that. I'm not really sure how or when to use SelectObject. can you quickly explain it and how i can use it in my situatioN?
    To understand recursion, one must first understand the concept of recursion.

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
        ahdc = CreateCompatibleDC(Form1.hdc)
        SelectObject ahdc, MapBitmap
        BitBlt hdc, 0, 0, MapWidth, MapHeight, ahdc, 0, 0, vbSrcCopy
    Now you just use Selectobject the way you did before, attach the mapbitmap into your new dc, here called ahdc
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9

    Thread Starter
    Addicted Member DarkMoose's Avatar
    Join Date
    Jul 2000
    Location
    in a box
    Posts
    185
    KYAHAHAHAHAHAHA IT'S ALIIIIIVEEEE!!! Er... hi... ;D It works now, you rawk kedaman ;D
    To understand recursion, one must first understand the concept of recursion.

  10. #10
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    hehe have fun!
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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