Results 1 to 8 of 8

Thread: BitBlt transparent

  1. #1
    GuitarMan
    Guest

    Unhappy

    I am trying to make a screen saver, a logo for a Band moves about the screen (with a space background thingy) bouncing off the walls. I have got all the other code working fine. However i dont like using vbsrcinvert or vbsrcinvert as these look weard when the logo crosses the earth of the moon. So i created this code so that it uses vbsrccopy and then writes each pixel manually from the background to create a transparent effect using a mask as a guide.

    My problem is this code is way to slow, any ideas on how to fix this?


    Sub MakeTrans()
    Dim PixelX As Integer
    Dim PixelY As Integer

    Dim BackPixelColour
    Dim MaskPixelColour

    For PixelX = 0 To Form1.PicMask.ScaleWidth
    For PixelY = 0 To Form1.PicMask.ScaleHeight

    MaskPixelColour = GetPixel(Form1.PicMask.hdc, PixelX, PixelY) 'get colour from mask

    If MaskPixelColour >= 0 And MaskPixelColour <= 500 Then 'if the pixel is black copy to the buffer the pixel from the background
    BackPixelColour = GetPixel(Form1.PicBack.hdc, (Position.X + PixelX), (Position.Y + PixelY)) 'get background pixel colour
    Call SetPixelV(Form1.PicBuf.hdc, (Position.X + PixelX), (Position.Y + PixelY), BackPixelColour) 'draw to buffer the pixel colour
    End If

    Next
    Next

    End Sub

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    This is an ongoing problem in the graphics world of programming: drawing things pixel by pixel.

    I suggest using SrcAND for the mask and SrcPAINT for the sprite, it should work. (get 'em in the declaration explorer)
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    the rasterop constants can be found within the runtimes too:
    VBRUN.RasterOpConstants.vbSrcPaint
    VBRUN.RasterOpConstants.vbSrcAnd
    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.

  4. #4
    Megatron
    Guest
    Or you can just use them plain (without any reference to another object)
    Code:
    Print vbSrcPaint 
    Print vbSrcAnd

  5. #5
    GuitarMan
    Guest
    Thanks anyway Guys. Its a shame i liked that code.

  6. #6
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Is it just me kedaman or do you change your signature every 2 seconds?
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    it's because of me, me changed my signature twice in 20 mins
    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.

  8. #8
    GuitarMan
    Guest

    Talking

    Thanks Sastraxi that works great, but why didn't i think of that? Oh well.

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