I was just wondering how you can make a bitmap image not cover the background. umm.. like.. if u had a picture of a circle, you wouldn't have the square of color around it, to make the game look better, and to LET ME USE A BACKGROUND (argh!!!)
Printable View
I was just wondering how you can make a bitmap image not cover the background. umm.. like.. if u had a picture of a circle, you wouldn't have the square of color around it, to make the game look better, and to LET ME USE A BACKGROUND (argh!!!)
Use a gif instead of a bitmap. Not only will this allow you to have transparent backgrounds, it will also take up much less space file size.
a .gif is a movie-like file isn't it?? (and uh, what do I use to make em). I've also seen programs that used bitmaps where a certain color didn't go, to allow to see background.:confused: :confused:
1: A .gif is not a movie file. It's another type of picture
2: Use Ms Paint or any imaging program to make them
To create "transperant" bitmaps, read the next two paragraphs.
If your using directx, use an alpha mask. If your using bitblt, use a mask.
For bitblt, the mask would be gray-scale (most commonly b&w). The darker it is, the less visiable the background. Use srcAnd to paint the mask, and srcPaint to paint the main image (sprit).
If you are using image boxs, use gifs. If you happen to have photoshop, it can create gifs. Gifs can be animated, but it is not required.
Hope this helps.
ok... so I paint back of the bitmap with srcand and the front with srccopy, but... how does vb know what's back and what's front?
You need two differnt images (or differnt parts of the image). With bitblt (it may work with paintpicture too), you speicify the locations, and area to copy. One of the images is the actual image to display (with a white background), and the other is the mask (lighter = more transpartent). You then use srcAnd on the mask, and srcCopy on the image.
Mmm, no. You use vbSrcAnd on the mask source, and vbSrcPaint on the sprite source. If you have a non-black background this will not work unless you blit the mask on with vbMergePaint and the Sprite with vbSrcAnd. However the partial transparency will not work with this second method.
If you ever need a resource, I had a "BitBlt Case Studies" a while ago, that nobody ever used. Maybe I could get it stickied ;)
Oops, I wrote it wrong the second time :(
If you have Adobe it is a great program for converting any tipe of picture to gif. and making it transparent..
I used paint.picture to do it
I never realied u guys meant make a white area over where the image would be and black for the back (i did all white/black for awhile :( ) but I got it, only prob is there's a white flicker when I place the image because of the mask, any ideas?
One of two ways that I have heard work:
1) paint them on to a back buffer, then copy them to the visable image. Make sure that the back buffer has autoredraw on.
2) turn on auto redraw, then use picture1.refresh to make the image visable.
Make sure to only do the copy/refresh after the whole frame has been drawn.
back buffer? and wont that kinda cause the background to go solid again? Making it a big pointless circle.... hmm...
You paint the whole frame to the back buffer, then copy it to the front buffer. The other way is to turn autoredraw on the front/only buffer, then refresh that picture box. In this way, the new frame woun't be visable until it is intirely drawn.
back buffer? what's the back buffer?
Two ways, both with code below:
1) To use that way, you need 2 picture boxes. One is the front buffer (no autoredraw), and the other is the back buffer (with autoredraw). You draw everything to the back buffer (in order: background [srccopy], mask [srcand], then sprite [srcpaint]), then copy the backbuffer to the frontbuffer [srccopy].
2) You can also turn autoredraw on the frontbuffer (you woun't need a backbuffer this way), then refresh the picture box after you finish drawing the frame (in order: background [srccopy], mask [srcand], then sprite [srcpaint]).
The following code assumes that the backbuffer is named backbuffer, the mask is named mask, the sprite is named image, and the frontbuffer is named frontbuffer. it also asumes that all the images are in differnt picture boxes. All the images need to be in picture boxes, you may combine the image and mask, changing the source xs, ys, and hdcs. The declation can be found in the API viewer (as it is not installed on the computer I am currently using).
1) This code requires a back buffer.
VB Code:
bitblt backbuffer.hdc, 0,0,backbuffer.scalewidth, backbuffer.scaleheight, background.hdc,0,0, srccopy bitblt backbuffer.hdc, X,Y,mask.scalewidth, mask.scaleheight, mask.hdc,0,0, srcand bitblt backbuffer.hdc, 0,0,image.scalewidth, image.scaleheight, image.hdc,0,0, srcpaint bitblt frontbuffer.hdc, 0,0,backbuffer.scalewidth, backbuffer.scaleheight, backbuffer.hdc,0,0, srccopy
2) This code doesn't need a backbuffer.
VB Code:
bitblt frontbuffer.hdc, 0,0,frontbuffer.scalewidth, frontbuffer.scaleheight, background.hdc, srccopy bitblt frontbuffer.hdc, X,Y,mask.scalewidth, mask.scaleheight, mask.hdc, srcand bitblt frontbuffer.hdc, 0,0,image.scalewidth, image.scaleheight, image.hdc, srcpaint frontbuffer.refresh