Re: Masking

new topic     » goto parent     » topic index » view thread      » older message » newer message

I've done this in a graphics lib I wrote...

It involved pre-loading the image, uh.... Have a look through the attached 
file. Basically, euphoria can draw a sequence of pixels much faster than 
doing it pixel by pixel.

What my graphics lib does is process the image, breaking each line up into 
lines of pixels that should be drawn, and ignoring the rest.

ie: if 0 is the transparent colour, and the first line of the image looks 
initially like this:
(random chars represent colours)
0000000000000af6732$@waer789awf000000000J8474@#a78a74900000000000000

Then it splits the line up into af6732$@waer789awf and J8474@#a78a749, and 
displays them
at the right positions.
It's very very fast, because there are no if statements, and it accomplishes 
things in as few steps as possible.

Have a look at my snake program, it shows how normal images are used, to do 
transparent images just use the other type of func calls.
=====================================================
.______<-------------------\__
/ _____<--------------------__|===
||_    <-------------------/
\__| Mr Trick


>From: Stewart MacKenzie-Leigh <stewartml89 at msn.com>
>Reply-To: EUforum at topica.com
>To: EUforum at topica.com
>Subject: Masking
>Date: Sat, 08 Nov 2003 19:30:28 +0000
>
>
>Is there a fster way to display a bitmap on the screen without the pixels 
>which are the mask color, other than plotting each color individually in a 
>loop?
>
>this is the code im using at the moment:
>
>for y = 1 to length(img) do
>    for x = 1 to length(img[y]) do
>        if img[y][x] != MASK_COLOR then
>            pixel(img[y][x], {imgX + x, imgY + y})
>        end if
>    end if
>end for
>
>this is too slow for what i am doing.
>
>
>thanks in advance
>
>StewartML
>
>
>
>TOPICA - Start your own email discussion group. FREE!
>
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu