Ongoing Graphics Woe... - Reply
- Posted by "BABOR, JIRI" <J.Babor at GNS.CRI.NZ> Aug 18, 1997
- 759 views
John DeHope wrote: >Well I tried a generic bitmap-drawing procedure that looks like this: <code skipped - shown below> >But it was too slow. I still need to write a routine that does this >quickly in 1024x768x256 graphics mode. Anybody have any ideas on how to >do this? You can speed up the routine considerably by comparing the whole sprite row with the background and then writing it to the screen in one go. I know, this is not the real answer to your problem, but I hope it helps a little bit. Btw, your routine is off a pixel towards the bottom right corner. Jiri -- snip ------------------------------------------------------------------------ include graphics.e include image.e include get.e object junk sequence s atom dt,t procedure my_display_image(sequence l, sequence b) atom offx, offy offx = l[1] - 1 offy = l[2] - 1 for x = 1 to length(b) do for y = 1 to length(b[x]) do if b[x][y] != 0 then pixel(b[x][y],{l[1]+x,l[2]+y}) end if end for end for end procedure global procedure merge_image(sequence s1, sequence s2) sequence s integer co,w w=length(s2[1]) for r=1 to length(s2) do s=get_pixel({s1[1],s1[2]+r-1,w}) -- get background row for c=1 to w do co=s2[r][c] if co then s[c]=co end if end for pixel(s, {s1[1],s1[2]+r-1}) end for end procedure -- main ------------------------------------------------------------------------ junk=graphics_mode(258) -- generate a simple hollow sprite shape & save it ellipse(14,1,{10,10},{49,49}) ellipse(0,1,{20,20},{39,39}) s=save_image({10,10},{49,49}) -- a bit of background nonsense for i=80 to 160 do draw_line(i,{{0,i},{150,i}}) end for -- time test: 100 iterations tick_rate(100) t=time() for i=1 to 100 do my_display_image({10,100},s) end for dt=time()-t position(15,1) puts(1, "100 iterations:\n") printf(1,"my_display_image: %5.2f\n",dt) t=time() for i=1 to 100 do merge_image({100,100},s) end for dt=time()-t printf(1,"merge_image: %5.2f\n",dt) junk=wait_key() junk=graphics_mode(-1)