1. split scroll

--------------352776012A9

I am working on an application that requires split scroll on a graphics
screen (like two windows to the same graphics image). The program I have
enclosed does what I intend but extremely slowly.

Can anybody out there come up with a solution on how to speed it up
without reducing the size of the image or increasing the scroll step?

Is the one dimensionaly slicing in a two dimensional array using a loop
slowing this down? I recall someone sent a message advising techniques
for two dimensional slicing ie s[a..b][c..d] but I am unable to trace
the message.

Many thanks from an extremely content registered Euphoria user.

Saludos
Adam H. Jackson

--------------352776012A9
Content-Disposition: inline; filename="2SCROLL2.EX"

include graphics.e
include image.e

sequence image1 -- contains original full image
sequence image2 -- to contain image made from sections
sequence p1,p2  -- coordinates of two sections (p1={p1x,p1y})
atom check

-- to create a random 640 x 400 bitmap (for demonstration purposes)
procedure create_image1()
    image1=repeat(repeat(0,640),400)
    for y=1 to 400 by 1 do
    for x=1 to 640 by 1 do
        image1[y][x]=rand(256)
    end for
    end for
end procedure

-- sets graphics mode 320 x 200 256 colours
procedure set_screen()
    check=graphics_mode(19)
end procedure

-- gets the two sections from image1 and appends in image2-----------------
procedure part_screen(sequence p1,sequence p2)
sequence part1,part2
image2={} -- clear image2. Perhaps quicker if it is simply overwritten?
    for l=0 to 199 by 1 do
        part1=image1[p1[2]+l][p1[1]..p1[1]+158]
        part2=image1[p2[2]+l][p2[1]..p2[1]+158]
        image2=append(image2,part1&{0,0}&part2)
    end for
end procedure

-- Key control for scroll ----------------------------------------
procedure control()
integer key
sequence t1 ,t2
t1=p1 t2=p2 -- create temp
    key=get_key()
    if key=27 then abort(1)
    elsif key=331 then t1[1]=t1[1]-1 -- left 1
    elsif key=333 then t1[1]=t1[1]+1 -- right 1
    elsif key=328 then t1[2]=t1[2]-1 -- up 1
    elsif key=336 then t1[2]=t1[2]+1 -- down 1
    elsif key=371 then t2[1]=t2[1]-1 -- right 2
    elsif key=372 then t2[1]=t2[1]+1 -- left 2
    elsif key=397 then t2[2]=t2[2]-1 -- up 2
    elsif key=401 then t2[2]=t2[2]+1 -- down 2
    end if
    if t1[1]<0 or t1[1]>640-180 then t1[1]=p1[1] end if -- limit x
    if t1[2]<0 or t1[2]>400-200 then t1[2]=p1[2] end if -- limit y
    if t2[1]<0 or t2[1]>640-180 then t2[1]=p2[1] end if -- limit x
    if t2[2]<0 or t2[2]>400-200 then t2[2]=p2[2] end if -- limit y
    p1=t1 p2=t2 -- transfer temp to real
end procedure

-- main ------------------------------------------------------
create_image1()
set_screen()
p1={0,0} p2={0,0} -- starting point

while 1 do
    control()
    part_screen(p1+1,p2+1) -- +1 as image is in a sequence
    display_image({0,0},image2)
end while


--------------352776012A9--

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu