×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Transparency with the PUT statement?

Transparency with the PUT statement?

Transparency with the PUT statement?

(OP)
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?

RE: Transparency with the PUT statement?

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 www.qb45.com

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

http://cubee.topcities.com

RE: Transparency with the PUT statement?

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.  

http://polacka.xepher.net/downloadables/relgfx.zip

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.

RE: Transparency with the PUT statement?

(OP)
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.

RE: Transparency with the PUT statement?

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

RE: Transparency with the PUT statement?

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.

RE: Transparency with the PUT statement?

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

http://cubee.topcities.com

RE: Transparency with the PUT statement?

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.

RE: Transparency with the PUT statement?

(OP)
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!

RE: Transparency with the PUT statement?

(OP)
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?

RE: Transparency with the PUT statement?

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)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close