Re: Masking
- Posted by jiri babor <jbabor at paradise.net.nz> Nov 08, 2003
- 695 views
Stewart, if you are after a purely Euphorian solution, have a look at the following routine that I wrote many years ago. It may not be good enough for whatever you are doing, but give it a try. In comparison with yours, it has three common, often quite significant optimizations: 1. reduced indexing level 2. a whole *run* of pixels is written instead of each one separately 3. unnecessary addition of 'y' coordinates is eliminated. jiri global procedure merge_image( sequence xy, -- top left corner sequence image, -- 2-d image sequence integer c) -- transparent cell color index -- display 2-d sequence image at point x,y -- image cells of color c are considered transparent sequence row integer f,k,w,x,y x = xy[1]-1 y = xy[2] for i=1 to length(image) do row=image[i] w = length(row) f=0 -- not in run for j=1 to w do if row[j]=c then if f then pixel(row[k..j-1],{x+k,y}) f=0 end if else if not f then k=j f=1 end if end if end for if f then pixel(row[k..w],{x+k,y}) end if y+=1 end for end procedure -- merge_image ----- Original Message ----- From: "Stewart MacKenzie-Leigh" <stewartml89 at msn.com> To: <EUforum at topica.com> Sent: 09 November 2003 8:30 AM Subject: Masking > > > 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! > >