Results 1 to 10 of 10

Thread: help learn from example

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Posts
    6

    help learn from example

    I can't figure out how something so simple was done..

    http://www.Planet-Source-Code.com/vb...50597&lngWId=1

    I was interested in this code and noticed something very simple that I notice in alot of VB projects from PLC... the background of the images are already transparent/\.. or just the same color as the form.. I couldn't figure out how this was done... Can someone please explain it to me?

  2. #2

  3. #3
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: help learn from example

    Yeah, you need two of the same image. One is the actual image with a black background, and the othe is the mask, which is the same image only with a white background and the image itself is all black. Then you do this:

    VB Code:
    1. Const SRCCOPY = &HCC0020         ' (DWORD) dest = source
    2. Const SRCPAINT = &HEE0086        ' (DWORD) dest = source OR dest
    3. Const SRCAND = &H8800C6          ' (DWORD) dest = source AND dest
    4. Const SRCINVERT = &H660046       ' (DWORD) dest = source XOR dest
    5. Const SRCERASE = &H440328        ' (DWORD) dest = source AND (NOT dest )
    6. Const NOTSRCCOPY = &H330008      ' (DWORD) dest = (NOT source)
    7. Const NOTSRCERASE = &H1100A6     ' (DWORD) dest = (NOT src) AND (NOT dest)
    8. Const DSTINVERT = &H550009       ' (DWORD) dest = (NOT dest)
    9.  
    10. 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
    11.  
    12. Private Sub Command1_Click()
    13.  
    14. BitBlt picDest.hdc, 0, 0, 60, 46, picMask.hdc, 60, 0, SRCAND
    15. BitBlt picDest.hdc, 0, 0, 60, 46, picSprite.hdc, 60, 0, SRCPAINT
    16.  
    17. End Sub

  4. #4

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Posts
    6

    Re: help learn from example

    ok thanks for the info. I was messing with photoshop and found out why. I was saving the pics in bmp which dont support transparent background apparently.. neither do jpegs.. but when I tried gif it worked so I'm good to go. thanks again people.

  6. #6

  7. #7
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: help learn from example

    What if you don't want icons and need images. Aren't images the standard when making games?

  8. #8
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: help learn from example

    There are many types of images and icons are one of them.
    Windows icons are small images that support transparency.
    Their sizes are vary between 16 and 128 pixels but majority of icon editors support only upto 64x64.
    When you need to use small images in your app - icons are the best.
    GIFs and JPGs are ok but flicker on every refresh so your screen looks like ... well you know.
    VB is best with BMPs but those don't support transparency and are much larger files.

  9. #9

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Posts
    6

    Re: help learn from example

    so the best thing to do when making games with larger images is to use bitblt trans on bmp pics?

  10. #10

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