Page 1 of 1

Transparency?

Posted: Sun Nov 13, 2005 12:50 pm
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

Posted: Sun Nov 13, 2005 1:03 pm
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.

Posted: Sun Nov 13, 2005 3:30 pm
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..

Posted: Sun Nov 13, 2005 5:19 pm
by {Nathan}
Actually, Z!re, I do believe that color 0 is transparent for screen modese 13 and below in FB.

Posted: Sun Nov 13, 2005 6:00 pm
by Nodtveidt
0 is transparent in 8-bit modes. &HFF00FF is transparent in truecolour modes.

Posted: Sun Nov 13, 2005 6:37 pm
by Z!re
Nekrophidius wrote:0 is transparent in 8-bit modes. &HFF00FF is transparent in truecolour modes.
Ah, yes..

Posted: Sun Nov 13, 2005 7:35 pm
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

Posted: Mon Nov 14, 2005 7:17 am
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;)

Posted: Mon Nov 14, 2005 9:46 am
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

Posted: Mon Nov 14, 2005 6:28 pm
by Zamaster
By the way Nemesis, to clear things up, I think its AND, OR not AND, XOR.

Posted: Tue Nov 15, 2005 12:09 am
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. :)

Posted: Tue Nov 15, 2005 3:03 pm
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