home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / g / gs252src.zip / GS252 / GSCOLOR2.C < prev    next >
C/C++ Source or Header  |  1992-07-17  |  2KB  |  73 lines

  1. /* Copyright (C) 1992 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20. /* gscolor2.c */
  21. /* Level 2 color and halftone operators for Ghostscript library */
  22. #include "gx.h"
  23. #include "gserrors.h"
  24. #include "gxfixed.h"            /* ditto */
  25. #include "gxmatrix.h"            /* for gzstate.h */
  26. #include "gxdevice.h"            /* for gx_color_index */
  27. #include "gzstate.h"
  28. #include "gzcolor.h"
  29. #include "gscspace.h"
  30. #include "gscolor2.h"
  31.  
  32. /*
  33.  * NOTE: The only color spaces currently implemented by Ghostscript
  34.  * are DeviceGray, DeviceRGB, and DeviceCMYK.  This is the module where that
  35.  * limitation is enforced, since setcolorspace is the only way that
  36.  * any other color space can be made current (other than specialized
  37.  * operators such as setpattern.)
  38.  */
  39.  
  40. int
  41. gs_setcolorspace(gs_state *pgs, gs_color_space *pcs)
  42. {    /****** ONLY IMPLEMENTED FOR Device SPACES ******/
  43.     int code;
  44.     switch ( pcs->type )
  45.     {
  46.     case gs_color_space_DeviceGray:
  47.         code = gs_setgray(pgs, 0.0);
  48.         break;
  49.     case gs_color_space_DeviceRGB:
  50.         code = gs_setrgbcolor(pgs, 0.0, 0.0, 0.0);
  51.         break;
  52.     case gs_color_space_DeviceCMYK:
  53.         code = gs_setcmykcolor(pgs, 0.0, 0.0, 0.0, 1.0);
  54.         break;
  55.     default:
  56.         code = gs_error_undefined;
  57.     }
  58.     return code;
  59. }
  60.  
  61. /* currentcolorspace */
  62. int
  63. gs_currentcolorspace(const gs_state *pgs, gs_color_space *pcs)
  64. {    /****** ONLY IMPLEMENTED FOR Device SPACES ******/
  65.     int num_comp;
  66.     pcs->type = (gs_color_space_type)pgs->color->space;
  67.     if ( (num_comp = gs_color_space_num_components[(int)pcs->type]) < 0 )
  68.     {    /* Uncolored pattern space, consult underlying space. */
  69.         /* NOT IMPLEMENTED YET */
  70.     }
  71.     return num_comp;
  72. }
  73.