Re: mem routines

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

On Wed, 2 Apr 1997 10:13:08 EST Colin Taylor <71630.1776 at COMPUSERVE.COM>
writes:
>
>Lucius L Hilley III wrote:
>>
>>fore = a foreground image.
>>back = a background image.
>>--if fore is a 2D sequence 10x20 then
>>--back must be a 2D sequence 10x20
>>filter = filter image of fore.
>>mixed = fore with back showing through.
>
>>Code would look something like this.
>
>>filter = (fore = 0)--Create boolean filter
>>filter = fliter * 255--set filter to where back can show through.
>
>>mixed = and_bits(filter, back)--mixed will equal part of back to
>show.
>>mixed = or_bits(fore, mixed)--mixed equal fore with back showing.
>
>>NOTE: Multiplying by 255 is slow.
>>    I suggest creating the filter once and reusing it.
>>ALSO: My background changes according to where
>>    I am going to place fore.  SO I have to call
>>    and_bits & or_bits every time.
>
>>Please give credit where credit is due.
>>These are only 4 lines of code but it took me a few hours
>>to figure out just what order and how this would work.
>
>--
>filter = not fore  -- creates boolean mask
>mixed = filter*back  -- masks the background image
>mixed = mixed+fore  -- adds the foreground image
>--
>
>Or, more concisely stated:
>
>--
>mixed = fore+back*not fore
>--
>
>This method runs about 20% faster than yours, and works on
>euphoria version 1.4.  It is the best that I have been able to do
>without resorting to (agghh!) machine code.

I don't think so.

YOU: filter = not fore
YOU: mixed = filter*back
YOU: mixed = mixed+fore

ME:  filter = (fore = 0)
ME: filter = fliter * 255
ME: mixed = and_bits(filter, back)
ME: mixed = or_bits(fore, mixed)

YOU: filter = not fore
ME:  filter = (fore = 0)
  I didn't think about using not.  MY Mistake.
  Mine is faster on my Pentium though.
--Your filter is done.

ME: filter = fliter * 255
--Now mine is done.

YOU: mixed = filter*back
ME: mixed = and_bits(filter, back)
  You have to multiply which is much slower than
  bit manipulation such as and_bits().

YOU: mixed = mixed+fore
ME: mixed = or_bits(fore, mixed)
  My Bit manipulation is faster than your adding.
  Same result though.


RESULTS:
    Yours is faster if you create the filter every time
that you want to mix fore and back. Because yours
takes one less step than mine.  EVEN Then you would
benefit from my or_bits(fore, back) over your fore + back.

    Mine is faster because I create the filter ONCE and
reuse it for that image every time I want to mix it with a
background.  I did my multiplying in the filter so I don't
have to multiply my filter with back.

HINT:  The fore stays the same.  The filter stays the same.
  Only the back is force to change.  The reason the back
  changes is because you are placing fore on a Piece of
  back in different places.

YOU:>Colin Taylor
YOU:>71630.1776 at compuserve.com

ME:{
--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