program imagedit; uses graphics,mouse,crt,text,open; var x320, x, y, picturesize : word; virtualwindow, virtualimage : pointer; colour, r, g, b : byte; {-----------------------------------------------------------} Procedure loadimage(filename:string); var picture : file of byte; begin assign(picture,filename+'.img'); reset(picture); picturesize:=filesize(picture); close(picture); x320:=$28; getmem(virtualwindow,64000); getmem(virtualimage,64000); asminitgraphics(1); asmclsuser(0,64000,seg(virtualimage^)); asmclsuser(0,64000,seg(virtualwindow^)); load320Image(filename+'.img',virtualimage,picturesize); load256palette(filename+'.pal'); menubar(seg(virtualwindow^)); Asminitpalette; PaletteGraphuser(0,173,4,64,5,1,seg(virtualwindow^)); asmcopyscreen(seg(virtualwindow^),seg(mode1addr^)); asmcopybytes(seg(virtualimage^),seg(mode1addr^)+x320*4,320*164); line_(0,172,319,172,0); end; {--------------------------------------------------------------} procedure editimage; var oldmousex, oldmousey, x1, x2, y1, y2, position : word; exitimage, clipboard : boolean; front, back : byte; procedure showclipboard; {++++++++++++++++++++++++++} begin putimageuser(1,10,5,seg(mode1addr^)); rectangleuser(0,9,(x2-x1)+2,(y2-y1)+11,0,seg(mode1addr^)); line_(0,8,319,8,0); end; {++++++++++++++++++++++++++} begin if init_mouse then begin position:=0; exitimage:=false; clipboard:=false; x:=1;y:=0; Set_Pointer_Location(100,100); show_pointer; repeat oldmousex:=mousex; oldmousey:=mousey; Get_Pointer_location(true,69,0,false); if (Mousex=0) and (Mousey=0) and (MouseButton=1)then exitimage:=true; if (MouseButton=1) and (mousey<173) and (mousey>7) then begin x1:=mousex; y1:=mousey; repeat Get_Pointer_location(false,69,0,false); if (mousey<173) and (mousey>7) and (mousex>x1) and (mousey>y1) then begin if position=0 then asmcopybytes(seg(virtualimage^),seg(mode1addr^)+x320*4,320*164); if position>0 then asmcopybytes(seg(virtualimage^)+position,seg(mode1addr^)+x320*4,320*164); rectangleuser(x1,y1,mousex,mousey,254,seg(mode1addr^)); end; until mousebutton<>1; x2:=mousex; y2:=mousey; if (x2>x1) and (y2>y1) then begin if position=0 then getimageuser(x1,y1-8,x2,y2-8,seg(virtualimage^)); if position>0 then getimageuser(x1,y1+28,x2,y2+28,seg(virtualimage^)); showclipboard; clipboard:=true; end; end; if (MouseButton=1) and (mousex=0) and (mousey>192) then begin position:=0; hide_pointer; asmcopybytes(seg(virtualimage^),seg(mode1addr^)+x320*4,320*164); if clipboard then showclipboard; show_pointer; end; if (MouseButton=1) and (mousex=319) and (mousey>192) then begin position:=x320*18; hide_pointer; asmcopybytes(seg(virtualimage^)+position,seg(mode1addr^)+x320*4,320*164); line_(0,8,319,8,0); if clipboard then showclipboard; show_pointer; end; if (MouseButton=2) and (mousey<193) and (mousey>9) then begin x:=1; y:=0; front:=255; back:=0; hide_pointer; colour:=asmgetpixel(mousex-1,mousey); r:=getred(colour); g:=getgreen(colour); b:=getblue(colour); putfill(313,194,318,198,colour); asmgotoxy(x+1,y); asmputchar(ord('C'),255,back,1); asmgotoxy(x+2,y); asmputchar(colour mod 1000 div 100+48,front,back,1); asmgotoxy(x+3,y); asmputchar(colour mod 100 div 10+48,front,back,1); asmgotoxy(x+4,y); asmputchar(colour mod 10+48,front,back,1); asmgotoxy(x+6,y); asmputchar(ord('R'),249,back,1); asmgotoxy(x+7,y); asmputchar(r mod 1000 div 100+48,front,back,1); asmgotoxy(x+8,y); asmputchar(r mod 100 div 10+48,front,back,1); asmgotoxy(x+9,y); asmputchar(r mod 10+48,front,back,1); asmgotoxy(x+11,y); asmputchar(ord('G'),250,back,1); asmgotoxy(x+12,y); asmputchar(g mod 1000 div 100+48,front,back,1); asmgotoxy(x+13,y); asmputchar(g mod 100 div 10+48,front,back,1); asmgotoxy(x+14,y); asmputchar(g mod 10+48,front,back,1); asmgotoxy(x+16,y); asmputchar(ord('B'),251,back,1); asmgotoxy(x+17,y); asmputchar(b mod 1000 div 100+48,front,back,1); asmgotoxy(x+18,y); asmputchar(b mod 100 div 10+48,front,back,1); asmgotoxy(x+19,y); asmputchar(b mod 10+48,front,back,1); show_pointer; end; until exitimage; fadeout(50); end; freemem(virtualwindow,64000); freemem(virtualimage,64000); asmclosegraph; end; {-----------------------------------------------------------} begin if does_file_exist(paramstr(1)+'.img') and does_file_exist(paramstr(1)+'.pal') then begin loadimage(paramstr(1)); editimage; end; if (paramstr(1)<>'') and (paramstr(1)<>'/?') then if Does_File_Exist(paramstr(1)+'.img')=false then writeln('File Not Found!'); if (paramstr(1)='') or (paramstr(1)='/?') then begin writeln; writeln('IMAGE Written By Franz Ayestaran (c)1997'); writeln('------'); writeln('This Program allows the user to view the'); writeln('colour and RGB values of an <.img> file'); writeln('accompanied by a <.pal> file.'); writeln; writeln('IMAGE '); writeln; end; end.