home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / xpaint-247 / image.h < prev    next >
C/C++ Source or Header  |  1996-06-25  |  5KB  |  151 lines

  1. #ifndef __IMAGE_H__
  2. #define __IMAGE_H__
  3.  
  4. /* +-------------------------------------------------------------------+ */
  5. /* | Copyright (C) 1993, David Koblas (koblas@netcom.com)              | */
  6. /* | Copyright 1995, 1996 Torsten Martinsen (bullestock@dk-online.dk)  | */
  7. /* |                                                                   | */
  8. /* | Permission to use, copy, modify, and to distribute this software  | */
  9. /* | and its documentation for any purpose is hereby granted without   | */
  10. /* | fee, provided that the above copyright notice appear in all       | */
  11. /* | copies and that both that copyright notice and this permission    | */
  12. /* | notice appear in supporting documentation.  There is no           | */
  13. /* | representations about the suitability of this software for        | */
  14. /* | any purpose.  this software is provided "as is" without express   | */
  15. /* | or implied warranty.                                              | */
  16. /* |                                                                   | */
  17. /* +-------------------------------------------------------------------+ */
  18.  
  19. /* $Id: image.h,v 1.7 1996/05/28 09:17:00 torsten Exp $ */
  20.  
  21. typedef struct {
  22.     int refCount;        /* reference count */
  23.  
  24.     /*
  25.     **  Special notes:
  26.     **    if the image isBW then there will be a two entry
  27.     **       colormap BLACK == 0, WHITE == 1
  28.     **    if the image isGrey, then the colormap is 256 entries
  29.     **       BLACK == 0 .. WHITE == 255
  30.      */
  31.     int isGrey, isBW;        /* simple indicator flags  GreyScale, Black & White */
  32.     /*
  33.     **  bytes per pixel (3 for RGB, 2 for 0..256+ cmap, 1 for 0..256 cmap)
  34.      */
  35.     int scale;
  36.     /*
  37.     **  Colormap entries
  38.     **   rgb rgb rgb [1..size]
  39.      */
  40.     int cmapPacked;        /* Boolean, is the colormap packed 
  41.                    down to just the used colors */
  42.     int cmapSize;        /* number of colors in colormap == 0 if no colormap */
  43.     unsigned char *cmapData;
  44.     /*
  45.     **  Image data
  46.     **   either rgb rgb rgb
  47.     **   or     idx idx idx
  48.     **
  49.     **   if image has colormap, and the size > 256, then
  50.     **     data is pointers to unsigned shorts.
  51.      */
  52.     int width, height;        /* width, height of image */
  53.     unsigned char *data;
  54.     unsigned char *maskData;
  55.  
  56.     /*
  57.     **  These values are here because the XPM calls are TOO dependant
  58.     **   on X Windows.  They are not, and should not, be used by anything
  59.     **   else.
  60.      */
  61.     unsigned long sourcePixmap;
  62.     unsigned long sourceColormap;
  63.     unsigned long sourceMask;
  64. } Image;
  65.  
  66. #ifdef _XLIB_H_
  67. /* Used to transfer information to routines in iprocess.c */
  68. struct imageprocessinfo {
  69.     int oilArea;
  70.     int noiseDelta;
  71.     int spreadDistance;
  72.     int pixelizeXSize;
  73.     int pixelizeYSize;
  74.     int despeckleMask;
  75.     int smoothMaskSize;
  76.     int tilt;
  77.     int solarizeThreshold;
  78.     int contrastW;
  79.     int contrastB;
  80.     int quantizeColors;
  81.     int tiltX1;
  82.     int tiltY1;
  83.     int tiltX2;
  84.     int tiltY2;
  85.     XColor *background;
  86. };
  87.  
  88. #endif
  89.  
  90. #define ImagePixel(image, x, y)                        \
  91.     (((image)->cmapSize == 0)                    \
  92.       ? &((image)->data[((y) * (image)->width + (x)) * 3])        \
  93.       : (((image)->cmapSize > 256)                    \
  94.          ? &((image)->cmapData[((unsigned short *)(image)->data)    \
  95.                 [(y) * (image)->width + (x)] * 3])    \
  96.          : &((image)->cmapData[(image)->data[(y)*(image)->width+(x)] * 3])))
  97.  
  98. #define ImageSetCmap(image, index, r, g, b) do {        \
  99.             image->cmapData[(index) * 3 + 0] = r;    \
  100.             image->cmapData[(index) * 3 + 1] = g;    \
  101.             image->cmapData[(index) * 3 + 2] = b;    \
  102.         } while (0)
  103.  
  104. /* image.c */
  105. Image *ImageNew(int width, int height);
  106. Image *ImageNewCmap(int width, int height, int size);
  107. Image *ImageNewBW(int width, int height);
  108. Image *ImageNewGrey(int width, int height);
  109. void ImageMakeMask(Image * image);
  110. void ImageDelete(Image * image);
  111. Image *ImageToRGB(Image * image);
  112.  
  113. #ifdef _XtIntrinsic_h
  114. Image *PixmapToImage(Widget w, Pixmap pix, Colormap cmap);
  115. void PixmapToImageMask(Widget w, Image * image, Pixmap mask);
  116. Boolean ImageToPixmap(Image * image, Widget w, Pixmap * pix, Colormap * cmap);
  117. Pixmap MaskDataToPixmap(Widget w, int width, int height,
  118.             char *data, XRectangle * rect);
  119. Pixmap ImageMaskToPixmap(Widget w, Image * image);
  120. Boolean ImageToPixmapCmap(Image * image, Widget w, Pixmap * pix, Colormap cmap);
  121. #endif
  122.  
  123. /* imageComp.c */
  124. Image *ImageCompress(Image * input, int ncolors, int noforce);
  125.  
  126. /* iprocess.c */
  127. Image *ImageSmooth(Image * input);
  128. Image *ImageSharpen(Image * input);
  129. Image *ImageEdge(Image * input);
  130. Image *ImageEmbose(Image * input);
  131. Image *ImageInvert(Image * input);
  132. Image *ImageOilPaint(Image * input);
  133. Image *ImageAddNoise(Image * input);
  134. Image *ImageSpread(Image * input);
  135. Image *ImageBlend(Image * input);
  136. Image *ImagePixelize(Image * input);
  137. Image *ImageDespeckle(Image * input);
  138. Image *ImageNormContrast(Image * input);
  139. Image *ImageHistogram(Image * input);
  140. Image *ImageSolarize(Image * input);
  141. Image *ImageQuantize(Image * input);
  142. Image *ImageGrey(Image * input);
  143. Image *ImageTilt(Image * input);
  144. Image *ImageDirectionalFilter(Image * input);
  145.  
  146. /* texture.c */
  147. Image *draw_plasma(int w, int h);
  148. Image *draw_landscape(int w, int h, int clouds);
  149.  
  150. #endif                /* __IMAGE_H__ */
  151.