 
#ifndef image_DEFINED
#define image_DEFINED 1
 
#ifndef class_DEFINED
#include <class.h>
#endif /* class_DEFINED */
/* 
 * This file was generated by the Andrew class system preprocessor.
 * Don't make changes to this file as it is created from image.ch and will be
 * overwritten.  Make changes to image.ch instead.
 */ 
 
#ifndef class_StaticInfoOnly
/* 
 * The following information was copied, as-is, from image.ch.
 */ 
 
/* ********************************************************************** *\
 *         Copyright IBM Corporation 1988,1989 - All Rights Reserved      *
 *        For full copyright information see:'andrew/config/COPYRITE'     *
\* ********************************************************************** */

/*
	$Disclaimer: 
*Permission to use, copy, modify, and distribute this software and its 
*documentation for any purpose is hereby granted without fee, 
*provided that the above copyright notice appear in all copies and that 
*both that copyright notice, this permission notice, and the following 
*disclaimer appear in supporting documentation, and that the names of 
*IBM, Carnegie Mellon University, and other copyright holders, not be 
*used in advertising or publicity pertaining to distribution of the software 
*without specific, written prior permission.
*
*IBM, CARNEGIE MELLON UNIVERSITY, AND THE OTHER COPYRIGHT HOLDERS 
*DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 
*ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO EVENT 
*SHALL IBM, CARNEGIE MELLON UNIVERSITY, OR ANY OTHER COPYRIGHT HOLDER 
*BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY 
*DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 
*WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 
*ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
*OF THIS SOFTWARE.
* $
*/

/*
 * Copyright 1989, 1990, 1991 Jim Frost
 *
 * Permission to use, copy, modify, distribute, and sell this software
 * and its documentation for any purpose is hereby granted without fee,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.  The author makes no representations
 * about the suitability of this software for any purpose.  It is
 * provided "as is" without express or implied warranty.
 *
 * THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
 * USE OR PERFORMANCE OF THIS SOFTWARE.
 */

typedef unsigned long  Pixel;     /* what X thinks a pixel is */
typedef unsigned short Intensity; /* what X thinks an RGB intensity is */
typedef unsigned char  byte;      /* byte type */

typedef struct rgbmap {
  unsigned int  size;       /* size of RGB map */
  unsigned int  used;       /* number of colors used in RGB map */
  unsigned int  compressed; /* image uses colormap fully */
  Intensity    *red;        /* color values in X style */
  Intensity    *green;
  Intensity    *blue;
} RGBMap;

#define IBITMAP		0 /* image is a bitmap */
#define IGREYSCALE	1 /* image is 8-bit Greyscale */
#define IRGB		2 /* image is RGB */
#define ITRUE		3 /* image is true color */

#define NUM_IMAGE_TYPES 4

#define BITMAPP(self)		((self)->type == IBITMAP)
#define GREYSCALEP(self)	((self)->type == IGREYSCALE)
#define RGBP(self)		((self)->type == IRGB)
#define TRUEP(self)		((self)->type == ITRUE)

#define TRUE_RED(PIXVAL)   (((PIXVAL) & 0xff0000) >> 16)
#define TRUE_GREEN(PIXVAL) (((PIXVAL) & 0xff00) >> 8)
#define TRUE_BLUE(PIXVAL)  ((PIXVAL) & 0xff)
#define RGB_TO_TRUE(R,G,B)   ((((R) & 0xff00) << 8) | ((G) & 0xff00) | ((B) >> 8))

unsigned long doMemToVal();
unsigned long doValToMem();
unsigned long doMemToValLSB();
unsigned long doValToMemLSB();

/* special case 1-byte transfers so they're inline
 */

#define memToVal(PTR,LEN)    ((LEN) == 1 ? (unsigned long)(*(PTR)) : 			      doMemToVal(PTR,LEN))
#define memToValLSB(PTR,LEN) ((LEN) == 1 ? (unsigned long)(*(PTR)) : 			      doMemToValLSB(PTR,LEN))
#define valToMem(VAL,PTR,LEN)    ((LEN) == 1 ? 				  (unsigned long)(*(PTR) = (byte)(VAL)) : 				  doValToMem(VAL,PTR,LEN))
#define valToMemLSB(VAL,PTR,LEN) ((LEN) == 1 ? 				  (unsigned long)(*(PTR) = (byte)(VAL)) : 				  (int)doValToMemLSB(VAL,PTR,LEN))

/* this returns the (approximate) intensity of an RGB triple
 */

#define colorIntensity(R,G,B)   (RedIntensity[(R) >> 8] + GreenIntensity[(G) >> 8] + BlueIntensity[(B) >> 8])





#define image_NEW (1<<5)
#define image_CHANGED (1<<6)


/* 
 * End of information copied from image.ch.
 */ 
 
#endif /* class_StaticInfoOnly *//* 
 * Include the superclass information
 */ 
#define dontDefineRoutinesFor_dataobject
#include "dataobj.ih"
#undef dontDefineRoutinesFor_dataobject

 
 
#ifndef class_StaticInfoOnly
/* 
 * Data structure for image 
 */ 
struct image { 
    union {
	struct basicobject_methods *image_methods;
	struct traced traced;
	struct observable observable;
	struct dataobject dataobject;
    } header;
  unsigned int type;  /* type of image */
  RGBMap *rgb; /* RGB map of image if IRGB type */
  unsigned int width;  /* width of image in pixels */
  unsigned int height; /* height of image in pixels */
  unsigned int depth;  /* depth of image in bits if IRGB type */
  unsigned int pixlen; /* length of pixel (in bytes) if IRGB type */
  unsigned int bitsperpixel; /* length of pixel (in bits) if IRGB type */
  byte *data; /* data rounded to full byte for each row */
  boolean inited; /* has the image been transformed into an XImage? */
  int jpegSaveQuality;
  char *origData;
  long origDataSize;
  long lastModified;
  char *saveformatstring;

};

 
/* 
 * End of data structure for image.
 */ 
 

#endif /* class_StaticInfoOnly */

#ifndef class_StaticInfoOnly

#ifndef image_PROGRAMMERVERSION
#define image_PROGRAMMERVERSION 1
#endif /* image_PROGRAMMERVERSION */

#ifdef image_VERSION
#undef image_VERSION
#endif /* image_VERSION */
#define image_VERSION ((((image_PROGRAMMERVERSION << 16) ^ (52 << 8) ^ sizeof(struct image)) & 0x7ffff) + 0x80000 + (4 << 20))


#endif /* class_StaticInfoOnly */
#define image_StaticLoadOnlyThisClass()  \
{ extern struct classinfo *image__GetClassInfo(); \
 extern struct classheader *image_classheader_StaticExport; \
  (void) class_EnterInfo(NULL, image_classheader_StaticExport->name, image__GetClassInfo, NULL, image_classheader_StaticExport->namekey); } 
 
#define image_StaticLoad()  \
    { \
    dataobject_StaticLoad(); \
    image_StaticLoadOnlyThisClass();  \
    } 
 
#define image_StaticEntry  {image_StaticLoad()} 
 
#ifndef class_StaticInfoOnly
static struct classheader image_classheader = {
    image_VERSION,
    "image",
    "image",
    (struct basicobject_methods *) &class_RoutineStruct,
};

#define image_CLASSPROCEDURES (image_classheader.classprocedures)
int image_classref_;
#endif /* class_StaticInfoOnly */

#endif /* image_DEFINED */

#if !defined(image_ROUTINESDEFINED) && !defined(dontDefineRoutinesFor_image) && !defined(class_StaticEntriesOnly)
#define image_ROUTINESDEFINED

#define image_Reference(self) \
 (((&(self)->header.traced))->refcount++)
#define image_UnReference(self) \
 ((((&(self)->header.traced))->refcount>0)?((&(self)->header.traced))->refcount--:0)
#define image_ReferenceCount(self) \
 (((&(self)->header.traced))->refcount)
#define image_AddObserver(self,observer) \
    ((* ((void (*)())((self)->header.image_methods->routines[0]))) (self,observer))
#define image_IsObserver(self,observer) \
    ((* ((boolean (*)())((self)->header.image_methods->routines[1]))) (self,observer))
#define image_RemoveObserver(self,observer) \
    ((* ((void (*)())((self)->header.image_methods->routines[2]))) (self,observer))
#define image_NotifyObservers(self,value) \
    ((* ((void (*)())((self)->header.image_methods->routines[3]))) (self,value))
#define image_ObservedChanged(self,changed,value) \
    ((* ((void (*)())((self)->header.image_methods->routines[4]))) (self,changed,value))
#define image_AddRecipient(self,trigger,rcvr,func,rock) \
    ((* ((boolean (*)())((self)->header.image_methods->routines[5]))) (self,trigger,rcvr,func,rock))
#define image_DeleteRecipient(self,trigger,rcvr) \
    ((* ((void (*)())((self)->header.image_methods->routines[6]))) (self,trigger,rcvr))
#define image_PullTrigger(self,trigger) \
    ((* ((void (*)())((self)->header.image_methods->routines[7]))) (self,trigger))
#define image_DisableTrigger(self,trigger) \
    ((* ((void (*)())((self)->header.image_methods->routines[8]))) (self,trigger))
#define image_EnableTrigger(self,trigger) \
    ((* ((void (*)())((self)->header.image_methods->routines[9]))) (self,trigger))
#define image_DisableCount(self,trigger) \
    ((* ((long (*)())((self)->header.image_methods->routines[10]))) (self,trigger))
#define image_Read(self,file,id) \
    ((* ((long (*)())((self)->header.image_methods->routines[11]))) (self,file,id))
#define image_Write(self,file,writeid,level) \
    ((* ((long (*)())((self)->header.image_methods->routines[12]))) (self,file,writeid,level))
#define image_ReadOtherFormat(self,file,fmt,encoding,description) \
    ((* ((boolean (*)())((self)->header.image_methods->routines[13]))) (self,file,fmt,encoding,description))
#define image_WriteOtherFormat(self,file,writeid,level,usagetype,boundary) \
    ((* ((long (*)())((self)->header.image_methods->routines[14]))) (self,file,writeid,level,usagetype,boundary))
#define image_GetModified(self) \
    ((* ((long (*)())((self)->header.image_methods->routines[15]))) (self))
#define image_SetModified(self) \
    ((* ((void (*)())((self)->header.image_methods->routines[16]))) (self))
#define image_ViewName(self) \
    ((* ((char * (*)())((self)->header.image_methods->routines[17]))) (self))
#define image_SetAttributes(self,attributes) \
    ((* ((void (*)())((self)->header.image_methods->routines[18]))) (self,attributes))
#define image_Put(self,property,type,rock) \
    ((* ((void (*)())((self)->header.image_methods->routines[19]))) (self,property,type,rock))
#define image_Get(self,property,type,rock) \
    ((* ((short (*)())((self)->header.image_methods->routines[20]))) (self,property,type,rock))
#define image_ListCurrentViews(self,array,size) \
    ((* ((int (*)())((self)->header.image_methods->routines[21]))) (self,array,size))
#define image_RestoreModified(self,oldmodified) \
    ((* ((void (*)())((self)->header.image_methods->routines[22]))) (self,oldmodified))
#define image_UniqueID(self) \
 ((long)((&(self)->header.dataobject)))
#define image_GetWriteID(self) \
 ( ((&(self)->header.dataobject))->writeID )
#define image_SetWriteID(self,newValue) \
 ( (((&(self)->header.dataobject))->writeID) = (newValue) )
#define image_GetID(self) \
      ( ((&(self)->header.dataobject))->id )
#define image_SetID(self,newValue) \
      ( (((&(self)->header.dataobject))->id) = (newValue) )
#define image_Reset(self) \
    ((* ((void (*)())((self)->header.image_methods->routines[23]))) (self))
#define image_SetSaveFormatString(self,saveformat) \
    ((* ((void (*)())((self)->header.image_methods->routines[24]))) (self,saveformat))
#define image_newRGBMapData(self,size) \
    ((* ((void (*)())((self)->header.image_methods->routines[25]))) (self,size))
#define image_freeRGBMapData(self) \
    ((* ((void (*)())((self)->header.image_methods->routines[26]))) (self))
#define image_newBitImage(self,width,height) \
    ((* ((void (*)())((self)->header.image_methods->routines[27]))) (self,width,height))
#define image_newGreyImage(self,width,height,depth) \
    ((* ((void (*)())((self)->header.image_methods->routines[28]))) (self,width,height,depth))
#define image_newRGBImage(self,width,height,depth) \
    ((* ((void (*)())((self)->header.image_methods->routines[29]))) (self,width,height,depth))
#define image_newTrueImage(self,width,height) \
    ((* ((void (*)())((self)->header.image_methods->routines[30]))) (self,width,height))
#define image_freeImageData(self) \
    ((* ((void (*)())((self)->header.image_methods->routines[31]))) (self))
#define image_Dither(self) \
    ((* ((struct image * (*)())((self)->header.image_methods->routines[32]))) (self))
#define image_Brighten(self,percent) \
    ((* ((void (*)())((self)->header.image_methods->routines[33]))) (self,percent))
#define image_Normalize(self) \
    ((* ((struct image * (*)())((self)->header.image_methods->routines[34]))) (self))
#define image_Gray(self) \
    ((* ((void (*)())((self)->header.image_methods->routines[35]))) (self))
#define image_Bit2Grey(self) \
    ((* ((struct image * (*)())((self)->header.image_methods->routines[36]))) (self))
#define image_Compress(self) \
    ((* ((void (*)())((self)->header.image_methods->routines[37]))) (self))
#define image_Zoom(self,xzoom,yzoom) \
    ((* ((struct image * (*)())((self)->header.image_methods->routines[38]))) (self,xzoom,yzoom))
#define image_Reduce(self,n) \
    ((* ((struct image * (*)())((self)->header.image_methods->routines[39]))) (self,n))
#define image_Expand(self) \
    ((* ((struct image * (*)())((self)->header.image_methods->routines[40]))) (self))
#define image_GammaCorrect(self,disp_gam) \
    ((* ((void (*)())((self)->header.image_methods->routines[41]))) (self,disp_gam))
#define image_Halftone(self) \
    ((* ((struct image * (*)())((self)->header.image_methods->routines[42]))) (self))
#define image_Duplicate(self,target) \
    ((* ((void (*)())((self)->header.image_methods->routines[43]))) (self,target))
#define image_WriteNative(self,file,filename) \
    ((* ((long (*)())((self)->header.image_methods->routines[44]))) (self,file,filename))
#define image_SendBeginData(self,file,writeID,level) \
    ((* ((long (*)())((self)->header.image_methods->routines[45]))) (self,file,writeID,level))
#define image_SendImageData(self,file) \
    ((* ((long (*)())((self)->header.image_methods->routines[46]))) (self,file))
#define image_SendEndData(self,file,writeID,id) \
    ((* ((long (*)())((self)->header.image_methods->routines[47]))) (self,file,writeID,id))
#define image_GetBeginData(self,file,id) \
    ((* ((long (*)())((self)->header.image_methods->routines[48]))) (self,file,id))
#define image_GetImageData(self,file) \
    ((* ((long (*)())((self)->header.image_methods->routines[49]))) (self,file))
#define image_GetEndData(self,file,id) \
    ((* ((long (*)())((self)->header.image_methods->routines[50]))) (self,file,id))
#define image_Load(self,fullname,fp) \
    ((* ((int (*)())((self)->header.image_methods->routines[51]))) (self,fullname,fp))
#define image_Type(self) \
 (((self))->type)
#define image_Data(self) \
 (((self))->data)
#define image_Width(self) \
 (((self))->width)
#define image_Height(self) \
 (((self))->height)
#define image_Depth(self) \
 (((self))->depth)
#define image_Pixlen(self) \
 (((self))->pixlen)
#define image_BitsPerPixel(self) \
 (((self))->bitsperpixel)
#define image_RGBSize(self) \
 (((self))->rgb->size)
#define image_RGBUsed(self) \
 (((self))->rgb->used)
#define image_RedMap(self) \
 (((self))->rgb->red)
#define image_GreenMap(self) \
 (((self))->rgb->green)
#define image_BlueMap(self) \
 (((self))->rgb->blue)
#define image_RedPixel(self,redIndex) \
 (*(((self))->rgb->red + redIndex))
#define image_GreenPixel(self,greenIndex) \
 (*(((self))->rgb->green + greenIndex))
#define image_BluePixel(self,blueIndex) \
 (*(((self))->rgb->blue + blueIndex))
#define image_GetOriginX(self) \
 (0)
#define image_GetOriginY(self) \
 (0)
#define image_SetJPEGSaveQuality(self,q) \
 (((self))->jpegSaveQuality = (q))
#define image_GetJPEGSaveQuality(self) \
 (((self))->jpegSaveQuality)
#define image_SaveFormatString(self) \
 (((self))->saveformatstring)

#define image_NewFromObject(self) \
    ((* ((struct image * (*)())((self)->header.image_methods->info->procs->routines[0]))) (&image_classheader, (self)->header.image_methods->info->versionnumber))
#define image_New() \
    (*((struct image * (*)()) (image_CLASSPROCEDURES->routines[0])))(&image_classheader,image_VERSION)
#define image_Initialize(self) \
    (*((void (*)()) (image_CLASSPROCEDURES->routines[2])))(&image_classheader,self, image_VERSION)

#define image_Destroy(self) \
    ((* ((void (*)()) ((self)->header.image_methods->info->procs->routines[1]))) (&image_classheader, self))
#define image_Finalize(self) \
    (*((void (*)()) (image_CLASSPROCEDURES->routines[3])))(&image_classheader,self)

#define image_InitializeObject(self) \
    (*((boolean (*)()) (image_CLASSPROCEDURES->routines[5])))(&image_classheader,self)
#define image_FinalizeObject(self) \
    (*((void (*)()) (image_CLASSPROCEDURES->routines[6])))(&image_classheader,self)
#define image_InitializeClass() \
    (*((boolean (*)()) (image_CLASSPROCEDURES->routines[7])))(&image_classheader)
#define image_depthToColors(n) \
    (*((int (*)()) (image_CLASSPROCEDURES->routines[8])))(&image_classheader,n)
#define image_colorsToDepth(n) \
    (*((int (*)()) (image_CLASSPROCEDURES->routines[9])))(&image_classheader,n)


#endif /* !defined(image_ROUTINESDEFINED) && !defined(dontDefineRoutinesFor_image ) && !defined(class_StaticEntriesOnly)*/

