#### Archived

This topic is now archived and is closed to further replies.

# Making Parts of Graphics INvisible in VB 6.0

This topic is 5278 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

OK, I want to be able to have a picture of say a circle, but I have to store it in a sqquare image obviously. I want the sides to just show whatever else happens to be behind the ball. Here is how I have it set up. I am declaring StdPictures for the various images, and then using PaintPicture() to draw them like this: PaintPicture pic, 50, 50, 1000, 1000, , , , , (Some RasterOp code) Now what I want to know is if there is one of those opcodes that can do what I want, if say the part that I want to be invisible is white. If I cant do this using op codes, how can I?

##### Share on other sites
I''d suggest at least using BitBlt for your graphics, which will allow you to use masks (masks allow you to specify transparency)

If you dont know howto use BitBlt from VB, I''d suggest you go through a quick toturial.. theres one here:

http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=36053&lngWId=1

(hope that address fits all in one line, its sposed to)

Maybe even BitBlt is overkill.. but its fast enough for alot of simpler games, and has decent functionality for most VB games.

Once you learn BitBlt, google for a tutorial on using masks and bitblt in VB - which will give you transparency

This probably sounds like alot to learn, but actually, the bitblt tutorial I refered you to takes like 15 minutes tops to complete and its pretty easy to understand. A masking tutorial should be around the same timeframe to complete.

If you need more tutorials, I''d suggest checking out Lucky''s VB Gaming site at:

http://www.rookscape.com/vbgaming

##### Share on other sites
I spent a very long time searching the MSDN thing, and I actually messed around with MaskBlt, but even tho I got the program to compile and run, it didnt ever show anything on the screen. Thanks for the tutorials, Ill see if I can get it working now.

##### Share on other sites
Aha! Thanks a bunch for the tutorial, I finally have it working. Heres my current code, (Btw I didnt mess with BitBlt or MaskBlt yet, I just took the concepts for now.

Dim pic As New StdPictureDim mask As New StdPicturePrivate Sub Form_Load()Set pic = LoadPicture("triangle.bmp")Set mask = LoadPicture("trianglemask.bmp")End SubPrivate Sub Timer1_Timer()PaintPicture mask, 50, 50, 1000, 1000, , , , , vbSrcAndPaintPicture pic, 50, 50, 1000, 1000, , , , , vbSrcPaintEnd Sub

##### Share on other sites
At some point you''ll probably want to move onto something faster than BitBlt (which although sufficient for basic things, is in fact quite slow). I''d recommend DirectX for this, some good tutorials can be found at:
Lucky''s VB Gaming Tutorials
DirectX4VB

##### Share on other sites
Thanks Kazgaroth, last night I got my game working using BitBlt for all the graphics instead of PaintPicture, but I had a problem that I couldnt get the image to stretch with whatever X, y, Width, and Height coordinates I BitBlt it to. It just showed up on the screen in the same size I saved it as in Paint. I didnt have this problem before.

##### Share on other sites
If you want the displayed image to be a different size to the image in memory, you need to use StretchBlt in the Windows API.

It is declared as follows:
Private Declare Function StretchBlt Lib "gdi32" (byval hDCDestination as long, byval xDest as long, byval yDest as long, byval cxDest as long, byval cyDest as long, byval hDCSrc as long, byval xSrc as long, byval ySrc as long, byval cxSrc as long, byval cySrc as long, byval dwrop as long) as long

It''s used the same way as BitBlt, but with two extra parameters ''cxDest'' and ''cyDest'', which are the required width and height, respectively.
Pretty much the same as the PaintPicture method.

Hope this is useful.

##### Share on other sites
Thanks, I tried that and it works great now. Also I read something about MaskBlt, is that just used to be able to have transparency in just one function call as opposed to:

StretchBlt Form1.myBackBuffer, Cloc.x - CRadius, Cloc.y - CRadius, CRadius * 2, CRadius * 2, CircleMask, 0, 0, 50, 50, vbSrcAndStretchBlt Form1.myBackBuffer, Cloc.x - CRadius, Cloc.y - CRadius, CRadius * 2, CRadius * 2, CirclePic, 0, 0, 50, 50, vbSrcPaint

Because I would imagine they do the same thing.

1. 1
Rutin
44
2. 2
3. 3
4. 4
5. 5

• 10
• 28
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633409
• Total Posts
3011705
• ### Who's Online (See full list)

There are no registered users currently online

×