home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!usc!hacgate!atom!washing
- From: washing@hac.com (Walter Washington)
- Newsgroups: comp.lang.pascal
- Subject: grayscale image representation
- Keywords: grayscale image
- Message-ID: <24545@hacgate.SCG.HAC.COM>
- Date: 21 Dec 92 22:16:30 GMT
- Sender: news@hacgate.SCG.HAC.COM
- Reply-To: washing@hac.com
- Organization: Hughes Aircraft Co.
- Lines: 67
-
- Dear Group,
- I,m a novice user of BP7 and I want to represent a picture in grayscale
- instead of color. How would I do this in BP7? Below is a copy of my program
- which reads in binary pixel data and writes it to the CRT. The picture I get is
- color, but I desire for it to be grayscale.
-
- Thank You,
-
- {*****************************************************************************}
- {* *}
- {* Image file of binary data *}
- {* *}
- {* *}
- {*****************************************************************************}
- PROGRAM Exec;
-
- USES
- Crt,Graph,Dos,util;
- type
- zulu= packed array[0..255] of char;
- VAR
- OrigMode: INTEGER;
- imgx: array[0..255,0..239] of byte;
- bline: zulu;
- x,y,drive,l,h: integer;
- infile: file of zulu;
-
-
-
- {****************************************************************}
- {* MAIN *}
- {****************************************************************}
- BEGIN
- OrigMode := LastMode;
- TEXTMODE(C80+FONT8X8);
- assign(infile,'oscal01.img');
- reset(infile);
- for y:=0 to 239 do
- begin
- read(infile,bline);
- for x:= 0 to 255 do
- begin
- imgx[x,y]:=ord(bline[x]);
- end;
- end;
- drive:=6;
- getmoderange(drive,l,h);
- initgraph(drive,h,'e:\walter\pascal7\bgi');
- rectangle(0,0,getmaxx,getmaxy);
- setviewport(0,0,getmaxx,getmaxy,clipoff);
- for y:= 0 to 239 do
- for x:=0 to 255 do
- putpixel(x+20,y+20,imgx[x,y]);
- { putimage(20,20,imgx[x,y],normalput);}
- outtextxy(300,300,'what up doc!!!');
- pause;
- closegraph;
- close(infile);
- pause;
-
-
- END. { of program Exec }
-
-
-
-
-
-