home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Multimed / Multimed.zip / mpegplay.zip / GRAY.C < prev    next >
C/C++ Source or Header  |  1994-02-16  |  2KB  |  82 lines

  1. /*
  2.  * Copyright (c) 1992 The Regents of the University of California.
  3.  * All rights reserved.
  4.  * 
  5.  * Permission to use, copy, modify, and distribute this software and its
  6.  * documentation for any purpose, without fee, and without written agreement is
  7.  * hereby granted, provided that the above copyright notice and the following
  8.  * two paragraphs appear in all copies of this software.
  9.  * 
  10.  * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
  11.  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
  12.  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  13.  * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14.  * 
  15.  * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  16.  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  17.  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  18.  * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  19.  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20.  */
  21.  
  22. #include "video.h"
  23. #include "proto.h"
  24. #include "dither.h"
  25.  
  26.  
  27. /*
  28.  *--------------------------------------------------------------
  29.  *
  30.  * GrayDitherImage --
  31.  *
  32.  *    Dithers image into 128 gray scales. Simply maps luminance
  33.  *      value into 1 of 128 gray scale colors (divide by two, essentially).
  34.  *
  35.  * Results:
  36.  *    None.
  37.  *
  38.  * Side effects:
  39.  *    None.
  40.  *
  41.  *--------------------------------------------------------------
  42.  */
  43.  
  44. void
  45. GrayDitherImage(lum, cr, cb, out, h, w)
  46.     unsigned char *lum;
  47.     unsigned char *cr;
  48.     unsigned char *cb;
  49.     unsigned char *out;
  50.     int w, h;
  51. {
  52.  
  53.   int i, max = w*h/16;
  54.  
  55.   for (i=0; i<max; i++) {
  56.     out[0] = pixel[lum[0]];
  57.     out[1] = pixel[lum[1]];
  58.     out[2] = pixel[lum[2]];
  59.     out[3] = pixel[lum[3]];
  60.     out[4] = pixel[lum[4]];
  61.     out[5] = pixel[lum[5]];
  62.     out[6] = pixel[lum[6]];
  63.     out[7] = pixel[lum[7]];
  64.     out[8] = pixel[lum[8]];
  65.     out[9] = pixel[lum[9]];
  66.     out[10] = pixel[lum[10]];
  67.     out[11] = pixel[lum[11]];
  68.     out[12] = pixel[lum[12]];
  69.     out[13] = pixel[lum[13]];
  70.     out[14] = pixel[lum[14]];
  71.     out[15] = pixel[lum[15]];
  72.     out += 16;
  73.     lum += 16;
  74.   }
  75. }
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.