Transparency?

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Guest

Transparency?

Post by Guest »

Hey there.
I'm trying to do transparency to an image(it's PUTted on the screen), but I don't know how. I saw a tut vic did, but in his case, he did the image from DATA. what if i load it from a .bsv? whatshould the mask and image transparent color be?


Thanks a lot
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

you need to use a technique called masking sprites. Although this is not very hard, it takes 2x the amount of memory usually needed, so i recommend you use a quick library such as Rellib.

Anyway, a tutorial on sprite masking is http://petesqbsite.com/sections/tutoria ... etput.html here. I reccomend you read the whole thing (including the stuff about buffers) cuz thats useful stuff.
Image
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

Code: Select all

'load the image and set up the imagebuffer and all that


PUT(x, y), image, TRANS
That would make color 0 transparent.. In any screenmode..


This is assuming you use FB..
I have left this dump.
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

Actually, Z!re, I do believe that color 0 is transparent for screen modese 13 and below in FB.
Image
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt »

0 is transparent in 8-bit modes. &HFF00FF is transparent in truecolour modes.
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

Nekrophidius wrote:0 is transparent in 8-bit modes. &HFF00FF is transparent in truecolour modes.
Ah, yes..
I have left this dump.
Nemesis
Coder
Posts: 36
Joined: Mon Aug 16, 2004 12:54 pm
Location: Colorado Springs, Colorado

Post by Nemesis »

In QB, you must either spend twice the amount of memory using
the original sprite, and its mask, or write your own custom sprite routine.
Usually the custom routine is slower but saves the memory, so its up to the programmer which is more benificial.
In a few days when I dig it up and maybe make a few changes I'll upload a screen 13 library for QB to the d/l section here, and also a few other ones I helped with. All were written in pure QB and include source.
My library called VIDEO13h, contains a sprite routine that includes a transparency routine and other sprite features too. The special thing about my custom sprite routine is the speed optimizations it uses, which is faster than doing the AND + XOR method with a masked sprite, but doesn't need a mask sprite! It's so fast, when compiled my transparent PUT is almost as fast as QB's PSET PUT! (No kidding 8)

Anyways, be on the lookout for these d/l.

Cya,

Nemesis
Guest

Post by Guest »

hmm.. I'll read that tutorial.
Z!RE & Nekrophidus:Since I have both QB & FB, I would be interested to know:
*By color 0, you mean the first color in the palette,right?
*&HFF00FF is 255,0,255 in paint,right?:P

Nemesis:Sounds real interesting(especially since it is written in QB) and it
s so fast. Does your put function do 2 FOR loops? Anyway, I'll be on the lookout for it;)
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

Anonymous wrote:hmm.. I'll read that tutorial.
Z!RE & Nekrophidus:Since I have both QB & FB, I would be interested to know:
*By color 0, you mean the first color in the palette,right?
*&HFF00FF is 255,0,255 in paint,right?:P

Nemesis:Sounds real interesting(especially since it is written in QB) and it
s so fast. Does your put function do 2 FOR loops? Anyway, I'll be on the lookout for it;)
Yup, color 0 is the first in the palette.. just make it color 0 and you'd be fine..

As for &HFF00FF it's just what you said, 255, 0, 255
I have left this dump.
User avatar
Zamaster
Veteran
Posts: 174
Joined: Wed Jun 15, 2005 1:51 pm

Post by Zamaster »

By the way Nemesis, to clear things up, I think its AND, OR not AND, XOR.
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt »

You can use either OR or XOR for the method...both work. I know this because I used to do it both ways. :)
Antoni
Veteran
Posts: 132
Joined: Wed Jun 15, 2005 3:01 pm
Contact:

Post by Antoni »

Or use Plasma/Rel 's SuperPut
http://www.phatcode.net/downloads.php?id=166
It was very used just before FB sucked our brain :D
Post Reply