1. mem routines
- Posted by "BABOR, JIRI" <J.Babor at GNS.CRI.NZ> Mar 30, 1997
- 1130 views
Public plea to Robert Craig, Now, that we are allowed to have mem_set() & mem_copy() - very nice, thank you! - what about a complete set of goodies with mem_and(), mem_or() & mem_xor()? Can I whip up any support, or am I too greedy already? Jiri
2. Re: mem routines
- Posted by "Cuny, David" <ATB.DCUNY at HW1.CAHWNET.GOV> Mar 31, 1997
- 1069 views
Jiri wrote: > Now, that we are allowed to have mem_set() & mem_copy() - very nice, thank > you! - what about a complete set of goodies with mem_and(), mem_or() & > mem_xor()? Can I whip up any support, or am I too greedy already? Jiri Sounds like what Lucius needed for his routine. It would no doubt be nice for drawing sprites, too. -- David Cuny
3. Re: mem routines
- Posted by Lucius L Hilley III <luciuslhilleyiii at JUNO.COM> Mar 31, 1997
- 1105 views
- Last edited Apr 01, 1997
David Cuny wrote: >Jiri wrote: >> Now, that we are allowed to have mem_set() & mem_copy() - very nice, thank >> you! - what about a complete set of goodies with mem_and(), mem_or() & >> mem_xor()? Can I whip up any support, or am I too greedy already? Jiri > >Sounds like what Lucius needed for his routine. It would no doubt be nice >for drawing sprites, too. > > -- David Cuny It is what I need. It would be nice for drawing the sprites that I am working with. I plan to release some image utilities soon. They will be great for drawing sprites. 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. I have another Idea that MIGHT be faster that uses xor_bits. So far I haven't succeeded in getting it put together. --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.
4. Re: mem routines
- Posted by Colin Taylor <71630.1776 at COMPUSERVE.COM> Apr 02, 1997
- 1155 views
Lucius L Hilley III wrote: >I plan to release some image utilities soon. They will be great for >drawing sprites. >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. >I have another Idea that MIGHT be faster that uses xor_bits. >So far I haven't succeeded in getting it put together. Since color bitmaps contain byte-level information (colors), it isn't necessary to resort to bit-level math. Try the following: -- 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. If you look at my bitmap demo on the euphoria home page, you will see lots of examples of the above type of bitmap manipulation. Colin Taylor 71630.1776 at compuserve.com
5. Re: mem routines
- Posted by Lucius L Hilley III <luciuslhilleyiii at JUNO.COM> Apr 02, 1997
- 1156 views
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. }