Re: help learn from example
Hi and welcome to our forums! :wave:
It looks to me that those images are small (32x32) icons which support transparency.
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:
Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
Const SRCPAINT = &HEE0086 ' (DWORD) dest = source OR dest
Const SRCAND = &H8800C6 ' (DWORD) dest = source AND dest
Const SRCINVERT = &H660046 ' (DWORD) dest = source XOR dest
Const SRCERASE = &H440328 ' (DWORD) dest = source AND (NOT dest )
Const NOTSRCCOPY = &H330008 ' (DWORD) dest = (NOT source)
Const NOTSRCERASE = &H1100A6 ' (DWORD) dest = (NOT src) AND (NOT dest)
Const DSTINVERT = &H550009 ' (DWORD) dest = (NOT dest)
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
Private Sub Command1_Click()
BitBlt picDest.hdc, 0, 0, 60, 46, picMask.hdc, 60, 0, SRCAND
BitBlt picDest.hdc, 0, 0, 60, 46, picSprite.hdc, 60, 0, SRCPAINT
End Sub
Re: help learn from example
Nope, you don't need two images - all you need is an icon editor to create icon type file with transparent background.
There are plenty of free icon editors but master of all is of course Microangelo (not free though).
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.
Re: help learn from example
GIFs do support trans but VB has a problem with refreshing these type images - you may experience flickering effect so try to convert then to icons.
Re: help learn from example
What if you don't want icons and need images. Aren't images the standard when making games? :ehh:
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.
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?
Re: help learn from example
Why not - works fine for me and more important no flickering.