Results 1 to 6 of 6

Thread: Transparent Blit

  1. #1

    Thread Starter
    Lively Member jayantkumble's Avatar
    Join Date
    Feb 2002
    Posts
    65

    Transparent Blit

    hi,
    Plz help me with this one.
    I have a series of images of a walking character that i want to blit on to a background. But the images blitted should be transparent. The first thing i did was that i got all the images into an array of stdPicture objects (i'm not using DirectX and i don't want to, at this moment). Then i wrote the code to load one of the images into the a picturebox that would be displaying the rest of the sequence when the user presses the LeftArrow key. But here i needed the characters background color i.e. White in this case to be transparent. So i thought of getting the background of the form to be blitted onto the picturebox first and then the characters image to be blitted using the API TransparentBlit. i.e.
    call BitBlit(picture1.hdc,0,0,picture1.width,picture1.height,form1.hdc,picture1.left,picture1.top,SRCCOPY )
    call TransprentBlit(picture1.hdc,0,0,picture1.width,pictue1.heoght,stdpicture(1).handle,0,0,stdpicture(1) .width,stdpicture(1).height,rgb(255,255,255))

    but here the stdpicture(1).handle is the handle of the bitmap and not any DC. So the TransparentBlit function doesn't work.
    How can i get this thing done without using any more image or pictureboxes.
    I tried using one more picturebox, i.e. getting tthe stdpicture(1) into the second picturebox and then TransparentBliting it onto the picture1 picture box.
    But after some time of working fine it gives me an out of memory error.

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Use offscreen DCs: http://fox.acky.net/vb/english/coding/tutorial/3.3.html

    btw: Pictureboxes have a hDC property which is their DC. Images don't have a DC.

  3. #3
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Just seen your site for the first time - very cool!!

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  4. #4
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Is this your site Fox?? http://fox.acky.net/vb/english/codin...ial/index.html I can remember that I othen landed on this one when I was searching for VB Game code in my early days og game programming....Nice site...

  5. #5
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Yes, that's the tutorial I once started and never finished. I ran out of time and later I was pissed to continue writing it. The site itselves starts here http://fox.acky.net/vb/

    However I didn't spend any time on it lately so the demo projects may be outdated - at least in my eyes they are. If I ever decided to update the site again it will be a 100% update with completely new projects and only complete tutorials. But this may take me a while before I even start..

  6. #6
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I havn't read much on the page, but the tile tutorial can still be used as theory i think. So I hope you get the time to update it....

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