1. Pixel optim
- Posted by Alexander <Carnivals at INAME.COM> Nov 26, 2000
- 402 views
I have managed to put together a graphics library, however, the routines I'm using are very slow (go figure why :)) Anyway, do anyone know a optimization for this code?: global procedure display_emb_vscreen(atom xoffset, atom yoffset, atom xparent, atom source) atom cache1, cache2, xvar, yvar, color, readpos cache1 = peek(source) cache2 = peek(source+1) xvar = cache1*256+cache2 cache1 = peek(source+2) cache2 = peek(source+3) yvar = cache1*256+cache2 readpos = 4 for y = 1 to yvar do for x = 1 to xvar do color = peek(source+readpos) if color != xparent then vscreen[y+yoffset][x+xoffset] = color end if readpos = readpos + 1 end for end for end procedure xvar and yvar is the size of the picture :) source is the hex address of where it starts BTW: Sorry for stealing the idea of a virtual screen :) but this routine is 20% faster than my old
2. Re: Pixel optim
- Posted by mic _ <stabmaster_ at HOTMAIL.COM> Nov 26, 2000
- 361 views
>From: Alexander <Carnivals at INAME.COM> >Anyway, do anyone know a >optimization for this code?: Just a very basic transcopy routine. doesn't do clipping or much of anything.. procedure transcopy(integer x, integer y, integer width, integer height, integer trans, atom src, atom dest) integer src_offset integer pix src_offset = 0 dest += (y*SCREEN_WIDTH)+x for i = 1 to height do for j = 0 to width - 1 do pix = peek(src + src_offset) if pix!=trans then poke(dest + j, pix) end if src_offset += 1 end for dest += SCREEN_WIDTH end for end procedure but if you really want speed the you might want to do this in assembly, or check out some of the other graphics libraries available. _____________________________________________________________________________________ Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com
3. Re: Pixel optim
- Posted by Jeffrey Fielding <JJProg at CYBERBURY.NET> Nov 26, 2000
- 375 views
On Sun, 26 Nov 2000, mic _ wrote: > >From: Alexander <Carnivals at INAME.COM> > >Anyway, do anyone know a > >optimization for this code?: > > > Just a very basic transcopy routine. doesn't do clipping or much of > anything.. > > > procedure transcopy(integer x, integer y, integer width, integer height, > integer trans, atom src, atom dest) > integer src_offset > integer pix > > src_offset = 0 > dest += (y*SCREEN_WIDTH)+x > > for i = 1 to height do > for j = 0 to width - 1 do > pix = peek(src + src_offset) > if pix!=trans then > poke(dest + j, pix) > end if > src_offset += 1 > end for > dest += SCREEN_WIDTH > end for > > end procedure > > > but if you really want speed the you might want to do this in assembly, or > check out some of the other graphics libraries available. > > > _____________________________________________________________________________________ > Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com > It's even faster if you load the memory to a sequence and operate on that - using peek and poke for the whole image is much faster than peeking and poking individual bytes. Jeff