This is gdith.c in view mode; [Download] [Up]
/* * Copyright (c) 1992 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice and the following * two paragraphs appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. */ #include <math.h> #include "video.h" #include "dither.h" /* Array that remaps color numbers to actual pixel values used by X server. */ unsigned char pixel[256]; /* Arrays holding quantized value ranged for lum, cr, and cb. */ int lum_values[LUM_RANGE]; int cr_values[CR_RANGE]; int cb_values[CB_RANGE]; /* Structures used by the X server. */ Display *display; /* *-------------------------------------------------------------- * * ConvertColor -- * * Given a l, cr, cb tuple, converts it to r,g,b. * * Results: * r,g,b values returned in pointers passed as parameters. * * Side effects: * None. * *-------------------------------------------------------------- */ static void ConvertColor(l, cr, cb, r, g, b) unsigned char l, cr, cb; unsigned char *r, *g, *b; { double fl, fcr, fcb, fr, fg, fb; fl = (double) l; fcr = ((double) cr) - 128.0; fcb = ((double) cb) - 128.0; fr = fl + (1.40200 * fcb); fg = fl - (0.71414 * fcb) - (0.34414 * fcr); fb = fl + (1.77200 * fcr); if (fr < 0.0) fr = 0.0; else if (fr > 255.0) fr = 255.0; if (fg < 0.0) fg = 0.0; else if (fg > 255.0) fg = 255.0; if (fb < 0.0) fb = 0.0; else if (fb > 255.0) fb = 255.0; *r = (unsigned char) fr; *g = (unsigned char) fg; *b = (unsigned char) fb; } /* Array back mapping pixel value to color number. Used for debugging and dumping purposes. */ static char backpixel[256]; /* *-------------------------------------------------------------- * * ExecuteDisplay -- * * Actually displays display plane in previously created window. * * Results: * None. * * Side effects: * None. * *-------------------------------------------------------------- */ /*************************************************************** vid_stream->current->display is a pointer to a bitmap of dimensions vid_stream->mb_width * 16 by vid_stream->mb_height * 16. The RGB data are pixel interleaved. - WAR ***************************************************************/ extern int writeToStdout; void ExecuteDisplay(vid_stream) VidStream *vid_stream; { int iWidth, iHeight; ++totNumFrames; fwrite((void *) &totNumFrames, (size_t) sizeof(int), (size_t) 1, stdout); iWidth = (vid_stream->mb_width << 4); fwrite((void *) &iWidth, (size_t) sizeof(int), (size_t) 1, stdout); iHeight = (vid_stream->mb_height << 4); fwrite((void *) &iHeight, (size_t) sizeof(int), (size_t) 1, stdout); fwrite((void *) vid_stream->current->display, (size_t) sizeof(char), (size_t) (3*iWidth*iHeight), stdout); return; }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.