Re: Fast Image Routine & Saving a sequence

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

On Tue, 27 May 1997 22:28:53 +0000 Ralf Nieuwenhuijsen
<nieuwen at magigimmix.xs4all.nl> writes:
>---------------------- Information from the mail header
>
>        Why does 0 or 6 return 1 instead of 6 ??

Answer is that or is a logical operator just like | in C
or_bits is the bitwise operator in euphoria like || in C.
or_bits was an after thouht so it is a function not a
normal operator.  Examples are below.

x = 0 or 6
-- x = 1
y = or_bits(0, 6)
--- y = 6

>and does anyone know why you can't use XOR on sequences???
>It would be helpfull for sprites,


I can't see where xor_bits() would be useful.
PLEASE enlighten me.
I know that just using or_bits() is a cheap method of
transparency.  I say cheap because it doesn't achieve
TRUE transparency. The original colors are mangled
in the attempt to create transparency.

These two functions should do all you need.
The color to be used as transparent can be any color
from 0 to 255.
You must keep in mind that your background image
MUST be of exact size and shape as your foreground
image. EXAMPLE


Screen is this size
+-----------------+
|                 |
|                 |
|                 |
|                 |
+-----------------+
You want to place image here.
+-----------------+
|                 |
|      +---+      |
|      |   |      |
|      +---+      |
+-----------------+
You must cut that section of the screen to
be used as the background image to be mixed.

foreg = sequence
backg = same shape sequence as foreg
fimage = Filter_Image(foreg, BLACK)

fimage is a filter of the foreground to be kept
this can be created once and used every time
You use the foreg to create a mixed image.
A mixed image is an image that shows the backg
through the foreg. The mixed image can then
be displayed to the screen without checking
for transparency with difficult and painfully
slow LOOPS.

Filter_image is slow because it uses multiplying.
The equality check is slow enough.
For a very slight increase in speed you can replace
fimage = (fimage = color)
with
fimage = not fimage

However this will not allow any color. It checks for
ONLY black.  color zero (0)

global function Filter_Image(sequence fimage, integer color)
  fimage = (fimage = color)
  fimage = fimage * 255
  return fimage
end function

global function Mix_Image(sequence fore, sequence back, sequence filter)
  filter = and_bits(filter, back)
  filter = or_bits(filter, fore)
  return filter
end function

>                #########################
>                    Saving a sequence to disk
>                #########################
>        The XP3 source also allows you to load & save multiple
>pictures to
>disk, that's handy but very restrictive. I'll write a routine which
>save an Euphoria sequence to disk with LZH Compression maintaining
>it's orgininal structure. That kind of routine can be used for a much
>more purposes. I will be using the same technique as i used in EDM.E
>
>Ralf Nieuwenhuijsen
>nieuwen at xs4all.nl

I will be interested in seeing this routine. I have many
uses for this.

--Lucius Lamar Hilley III
--  E-mail at luciuslhilleyiii at juno.com
--  I support transferring of files less than 60K.
--  I can Decode both UU and Base64 format.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu