Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transparency with the PUT statement?

Status
Not open for further replies.

sandmann999

Programmer
Apr 28, 2001
52
US
I'm trying to figure out how to make it so that when I use the PUT statement, I can make it not show certain colors, hence having a background image show through instead of just a black box around the image.

For example, in the following code, it draws a random background, and then places an X in the middle of the background, but there is a black box around the X.

SCREEN 13
RANDOMIZE TIMER

FOR y = 1 TO 5
FOR x = 1 TO 5
READ z%
LINE (x * 5, y * 5)-(x * 5 + 5, y * 5 + 5), z%, BF
NEXT
NEXT

DIM test%(1000)

GET (5, 5)-(30, 30), test%
CLS



FOR i = 130 TO 190
FOR j = 70 TO 130
PSET (i, j), RND * 250
NEXT
NEXT

PUT (145, 85), test%, PSET

DATA 1,0,0,0,1
DATA 0,1,0,1,0
DATA 0,0,1,0,0
DATA 0,1,0,1,0
DATA 1,0,0,0,1


How can I make it so wherever black is, the background shows through instead?
 
there is no easy/fast way to do this with pure QB...
You can get close, but it won't be quite the speed of PUT...

there are many Libraries out there that allow you to do what you are wanting to do, and much more... some like DirectQB, Future library... etc...

the process you are decribing is called using Sprites...

A sprite is a 2D picture that typically has a transparent background and is usually manipulated on the screen and commonly used for animation...

you might try looking for these at
Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif

 
lol transparency with put...

not possible. there is no way to do it with the put statement. you'll have to make your own put statement. preferrably one that clips images.


download that. then try out minirpg. check out relsprite. it's a put with transparency, clipping, etc. etc. you can use it with a buffer as well. it also has many useful things. a definite download.
 
Thanks for all the ideas.
I did, however, find a way to do it with just the PUT statement. It takes two images though. Both are identical, except in one picture, all the background is color 0, and in the other, all the background color is 255.
Then you PUT the one with 255s with the AND suffix, and then PUT the one with the 0s with the OR statement. It will make the background show through and make the black invisible.
 
oh, masking. but it's not possible with any other color than 0. i prefer to make my own put because:

1. can choose for transparency WITHOUT a mask (second image)
2. clipping (can show only a part of image)
3. probably some other things
 
The reason the PUT command is there is for two reasons: convenience and for speed. But this was in the good old 386 days. Computers now as so fast that you can draw what you want pixil by pixil using PSET without it slowing down the program. This is probably the way to go, for the three reasons that Barok mentioned.
 
More reasons to write your own 'PUT' function...
4. Scaling (Larger / Smaller images of the same immage)
5. Rotation (being able to rotate the original image)
6. Color Substitutions (like if you want the green pixels to be red for a certain image)
7. Mirroring (mirrored image)
8. more... (imagination is the limit)

Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif

 
also, translucency, where you can see another tile through the tile you're puting, so it's like looking through stained glass. once again, it's in relgfx.
 
Sounds good. I think I might have some ideas on how to do my own PUT statement, but it would include FOR loops and only placing a color when it's not 0. That's pretty rudimentary I would think.
Can you guys give me some ideas? Thanks!
 
Secondly, can BSAVE and BLOAD ONLY be used with the PUT statement? If I was to make my own PUT statement, would I need to use a save format like an array or a random access file?
 
No, BLOAD and BSAVE can be used for any array

The way that you want to do it with the FOR-NEXT loop is the only way to do it. (Without assembly)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top