home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / pascal / 7612 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  2.3 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!usc!hacgate!atom!washing
  2. From: washing@hac.com (Walter Washington)
  3. Newsgroups: comp.lang.pascal
  4. Subject: grayscale image representation
  5. Keywords: grayscale image
  6. Message-ID: <24545@hacgate.SCG.HAC.COM>
  7. Date: 21 Dec 92 22:16:30 GMT
  8. Sender: news@hacgate.SCG.HAC.COM
  9. Reply-To: washing@hac.com
  10. Organization: Hughes Aircraft Co.
  11. Lines: 67
  12.  
  13. Dear Group,
  14.     I,m a novice user of BP7 and I want to represent a picture in grayscale
  15. instead of color.  How would I do this in BP7? Below is a copy of my program
  16. which reads in binary pixel data and writes it to the CRT.  The picture I get is
  17. color, but I desire for it to be grayscale.
  18.  
  19.                     Thank You,
  20.  
  21. {*****************************************************************************}
  22. {*                                                                           *}
  23. {*              Image file of binary data                                    *}
  24. {*                                                                           *}
  25. {*                                                                           *}
  26. {*****************************************************************************}
  27. PROGRAM Exec;
  28.  
  29. USES
  30.   Crt,Graph,Dos,util;
  31. type
  32.   zulu= packed array[0..255] of char;
  33. VAR
  34.   OrigMode: INTEGER;
  35.   imgx: array[0..255,0..239] of byte;
  36.   bline: zulu;
  37.   x,y,drive,l,h: integer;
  38.   infile: file of zulu;
  39.  
  40.  
  41.  
  42. {****************************************************************}
  43. {*              MAIN                                            *}
  44. {****************************************************************}
  45. BEGIN
  46.   OrigMode := LastMode;
  47.   TEXTMODE(C80+FONT8X8);
  48.      assign(infile,'oscal01.img');
  49.      reset(infile);
  50.      for y:=0 to 239 do
  51.        begin
  52.          read(infile,bline);
  53.          for x:= 0 to 255 do
  54.            begin
  55.              imgx[x,y]:=ord(bline[x]);
  56.            end;
  57.        end;
  58.        drive:=6;
  59.        getmoderange(drive,l,h);
  60.        initgraph(drive,h,'e:\walter\pascal7\bgi');
  61.        rectangle(0,0,getmaxx,getmaxy);
  62.        setviewport(0,0,getmaxx,getmaxy,clipoff);
  63.        for y:= 0 to 239 do
  64.          for x:=0 to 255 do
  65.            putpixel(x+20,y+20,imgx[x,y]);
  66. {       putimage(20,20,imgx[x,y],normalput);}
  67.        outtextxy(300,300,'what up doc!!!');
  68.        pause;
  69.        closegraph;
  70.      close(infile);
  71.      pause;
  72.  
  73.  
  74. END. { of program Exec }
  75.  
  76.  
  77.  
  78.  
  79.  
  80.