/* cii.h ** Copyright (C) 1990, 1993 by Xerox Corporation. All rights reserved. ** MFP, October 28, 1993 12:48:42 pm PDT ** ** Version CII-93-10-28 ** ** Caveats: ** Device creation procedures are not part of cii.h; see ciisetup.h. ** ** Changes since CII-93-07-01 ** New methods: ** CII_MakeSampledBlack ** CII_ApplyCCITTFacsimileDecompressionFilter ** CII_SetSeparation ** CII_SetOutputBuffers ** CII_SetColorTable ** Revised: ** CII_StrokeControlRep now has provisions for dashed strokes. ** ** Changes since CII-93-08-11 ** New methods: ** CII_MakeLookupTable ** CII_DestroyLookupTable ** CII_SetColorLookupTable ** CII_GetColorLookupTable ** CII_Sync ** ** Changes since CII-93-09-21 ** The comments to GetMatrix and GetInitialMatrix were made more ** specific about the the result of GetMatrix on a newly-created ** handle. ** ** Changes since CII-93-09-28 ** New methods: ** CII_RegisterCleanupObject ** CII_UnRegisterCleanupObject ** CII_SetInitialMatrix ** */ #ifndef cii_h #define cii_h /********************************************************************** ** CII_RES: TYPE ** ** ** ** Error Codes ** **********************************************************************/ typedef enum { CII_RES_ok = 0, CII_RES_bounds = 1001, CII_RES_overflow = 1002, CII_RES_zeroDivide = 1003, CII_RES_nilFault = 1004, CII_RES_insufficientMemory = 1005, CII_RES_ioError = 1006, CII_RES_timeout = 1007, CII_RES_eof = 1008, CII_RES_numericalInstability = 1009, CII_RES_bug = 1010, CII_RES_fileNotFound = 1020, CII_RES_colorModelOperatorNotFound = 1021, CII_RES_colorOperatorNotFound = 1022, CII_RES_colorNotFound = 1023, CII_RES_decompressorNotFound = 1024, CII_RES_fontNotFound = 1025, CII_RES_operatorNotFound = 1026, CII_RES_resourceNotFound = 1027, CII_RES_accessError = 1028, CII_RES_syntax = 1040, CII_RES_undefinedOperation = 1041, CII_RES_invalidCompressedSequence = 1042, CII_RES_malformedFont = 1043, CII_RES_invalidEncoding = 1044, CII_RES_invalidHeader = 1045, CII_RES_invalidIdentifier = 1046, CII_RES_invalidInstructionProperty = 1047, CII_RES_invalidName = 1048, CII_RES_invalidString = 1049, CII_RES_invalidToner = 1050, CII_RES_invalidVersion = 1051, CII_RES_nullValue = 1060, CII_RES_illegalAlternateMetrics = 1061, CII_RES_illegalColor = 1062, CII_RES_unknownSpecialColor = 1063, CII_RES_unknownSignalType = 1064, CII_RES_wrongShape = 1065, CII_RES_wrongSize = 1066, CII_RES_notCardinal = 1067, CII_RES_notInteger = 1068, CII_RES_notNumber = 1069, CII_RES_wrongType = 1070, CII_RES_noFont = 1071, CII_RES_illegalArguments = 1072, CII_RES_illegalTransformation = 1073, CII_RES_illegalPixelMask = 1074, CII_RES_illegalPropertyVector = 1075, CII_RES_illegalRunVector = 1076, CII_RES_undefinedProperty = 1077, CII_RES_stackOverflow = 1080, CII_RES_stackUnderflow = 1081, CII_RES_saveRestoreMismatch = 1082, CII_RES_markMismatch = 1083, CII_RES_unmarkFailed = 1084, CII_RES_invalidOperationSequence = 1085, CII_RES_obsoleteConstruct = 1100, CII_RES_unsupportedColorOperator = 1101, CII_RES_notImplemented = 1102, CII_RES_unimplemented = 1103, CII_RES_squareEndOnStrokeOfZeroLength = 1120, CII_RES_unableToProperlyAdjustMaskPositions = 1121, CII_RES_noSubstituteColor = 1122, CII_RES_fontSubstitution = 1123, CII_RES_appearance = 1124, CII_RES_error = 1140, CII_RES_copySensitive = 1160 } CII_RES; /********************************************************************** ** CII_Handle: TYPE ** ** ** ** This is the primary object for the imaging operations; most of ** ** this interface is concerned with the methods belonging to this ** ** kind of object. ** **********************************************************************/ typedef struct CII_ObjectRep * CII_Handle; /********************************************************************** ** CII_Destroy: METHOD ** ** ** ** Should be called exactly once on each CII_Handle created. ** ** Prior to handle destruction, each of the registered ** ** CleanupObjects is notified - see the RegisterCleanupObject ** ** method for details. ** **********************************************************************/ #define CII_Destroy(h) \ (((h)->Destroy)(h)) typedef CII_RES PROC_CII_Destroy(CII_Handle h); /********************************************************************** ** CII_Boolean: TYPE ** ** ** ** A Boolean: 0 => FALSE, 1 => TRUE ** **********************************************************************/ typedef int CII_Boolean; /********************************************************************** ** CII_Scaled: TYPE ** ** ** ** A fixed point number, scaled by 2**16 ** **********************************************************************/ typedef long int CII_Scaled; /********************************************************************** ** CII_RectangleRep: TYPE ** ** ** ** Explicit representation of a rectangle ** ** In client coordinates. ** ** (x,y) is one corner. ** ** w is the width, in the x direction. ** ** h is the height, in the y direction. ** ** w and/or h may be negative. ** **********************************************************************/ typedef struct CII_RectangleRep {float x, y, w, h;} CII_RectangleRep; /********************************************************************** ** CII_VectorRep: TYPE ** ** ** ** Explicit representation of a point or vector ** ** In client coordinates. ** **********************************************************************/ typedef struct CII_VectorRep {float x, y;} CII_VectorRep; /********************************************************************** ** CII_Color: TYPE ** ** ** ** Represents a color. ** ** Details are opaque to the client. These objects are ** ** heap-allocated, and so may be stored in persistent data ** ** structures. ** **********************************************************************/ typedef struct {int opaque;} *CII_Color; /********************************************************************** ** CII_DestroyColor: METHOD ** ** ** ** Should be called exactly once for each CII_Color returned to ** ** the client, after after which the client should not use the ** ** object again. The handle must be the same handle used to ** ** create the CII_Color. ** **********************************************************************/ #define CII_DestroyColor(h, color) \ (((h)->DestroyColor)(h, color)) typedef CII_RES PROC_CII_DestroyColor( CII_Handle h, CII_Color color ); /********************************************************************** ** CII_ColorOperator: TYPE ** ** ** ** Represents a color operator, which maps pixel values (tuples of ** ** numbers) into colors. ** ** Details are opaque to the client. These objects are ** ** heap-allocated, and so may be stored in persistent data ** ** structures. ** **********************************************************************/ typedef struct {int opaque;} *CII_ColorOperator; /********************************************************************** ** CII_DestroyColorOperator: METHOD ** ** ** ** Should be called exactly once for each CII_ColorOperator ** ** returned to the client, after after which the client should not ** ** use the object again. The handle must be the same handle used ** ** to create the CII_ColorOperator. ** **********************************************************************/ #define CII_DestroyColorOperator(h, colorOperator) \ (((h)->DestroyColorOperator)(h, colorOperator)) typedef CII_RES PROC_CII_DestroyColorOperator( CII_Handle h, CII_ColorOperator colorOperator ); /********************************************************************** ** CII_SampleRange: TYPE ** ** ** ** Used as a parameter to the color operator creation procs, ** ** declares the interval over which the signal values may range, ** ** and what the sense is. The signal values are the result of the ** ** samples after being processed through the lookup tables, if any. ** **********************************************************************/ typedef struct CII_SampleRange { float sWhite; /* input value corresponding to white */ float sBlack; /* input value for max density */ } CII_SampleRange; /********************************************************************** ** CII_Clipper: TYPE ** ** ** ** Represents a clipping region. ** ** Details are opaque to the client. These objects are ** ** heap-allocated, and so may be stored in persistent data ** ** structures. ** **********************************************************************/ typedef struct {int opaque;} *CII_Clipper; /********************************************************************** ** CII_DestroyClipper: METHOD ** ** ** ** Should be called exactly once for each CII_Clipper returned to ** ** the client, after after which the client should not use the ** ** object again. The handle must be the same handle used to ** ** create the CII_Clipper. ** **********************************************************************/ #define CII_DestroyClipper(h, clipper) \ (((h)->DestroyClipper)(h, clipper)) typedef CII_RES PROC_CII_DestroyClipper( CII_Handle h, CII_Clipper clipper ); /********************************************************************** ** CII_Font: TYPE ** ** ** ** Represents a font. ** ** Details are opaque to the client. These objects are ** ** heap-allocated, and so may be stored in persistent data ** ** structures. ** **********************************************************************/ typedef struct {int opaque;} *CII_Font; /********************************************************************** ** CII_DestroyFont: METHOD ** ** ** ** Should be called exactly once for each CII_Font returned to the ** ** client, after after which the client should not use the object ** ** again. The handle must be the same handle used to create the ** ** CII_Font. ** **********************************************************************/ #define CII_DestroyFont(h, font) \ (((h)->DestroyFont)(h, font)) typedef CII_RES PROC_CII_DestroyFont( CII_Handle h, CII_Font font ); /********************************************************************** ** CII_FillType: TYPE ** ** ** ** Specifies the fill rule. ** **********************************************************************/ typedef enum { CII_NONZERO_FILL, /* Use non-zero winding-number fill rule */ CII_EO_FILL /* Use even/odd winding-number fill rule */ } CII_FillType; /********************************************************************** ** CII_RasterRep: TYPE ** ** ** ** Describes the layout of a raster in memory ** **********************************************************************/ typedef struct CII_RasterRep { int sMinBox; /* box.min.s */ int fMinBox; /* box.min.f */ int sMaxBox; /* box.max.s */ int fMaxBox; /* box.max.f */ unsigned bitsPerSample; /* number of bits per sample */ unsigned bitsPerLine; /* number of bits per scan line */ long* basePointer; /* word pointer to data area */ unsigned bitIndex; /* index of first bit of data */ void* ref; /* for retaining collectible storage */ } CII_RasterRep; /********************************************************************** ** CII_SetMatrix: METHOD ** ** ** ** Sets the client-to-device transformation. ** **********************************************************************/ #define CII_SetMatrix(h, matrix) \ (((h)->SetMatrix)(h, matrix)) typedef CII_RES PROC_CII_SetMatrix( CII_Handle h, float matrix[] ); /********************************************************************** ** CII_GetMatrix: METHOD ** ** ** ** Gets the client-to-device transformation. For a newly-created ** ** handle, this will be the identity matrix. ** **********************************************************************/ #define CII_GetMatrix(h, matrixResult) \ (((h)->GetMatrix)(h, matrixResult)) typedef CII_RES PROC_CII_GetMatrix( CII_Handle h, float matrixResult[] ); /********************************************************************** ** CII_GetInitialMatrix: METHOD ** ** ** ** Gets the client-to-device transformation that maps the standard ** ** initial page coordinate system to device space, taking into ** ** account the resolution and scan direction of the device. Units ** ** are inch/72, as for PostScript(TM). Note that this is not the ** ** matrix that is current for a newly-created handle. ** **********************************************************************/ #define CII_GetInitialMatrix(h, matrixResult) \ (((h)->GetInitialMatrix)(h, matrixResult)) typedef CII_RES PROC_CII_GetInitialMatrix( CII_Handle h, float matrixResult[] ); /********************************************************************** ** CII_SetInitialMatrix: METHOD ** ** ** ** Sets the value to be returned by CII_GetInitialMatrix. This ** ** may be used reflect changes to the effective resolution, ** ** origin, and orientation. Note that the value of the initial ** ** matrix does not have any effect on the CII imaging methods, but ** ** rather is for the benefit of the client. ** **********************************************************************/ #define CII_SetInitialMatrix(h, matrix) \ (((h)->SetInitialMatrix)(h, matrix)) typedef CII_RES PROC_CII_SetInitialMatrix( CII_Handle h, float matrix[] ); /********************************************************************** ** CII_MakeGrayColorOperator: METHOD ** ** ** ** Makes a gray color operator ** **********************************************************************/ #define CII_MakeGrayColorOperator(a, b, c, d, e) \ (((a)->MakeGrayColorOperator)(a, b, c, d, e)) typedef CII_RES PROC_CII_MakeGrayColorOperator( CII_Handle h, CII_SampleRange* sampleRange, unsigned int sampleTableSize, float sampleTable[], CII_ColorOperator* colorOperatorResult ); /********************************************************************** ** CII_MakeRGBColorOperator: METHOD ** ** ** ** Makes a RGB color operator ** **********************************************************************/ #define CII_MakeRGBColorOperator(a, b, c, d, e, f, g) \ (((a)->MakeRGBColorOperator)(a, b, c, d, e, f, g)) typedef CII_RES PROC_CII_MakeRGBColorOperator( CII_Handle h, CII_SampleRange* sampleRange, unsigned int sampleTableSize, float sampleTableR[], float sampleTableG[], float sampleTableB[], CII_ColorOperator* colorOperatorResult ); /********************************************************************** ** CII_MakeCMYKColorOperator: METHOD ** ** ** ** Makes a CMYK color operator ** **********************************************************************/ #define CII_MakeCMYKColorOperator(a, b, c, d, e, f, g, h) \ (((a)->MakeCMYKColorOperator)(a, b, c, d, e, f, g, h)) typedef CII_RES PROC_CII_MakeCMYKColorOperator( CII_Handle h, CII_SampleRange* sampleRange, unsigned int sampleTableSize, float sampleTableC[], float sampleTableM[], float sampleTableY[], float sampleTableK[], CII_ColorOperator* colorOperatorResult ); /********************************************************************** ** CII_MakeHighlightColorOperator: METHOD ** ** ** ** Makes a Highlight color operator ** **********************************************************************/ #define CII_MakeHighlightColorOperator(a, b, c, d, e, f, g, h) \ (((a)->MakeHighlightColorOperator)(a, b, c, d, e, f, g, h)) typedef CII_RES PROC_CII_MakeHighlightColorOperator( CII_Handle h, CII_SampleRange* sampleRange, CII_Color baseColor, CII_Color highlightColor, unsigned int sampleTableSize, float sampleTableBaseColor[], float sampleTableHighlightColor[], CII_ColorOperator* colorOperatorResult ); /********************************************************************** ** CII_MakeColor: METHOD ** ** ** ** Creates a color by applying a color operator to a tuple of ** ** sample values. The samplesPerPixel parameter is present as an ** ** error check against the samplesPerPixel of the color operator ** **********************************************************************/ #define CII_MakeColor(h, colorOperator, samplesPerPixel, pixel, colorResult) \ (((h)->MakeColor)(h, colorOperator, samplesPerPixel, pixel, colorResult)) typedef CII_RES PROC_CII_MakeColor( CII_Handle h, CII_ColorOperator colorOperator, unsigned int samplesPerPixel, float pixel[], CII_Color* colorResult ); /********************************************************************** ** CII_MakeSampledBlack: METHOD ** ** ** ** Creates a color that consists of a black-and-white or ** ** black-and-clear pattern that is replicated as necessary to fill ** ** the entire mask area. The provided raster must have one bit ** ** per sample. The '1' bits specify black, and the '0' bits ** ** specify white or clear, depending on the 'clear' parameter. ** ** The transformation matrix maps the [s, f] coordinates of the ** ** source bitmap to the [s, f] device coordinates; the current ** ** matrix has no effect on the way the color is created. ** ** Note: If the tiling effect is not needed, it is normally ** ** preferable to use MaskBitmap (with a clipping region, if ** ** required). ** **********************************************************************/ #define CII_MakeSampledBlack(h, bitmap, pixelToDevice, clear, colorResult) \ (((h)->MakeSampledBlack)(h, bitmap, pixelToDevice, clear, colorResult)) typedef CII_RES PROC_CII_MakeSampledBlack( CII_Handle h, CII_RasterRep* bitmap, float pixelToDevice[], CII_Boolean clear, CII_Color* colorResult ); /********************************************************************** ** CII_SetColor: METHOD ** ** ** ** Sets the current color ** **********************************************************************/ #define CII_SetColor(h, color) \ (((h)->SetColor)(h, color)) typedef CII_RES PROC_CII_SetColor( CII_Handle h, CII_Color color ); /********************************************************************** ** CII_SetGray: METHOD ** ** ** ** Convenience proc to set gray; 0=>black, 1=>white ** **********************************************************************/ #define CII_SetGray(h, gray) \ (((h)->SetGray)(h, gray)) typedef CII_RES PROC_CII_SetGray( CII_Handle h, float* gray ); /********************************************************************** ** CII_SetRGB: METHOD ** ** ** ** convenience proc to set rgb color; 0=>black, 1=>full primary ** **********************************************************************/ #define CII_SetRGB(h, rgb) \ (((h)->SetRGB)(h, rgb)) typedef CII_RES PROC_CII_SetRGB( CII_Handle h, float rgb[] ); /********************************************************************** ** CII_SetHSV: METHOD ** ** ** ** convenience proc to set hsv color ** **********************************************************************/ #define CII_SetHSV(h, hsv) \ (((h)->SetHSV)(h, hsv)) typedef CII_RES PROC_CII_SetHSV( CII_Handle h, float hsv[] ); /********************************************************************** ** CII_SetCMYK: METHOD ** ** ** ** convenience proc to set cmyk color ** **********************************************************************/ #define CII_SetCMYK(h, cmyk) \ (((h)->SetCMYK)(h, cmyk)) typedef CII_RES PROC_CII_SetCMYK( CII_Handle h, float cmyk[] ); /********************************************************************** ** CII_GetColor: METHOD ** ** ** ** Gets the current color ** **********************************************************************/ #define CII_GetColor(h, colorResult) \ (((h)->GetColor)(h, colorResult)) typedef CII_RES PROC_CII_GetColor( CII_Handle h, CII_Color* colorResult ); /********************************************************************** ** CII_MaskRectangle: METHOD ** ** ** ** Masks a rectangle. ** ** Uses the current matrix, color, and clipping region ** **********************************************************************/ #define CII_MaskRectangle(h, rect) \ (((h)->MaskRectangle)(h, rect)) typedef CII_RES PROC_CII_MaskRectangle( CII_Handle h, CII_RectangleRep* rect ); /********************************************************************** ** CII_PathSink: TYPE ** ** ** ** Pointer to private information to be supplied to MoveTo, ** ** LineTo, CurveTo, and ConicTo. Normally the referent is ** ** stack-allocated; so don't retain this pointer when the path ** ** generator is done. ** **********************************************************************/ typedef struct CII_PathSinkObjectRep *CII_PathSink; /********************************************************************** ** CII_PathGenerator: TYPE ** ** ** ** An abstract, procedural representation of a path ** **********************************************************************/ typedef struct CII_PathGeneratorObjectRep *CII_PathGenerator; /********************************************************************** ** CII_GeneratePath: METHOD ** ** ** ** Invokes the PathGenerator into a PathSink ** **********************************************************************/ #define CII_GeneratePath(self, sink) \ (((self)->GeneratePath)(self, sink)) typedef CII_RES PROC_CII_GeneratePath( CII_PathGenerator self, CII_PathSink sink ); /********************************************************************** ** CII_MoveTo: METHOD ** ** ** ** begins a new trajectory at the point p; p0 := p ** **********************************************************************/ #define CII_MoveTo(sink, p) \ (((sink)->MoveTo)(sink, p)) typedef CII_RES PROC_CII_MoveTo( CII_PathSink sink, CII_VectorRep* p ); /********************************************************************** ** CII_LineTo: METHOD ** ** ** ** extends a straight line from p0 to p; p0 := p ** **********************************************************************/ #define CII_LineTo(sink, p) \ (((sink)->LineTo)(sink, p)) typedef CII_RES PROC_CII_LineTo( CII_PathSink sink, CII_VectorRep* p ); /********************************************************************** ** CII_CurveTo: METHOD ** ** ** ** extends a cubic curve from p0 (controlled by p[0], p[1]) to ** ** p[2]; p0 := p[2] ** **********************************************************************/ #define CII_CurveTo(sink, p) \ (((sink)->CurveTo)(sink, p)) typedef CII_RES PROC_CII_CurveTo( CII_PathSink sink, CII_VectorRep p[] ); /********************************************************************** ** CII_ConicControlRep: TYPE ** ** ** ** Control parameters for a conic piece ** **********************************************************************/ typedef struct CII_ConicControlRep { CII_VectorRep p1, p2; float s; } CII_ConicControlRep; /********************************************************************** ** CII_ConicTo: METHOD ** ** ** ** extends a conic curve from p0 (controlled by p1, s) to p2; p0 ** ** := p2 ** **********************************************************************/ #define CII_ConicTo(sink, c) \ (((sink)->ConicTo)(sink, c)) typedef CII_RES PROC_CII_ConicTo( CII_PathSink sink, CII_ConicControlRep* c ); /********************************************************************** ** CII_MaskFill: METHOD ** ** ** ** For filling an area specified by a path. ** **********************************************************************/ #define CII_MaskFill(h, pathGenerator, fillType) \ (((h)->MaskFill)(h, pathGenerator, fillType)) typedef CII_RES PROC_CII_MaskFill( CII_Handle h, CII_PathGenerator pathGenerator, CII_FillType fillType ); /********************************************************************** ** CII_Clip: METHOD ** ** ** ** Replaces the current clipping region with its intersection with ** ** the specified area ** **********************************************************************/ #define CII_Clip(h, pathGenerator, fillType) \ (((h)->Clip)(h, pathGenerator, fillType)) typedef CII_RES PROC_CII_Clip( CII_Handle h, CII_PathGenerator pathGenerator, CII_FillType fillType ); /********************************************************************** ** CII_GetClipper: METHOD ** ** ** ** Gets the current clipping region. ** **********************************************************************/ #define CII_GetClipper(h, clipperResult) \ (((h)->GetClipper)(h, clipperResult)) typedef CII_RES PROC_CII_GetClipper( CII_Handle h, CII_Clipper* clipperResult ); /********************************************************************** ** CII_SetClipper: METHOD ** ** ** ** Sets the current clipping region. ** **********************************************************************/ #define CII_SetClipper(h, clipper) \ (((h)->SetClipper)(h, clipper)) typedef CII_RES PROC_CII_SetClipper( CII_Handle h, CII_Clipper clipper ); /********************************************************************** ** CII_BuildClipperBegin: METHOD ** ** ** ** The sequence of calls ** ** CII_BuildClipperBegin(h); ** ** CII_MaskXXX(h, ...); ** ** ... ** ** CII_BuildClipperEnd(h); ** ** may be used to modify the clipping region by means of any of ** ** the masking operations. The area marked by these mask ** ** operations will be intersected with the active clipping region; ** ** if it is desired to totally replace the clipper, do ** ** CII_SetClipper(h, NIL); ** ** prior to the above sequence. ** ** The BuildClipperBegin / BuildClipperEnd sequence may not be ** ** nested. ** **********************************************************************/ #define CII_BuildClipperBegin(h) \ (((h)->BuildClipperBegin)(h)) typedef CII_RES PROC_CII_BuildClipperBegin(CII_Handle h); /********************************************************************** ** CII_BuildClipperEnd: METHOD ** ** ** ** See CII_BuildClipperBegin, above. ** **********************************************************************/ #define CII_BuildClipperEnd(h) \ (((h)->BuildClipperEnd)(h)) typedef CII_RES PROC_CII_BuildClipperEnd(CII_Handle h); /********************************************************************** ** CII_StrokeType: TYPE ** ** ** ** For controlling closed strokes ** **********************************************************************/ typedef enum {CII_OPEN_STROKE, CII_CLOSED_STROKE} CII_StrokeType; /********************************************************************** ** CII_EndType: TYPE ** ** ** ** End treatment for strokes ** **********************************************************************/ typedef enum { CII_SQUARE_END, CII_BUTT_END, CII_ROUND_END, CII_TRIANGULAR_END } CII_EndType; /********************************************************************** ** CII_JointType: TYPE ** ** ** ** Joint treatment for strokes ** **********************************************************************/ typedef enum { CII_MITER_JOINT, CII_BEVEL_JOINT, CII_ROUND_JOINT, CII_TRIANGULAR_JOINT, CII_NO_JOINT, CII_MITERCLIP_JOINT, CII_MITERBEVEL_JOINT } CII_JointType; /********************************************************************** ** CII_StrokeControlRep: TYPE ** ** ** ** Collected stroke control. ** ** For a normal (non-dashed) stroke, dashCount is 0. For a dashed ** ** stroke, dashCount is the number of elements in the dash pattern ** ** arry, dashArray. The dashArray elements are given in ** ** user-space units, and are used cyclicly to indicate the lengths ** ** of the on ond off sections of the stroke. These elements must ** ** be non-negative, and not all zero. ** ** The value of dashOffset indicates (in user-space units) where ** ** to start the pattern. ** ** If dashCorrectLength is positive, the dashArray values (and the ** ** offset value) are effectively multiplied by the ratio ** ** dashComputedLength/dashCorrectLength, ** ** where dashComputedLength is the length of the path, in user ** ** coordinates, as computed by the imager. This allows the client ** ** to have control over the number and ending state of the dashes ** ** without needing to use exactly the same length approximations ** ** as the imager does. ** ** The setting of strokeAdjust controls the way strokes are ** ** rendered; use 0 (FALSE) to get inferior quality. ** ** thickening is in device space and can be negative ** ** (i.e. thinning is OK) ** ** minThickness is in device space and should be non-negative. ** ** A CII_StrokeControlRep should be initialized with the value ** ** CII_INITIALSTROKECONTROL, the stamp value is used to help ** ** ensure that the fields have all been properly set up. ** **********************************************************************/ typedef struct CII_StrokeControlRep { CII_StrokeType strokeType; CII_EndType end; CII_JointType joint; float miterLimit; float strokeWidth; int dashCount; float* dashArray; float dashOffset; float dashCorrectLength; CII_Boolean strokeAdjust; CII_VectorRep thickening; CII_VectorRep minThickness; int stamp; } CII_StrokeControlRep; #define CII_INITIALSTROKECONTROL \ {0, CII_SQUARE_END, CII_MITER_JOINT, 0.0, 0.0, 0, (float*)0, \ 0.0, 0.0, 1, {0.0, 0.0}, {0.0, 0.0}, 6218} /********************************************************************** ** CII_MaskStroke: METHOD ** ** ** ** Masks a stroke ** **********************************************************************/ #define CII_MaskStroke(h, pathGenerator, s) \ (((h)->MaskStroke)(h, pathGenerator, s)) typedef CII_RES PROC_CII_MaskStroke( CII_Handle h, CII_PathGenerator pathGenerator, CII_StrokeControlRep* s ); /********************************************************************** ** CII_MaskBitmap: METHOD ** ** ** ** Uses a bitmap as a mask. The raster provided should be 1 bit ** ** per pixel. The current transformation matrix is used to ** ** specify the mapping of the [s, f] source coordinate system to ** ** the device coordinate system. The current color fills the ** ** portions of the output image that correspond with the '1' bits. ** ** In most cases, the background color will be NIL, which means ** ** the '0' bits are clear, and this acts like a true masking ** ** operation. However, if the background color is not NIL, it ** ** will be used to fill the portions of the output image that ** ** correspond with the '0' bits of the source. ** **********************************************************************/ #define CII_MaskBitmap(h, raster, background) \ (((h)->MaskBitmap)(h, raster, background)) typedef CII_RES PROC_CII_MaskBitmap( CII_Handle h, CII_RasterRep* raster, CII_Color background ); /********************************************************************** ** CII_MaskDeviceTrapezoid: METHOD ** ** ** ** Masks a trapezoid, expressed in device coordinates. This ** ** operation ignores the clipping region, as well as the clipper, ** ** so it is up to the client to make sure that the trapezoid has ** ** been properly transformed and clipped. The interpretation of ** ** the parameters is as follows: ** ** sMin, fMin, sMax, fMax: these express the bounding box of the ** ** trapezoid; they are integers in device space and therefore ** ** demarcate the boundaries of pixels. Only pixels inside ** ** this box will be affected by the mask. ** ** f0, df0: these express the starting location and slope of one ** ** of the trapezoid's sides. These are both fixed-point ** ** representations of rational numbers, with a scale factor of ** ** 65536 (2**16). The value of f0 is the point at which the ** ** side intersects the line of constant s value (sMin+0.5). ** ** The corresponding values for successive lines are obtained ** ** by adding df0 to the previous line's value. ** ** f1, df1: these are like f0 and df0, but for the opposite side. ** ** It is permitted for the two sides of the trapezoid to ** ** cross, and for the sides to extend beyond the sides of the ** ** bounding box; in the latter case the mask will be clipped ** ** by the bounding box. The mask includes precisely those ** ** pixel areas [s..s+1) X [f..f+1) such that ** ** (sMin <= s < sMax) and (fMin <= f < fMax) and ( ** ** (f0+(s-sMin)*df0) <= C*(f+0.5) < (f1+(s-sMin)*df1) or ** ** (f1+(s-sMin)*df1) <= C*(f+0.5) < (f0+(s-sMin)*df0)), ** ** where C is the scale factor (2**16). ** ** As described thus far, the trapezoid is filled using a ** ** point-sampled, pixel-center rule. To get the effect of ** ** including any pixel touched by the trapezoid, consistent with ** ** section 6.5.1 of the PLRM(2nd ed) the client may do the ** ** following: ** ** 1. If necessary, subdivide the original trapezoid to ** ** eliminate crossing sides. This step may not be needed ** ** if the source of the trapezoids is guaranteed never to ** ** create such beasts. ** ** 2. Use the floor function to calculate sMin and fMin, and ** ** the ceiling function to calculate sMax and fMax, rather ** ** than rounding. ** ** 3. Sort the sides so that the f value for side 0 does not ** ** exceed the f value for side 1; this makes sense by ** ** virtue of step 1, which eliminated crossings. ** ** 4. The calculation of df0 and df1 stay the same, since the ** ** slope of the sides does not change when you offset them. ** ** However, before the calculation of f0 as the ** ** intersection of side 0 with the (sMin+0.5) line, offset ** ** the side 0 line by (ds, df) = (-0.5, -0.5) if df0 < 0, ** ** or by (0.5, -0.5) if df0 > 0 (if df0 = 0, both offsets ** ** give the same answer). Similarly, offset side 1 by ** ** (0.5, 0.5) if df1 < 0, or by (-0.5, 0.5) otherwise; ** ** additionally, f1 should be decreased by 1 after ** ** conversion to scaled form. ** **********************************************************************/ #define CII_MaskDeviceTrapezoid(h, sMin, fMin, sMax, fMax, f0, df0, f1, df1) \ (((h)->MaskDeviceTrapezoid)(h, sMin, fMin, sMax, fMax, f0, df0, f1, df1)) typedef CII_RES PROC_CII_MaskDeviceTrapezoid( CII_Handle h, int sMin, int fMin, int sMax, int fMax, CII_Scaled f0, CII_Scaled df0, CII_Scaled f1, CII_Scaled df1 ); /********************************************************************** ** CII_MaskProgram: TYPE ** ** ** ** Represents a 'compiled' version of a little program for ** ** generating device masks. See MakeMaskProgram and ** ** MaskDeviceBoxes, below. ** ** Details are opaque to the client. These objects are ** ** heap-allocated, and so may be stored in persistent data ** ** structures. ** **********************************************************************/ typedef struct {int opaque;} *CII_MaskProgram; /********************************************************************** ** CII_DestroyMaskProgram: METHOD ** ** ** ** Should be called exactly once for each CII_MaskProgram returned ** ** to the client, after after which the client should not use the ** ** object again. The handle must be the same handle used to ** ** create the CII_MaskProgram. ** **********************************************************************/ #define CII_DestroyMaskProgram(h, maskProgram) \ (((h)->DestroyMaskProgram)(h, maskProgram)) typedef CII_RES PROC_CII_DestroyMaskProgram( CII_Handle h, CII_MaskProgram maskProgram ); /********************************************************************** ** CII_MakeMaskProgram: METHOD ** ** ** ** Various CII clients may choose to represent mask data in ** ** various forms, differing in detail, but all representing mask ** ** data in device coordinates. To deal effectively with this ** ** diversity, CII allows device-resolution mask data to be stored ** ** in a form driven by the client, and accepts a little program ** ** that knows how to decode the data into device-boxes. This ** ** program is provided in the form of an ascii string, using the ** ** little language we define here. The CII implementation may ** ** work by (a) interpreting the string, by (b) recognizing special ** ** cases, or even by (c) compiling it into a small ** ** machine-language program. So that any such processing need be ** ** done only once, the CII_MakeMaskProgram is a separate call from ** ** CII_MaskDeviceBoxes. ** ** The machine model for this little programming language is as ** ** follows: ** ** There is one accumulator and ten registers, each 32 bits wide. ** ** Registers 0, 1, 2, and 3 have a special meaning, as follows: ** ** 0 - sMin ** ** 1 - fMin ** ** 2 - sMax ** ** 3 - fMax ** ** These assigned registers are used to communicate the resulting ** ** device boxes out of the program, via the E instruction; they ** ** are also initialized to be the clipping box that is passed to ** ** CII_MaskDeviceBoxes. The accumulator and the other registers ** ** are initialized to zero. ** ** For input to the program, there is (conceptually) a stream of ** ** input bytes; for CII_MaskDeviceBoxes, this data comes from ** ** consecutive memory locations. The value of bigEndian ** ** determines the order with which the bytes are fetched. The ** ** program should respect alignment - the data for F2 and F4 must ** ** occur on 2-byte and 4-byte boundaries, respectively, and the ** ** maskData pointer should be aligned on a word boundary. A ** ** program that needs to deal with unaligned data must assemble ** ** the bytes itself. ** ** The instructions in the program string are each one or two ** ** characters long. In the following description, k is a single ** ** decimal digit, and denotes a register number, and A denotes the ** ** accumulator. ** ** { start loop ** ** } end loop ** ** Lk load var k into A ** ** Sk store accum into var k ** ** +k Add var k to A ** ** -k Subtract var k from A ** ** ^k Shift (unsigned) A by (signed) count in register k ** ** X exit loop if A is zero ** ** ~ ** ** F1 F2 F4 - fetch 1, 2, or 4 bytes into A, bump src pointer ** ** W1 W2 - fetch 1 or 2 bytes, unsigned, into A, bump src ** ** pointer ** ** = clear A ** ** 0 .. 7 - multiply A by 8 and add digit value. ** ** E emit a box (in registers 0 to 3) ** ** The program string is terminated by a null. No white space is ** ** allowed. The storage for the program string may be re-used ** ** after the MakeMaskProgram call is complete. ** ** The shift command multiplies by 2**k, dropping any bits that ** ** fall off either end of the word. ** ** This is codeVersion 1; this value should be explicitly coded ** ** with the program string, rather than symbolically, so that may ** ** be updated when the program string is updated. ** ** The program execution terminates when the end is reached, or ** ** when a fetch is attempted and there is no further data. ** ** As a simple example, the following program decodes a simple ** ** run-length encoding of a monotone region, consisting of a ** ** sequence of halfwords that give the start and length of the box ** ** on each scanline, with the start relative to the initial fMin: ** ** L1S4L2S5{L0-5XW2+4S1W2+1S3=1+0S2ES0} ** ** Breaking this down, we get: ** ** L1S4 save the initial fMin in register 4 ** ** L2S5 save the initial sMax in register 5 ** ** {L0-5X while sMin ~= sMaxInitial do ** ** W2+4S1 fMin := fetch2()+fMinInitial ** ** W2+1S3 fMax := fetch2()+fMin ** ** =1+0S2 sMax := sMin+1 ** ** E emit(sMin, fMin, sMax, fMax) ** ** S0 sMin := sMin+1 ** ** } end ** ** ** ** Notes: ** ** Loops may be nested. ** ** A simple conditional may be obtained by the idiom: ** ** { X =X} ** ** The equal sign together with the digits 0 to 7 constitute an ** ** idiom for loading octal constants. Nontrivial constants may ** ** be loaded into registers outside of any loop. ** **********************************************************************/ #define CII_MakeMaskProgram(h, codeVersion, bigEndian, codeString, maskProgramResult) \ (((h)->MakeMaskProgram)(h, codeVersion, bigEndian, codeString, maskProgramResult)) typedef CII_RES PROC_CII_MakeMaskProgram( CII_Handle h, int codeVersion, CII_Boolean bigEndian, char* codeString, CII_MaskProgram* maskProgramResult ); /********************************************************************** ** CII_MaskDeviceBoxes: METHOD ** ** ** ** See CII_MakeMaskProgram for details of maskProgram. This ** ** operation bypasses the transformation and the clipper, leaving ** ** these responsibilities to the client. ** ** sMin, fMin, sMax, fMax specify the bounds of the mask. It is ** ** an error to exceed these bounds. ** ** boxOrder gives some information about the generated boxes: ** ** 0 - nothing is known about the order or overlap of the boxes ** ** 1 - boxes will be disjoint ** ** 2 - boxes will be disjoint, nonempty, and for any two ** ** consecutive boxes a and b, b.sMin >= a.sMax-1 ** **********************************************************************/ #define CII_MaskDeviceBoxes(a, b, c, d, e, f, g, h, i) \ (((a)->MaskDeviceBoxes)(a, b, c, d, e, f, g, h, i)) typedef CII_RES PROC_CII_MaskDeviceBoxes( CII_Handle h, int sMin, int fMin, int sMax, int fMax, int boxOrder, CII_MaskProgram maskProgram, int maskDataByteCount, void* maskData ); /********************************************************************** ** CII_FindFont: METHOD ** ** ** ** Finds a font, given a name. ** ** fontName is the Hierarchical name, slash delimited ** **********************************************************************/ #define CII_FindFont(h, fontName, fontResult) \ (((h)->FindFont)(h, fontName, fontResult)) typedef CII_RES PROC_CII_FindFont( CII_Handle h, char* fontName, CII_Font* fontResult ); /********************************************************************** ** CII_ModifyFont: METHOD ** ** ** ** Makes a new font with a modified transformation, according to ** ** the supplied matrix. ** **********************************************************************/ #define CII_ModifyFont(h, font, mp, fontResult) \ (((h)->ModifyFont)(h, font, mp, fontResult)) typedef CII_RES PROC_CII_ModifyFont( CII_Handle h, CII_Font font, float mp[], CII_Font* fontResult ); /********************************************************************** ** CII_MakeFontAtom: METHOD ** ** ** ** Differs from ModifyFont in that it ignores the translation ** ** component of the supplied matrix ** **********************************************************************/ #define CII_MakeFontAtom(h, font, mp, fontResult) \ (((h)->MakeFontAtom)(h, font, mp, fontResult)) typedef CII_RES PROC_CII_MakeFontAtom( CII_Handle h, CII_Font font, float mp[], CII_Font* fontResult ); /********************************************************************** ** CII_EasyMetrics: TYPE ** ** ** ** all easy => never call hardMetrics proc ** ** ordinary easy => call hardMetrics for spacing characters ** ** none easy => call hardMetrics for each character ** **********************************************************************/ typedef enum { CII_ALL_EASY_METRICS, CII_ORDINARY_EASY_METRICS, CII_NONE_EASY_METRICS } CII_EasyMetrics; /********************************************************************** ** CII_CharCode: TYPE ** ** ** ** A 32-bit character code ** **********************************************************************/ typedef unsigned long CII_CharCode; /********************************************************************** ** CII_MaskInfo: TYPE ** ** ** ** Information about the character just masked, for benefit of ** ** hardMetrics procedure ** **********************************************************************/ typedef struct CII_MaskInfo { CII_Font fontAtom; CII_CharCode charCode; CII_Scaled deltaX; /* device coords, slow scan direction */ CII_Scaled deltaY; /* device coords, fast scan direction */ int minX, minY, maxX, maxY; /* bounding box, device coords */ } CII_MaskInfo; /********************************************************************** ** CII_ShowArgs: TYPE ** ** ** ** The control block for Show. This is a read-write area; the cp ** ** field and the start field get updated to reflect how much work ** ** has been done. ** **********************************************************************/ typedef struct CII_ShowArgs { CII_Font fontAtom; /* with transformation to device coordinates */ CII_EasyMetrics easyMetrics; /* controls metrics callback */ CII_Boolean noImage; /* TRUE turns off imaging */ CII_RES (*hardChar)(CII_Handle, struct CII_ShowArgs*); CII_RES (*hardMetrics)(CII_Handle, struct CII_ShowArgs*, struct CII_MaskInfo*); CII_VectorRep cp; /* gets updated; device coords */ int start; /* gets updated for callbacks */ int end; /* characters[end-1] is the last one */ CII_CharCode* characters; /* the character codes, one per word */ void* clientData; /* for benefit of callbacks */ } CII_ShowArgs; /********************************************************************** ** CII_DoHardChar: METHOD ** ** ** ** May be used as the hardChar proc, or simply to show a single ** ** character without using the mask cache. ** ** N.B. ignores current transformation ** **********************************************************************/ #define CII_DoHardChar(h, s) \ (((h)->DoHardChar)(h, s)) typedef CII_RES PROC_CII_DoHardChar( CII_Handle h, CII_ShowArgs* s ); /********************************************************************** ** CII_DoHardMetrics: METHOD ** ** ** ** May be used as the hardMetrics proc to provide the default ** ** behavior of adding the escapement to the current position. ** ** N.B. ignores current transformation ** **********************************************************************/ #define CII_DoHardMetrics(h, s, maskInfo) \ (((h)->DoHardMetrics)(h, s, maskInfo)) typedef CII_RES PROC_CII_DoHardMetrics( CII_Handle h, CII_ShowArgs* s, CII_MaskInfo* maskInfo ); /********************************************************************** ** CII_Show: METHOD ** ** ** ** General-purpose Show procedure. ** **********************************************************************/ #define CII_Show(h, s) \ (((h)->Show)(h, s)) typedef CII_RES PROC_CII_Show( CII_Handle h, CII_ShowArgs* s ); /********************************************************************** ** CII_BufferedSeparationImage: METHOD ** ** ** ** Draws a portion of the buffered image, using any data outside ** ** of the sMin .. sMax range any interpolation or other ** ** anti-aliasing that might be done. This range will typically ** ** specify most of the image, with only a few scanlines of context ** ** from adjacent bands. ** **********************************************************************/ #define CII_BufferedSeparationImage(a, b, c, d, e, f, g) \ (((a)->BufferedSeparationImage)(a, b, c, d, e, f, g)) typedef CII_RES PROC_CII_BufferedSeparationImage( CII_Handle h, CII_RasterRep* buffers[], unsigned int samplesPerPixel, int sMin, int sMax, CII_ColorOperator colorOperator, CII_Boolean interpolate ); /********************************************************************** ** CII_BufferedInterleavedImage: METHOD ** ** ** ** Like BufferedSeparationImage, but the samples are interleaved ** ** in the buffer. The fSize of the buffer is samplesPerPixel ** ** times greater than the fSize of the image data. ** **********************************************************************/ #define CII_BufferedInterleavedImage(a, b, c, d, e, f, g) \ (((a)->BufferedInterleavedImage)(a, b, c, d, e, f, g)) typedef CII_RES PROC_CII_BufferedInterleavedImage( CII_Handle h, CII_RasterRep* buffer, unsigned int samplesPerPixel, int sMin, int sMax, CII_ColorOperator colorOperator, CII_Boolean interpolate ); /********************************************************************** ** CII_ImageSource: TYPE ** ** ** ** This is a simple, abstract byte-stream object. ** **********************************************************************/ typedef struct CII_ImageSourceObjectRep * CII_ImageSource; /********************************************************************** ** CII_ImageSourceRead: METHOD ** ** ** ** The read proc places the number of bytes read into ** ** *nbytesResult. Zero bytes read indicates the end-of-stream. ** **********************************************************************/ #define CII_ImageSourceRead(self, buf, nbytes, nbytesResult) \ (((self)->ImageSourceRead)(self, buf, nbytes, nbytesResult)) typedef CII_RES PROC_CII_ImageSourceRead( CII_ImageSource self, void* buf, unsigned int nbytes, unsigned int* nbytesResult ); /********************************************************************** ** CII_ImageSourceDestroy: METHOD ** ** ** ** Asserts this image source is finished. ** **********************************************************************/ #define CII_ImageSourceDestroy(self) \ (((self)->ImageSourceDestroy)(self)) typedef CII_RES PROC_CII_ImageSourceDestroy(CII_ImageSource self); /********************************************************************** ** CII_StreamImage: METHOD ** ** ** ** Draws the image; takes care of breaking the image into ** ** managable pieces. The image data is pulled from the source, ** ** and is always interleaved, with each scanline starting at a bit ** ** index that is zero modulo padMod. Use padMod = 1 for no ** ** padding, padMod = 8 for byte-aligned scanlines, etc. ** **********************************************************************/ #define CII_StreamImage(a, b, c, d, e, f, g, h, i) \ (((a)->StreamImage)(a, b, c, d, e, f, g, h, i)) typedef CII_RES PROC_CII_StreamImage( CII_Handle h, unsigned int sSize, unsigned int fSize, unsigned int bitsPerSample, unsigned int samplesPerPixel, unsigned int padMod, CII_ColorOperator co, CII_Boolean interpolate, CII_ImageSource source ); /********************************************************************** ** CII_MaskStreamBits: METHOD ** ** ** ** Stream-oriented analogue to MaskBitmap. Always 1 bit per ** ** pixel. The padMod argument is as for StreamImage. ** **********************************************************************/ #define CII_MaskStreamBits(h, sSize, fSize, padMod, source, background) \ (((h)->MaskStreamBits)(h, sSize, fSize, padMod, source, background)) typedef CII_RES PROC_CII_MaskStreamBits( CII_Handle h, unsigned int sSize, unsigned int fSize, unsigned int padMod, CII_ImageSource source, CII_Color background ); /********************************************************************** ** CII_ApplyCCITTFacsimileDecompressionFilter: METHOD ** ** ** ** Makes a new ImageSource that works by decompressing the data ** ** supplied by the input ImageSource according to the CCITT Group ** ** 3 or Group 4 Facsimile compression standards. ** ** ** ** input: This supplies the (compressed) source data. ** ** ** ** k: If negative, source is pure 2-D (Group 4) encoding. ** ** If zero, source is pure 1-D (Group 3) encoding. ** ** If positive, a mixed 1-D / 2-D encoding is accepted. The ** ** G3-specified limits on consecutive 2-D encoded scanlines is ** ** not enforced. ** ** ** ** requireEOL: If true, the end-of-line bit pattern is ** ** required at the end of each scan line. ** ** ** ** padMod: Additional zero bits are inserted at the end of each ** ** output scanline for alignment purposes; normal values for ** ** this would be 1 (no padding), 8 (pad to byte boundary), or ** ** 32 (pad to a word boundary). If the filtered output is ** ** destined for StreamImage or MaskStreamBits, this should ** ** match up with the padMod of that call. ** ** ** ** sSize: The number of scan lines (rows) present in the image. ** ** A value of 0 may be used if the scan count is not known. ** ** ** ** fSize: The number of source pixels in each scan line. (The ** ** facsimile standards assume a value of 1728, so the ability ** ** to specify this is a slight generalization of the ** ** standards.) ** ** ** ** endOfBlock: If true, the data is expected to be terminated ** ** with an end-of-block pattern, overriding the sSize ** ** parameter. If false, the data stops at end-of-block or ** ** after sSize scan lines, whichever comes first. ** ** ** ** blackIs1: If true, the black pixels in the source come out ** ** as 1 bits in the filtered output; otherwise the black pixels ** ** come out as 0 bits. (The facsimile standards are written in ** ** terms of black and white pixels, and leave unspecified the ** ** sense of the unencoded bits.) ** ** ** ** msbFirst: If true, the bits within each input byte of ** ** compressed data are interpreted with the ** ** most-significant-bit first; otherwise, interpret the bytes ** ** lsb-first. ** ** ** ** damagedRowsBeforeError: If > 0, with requireEOL and k >= 0, ** ** then tolerate this many damaged rows before generating an ** ** error. ** ** ** ** filteredResult: This is for returning the ImageSource that ** ** may be read to obtain the decompressed data. Note that the ** ** decompression won't, in general, take place until this ** ** source is read. (Issue: it should be specified what the ** ** destroy proc of the filtered stream does - should it call ** ** the destroy proc of the input stream or not?) ** ** ** ** There may be a performance advantage in using this ** ** decompression filter with the MaskStreamBits or StreamImage ** ** methods of this handle, because in such a case there is an ** ** opportunity for the implementation to avoid the extra buffering ** ** stage; this is the primary motivation for introducing this ** ** decompression filter into the CII interface. ** **********************************************************************/ #define CII_ApplyCCITTFacsimileDecompressionFilter(a, b, c, d, e, f, g, h, i, j, k, l) \ (((a)->ApplyCCITTFacsimileDecompressionFilter)(a, b, c, d, e, f, g, h, i, j, k, l)) typedef CII_RES PROC_CII_ApplyCCITTFacsimileDecompressionFilter( CII_Handle h, CII_ImageSource input, int k, CII_Boolean requireEOL, unsigned int padMod, unsigned int sSize, unsigned int fSize, CII_Boolean endOfBlock, CII_Boolean blackIs1, CII_Boolean msbFirst, int damagedRowsBeforeError, CII_ImageSource* filteredResult ); /********************************************************************** ** CII_Toner: TYPE ** ** ** ** Specifies a toner color for several of the more ** ** device-dependent methods ** **********************************************************************/ typedef enum { CII_TONER_BLACK, CII_TONER_CYAN, CII_TONER_MAGENTA, CII_TONER_YELLOW, CII_TONER_WHITE, CII_TONER_RED, CII_TONER_GREEN, CII_TONER_BLUE, CII_TONER_CUSTOM, CII_TONER_HIGHLIGHT } CII_Toner; /********************************************************************** ** CII_HalftonePropertiesForSeparation: TYPE ** ** ** ** Specifies the halftone dot growth for a given toner. For ** ** samples samples normalized to the range [0..maxSample], a ** ** printer pixel will be inked if sample > threshold; thus to ** ** allow full range on the output, the threshold values should be ** ** confined to the range [0..maxSample-1]. A value of 255 for ** ** maxSample is strongly recommended. ** ** Not all toner values will, in general, be meaningful for this ** ** call; the ones you probably want to use are CII_TONER_BLACK, ** ** CII_TONER_CYAN, CII_TONER_MAGENTA, and CII_TONER_YELLOW. ** **********************************************************************/ typedef struct CII_HalftonePropertiesForSeparation { char* halftoneType; /* make this NIL for now */ CII_Toner toner; /* says which toner this is for */ unsigned maxSample; /* expected range of input samples */ CII_RasterRep thresholds; /* the threshold array */ unsigned phase; /* successive rows offset by this much */ void* reserved; /* reserved - must be NIL */ } CII_HalftonePropertiesForSeparation; /********************************************************************** ** CII_HalftoneProperties: TYPE ** ** ** ** Represents the halftone properties for all toners. ** ** Details are opaque to the client. These objects are ** ** heap-allocated, and so may be stored in persistent data ** ** structures. ** **********************************************************************/ typedef struct {int opaque;} *CII_HalftoneProperties; /********************************************************************** ** CII_MakeHalftoneProperties: METHOD ** ** ** ** Makes the imager-private representation of the halftone ** ** properties. ** **********************************************************************/ #define CII_MakeHalftoneProperties(a, b, c, d) \ (((a)->MakeHalftoneProperties)(a, b, c, d)) typedef CII_RES PROC_CII_MakeHalftoneProperties( CII_Handle h, int separationCount, CII_HalftonePropertiesForSeparation halftonePropertiesForSeparation[], CII_HalftoneProperties* halftonePropertiesResult ); /********************************************************************** ** CII_SetHalftoneProperties: METHOD ** ** ** ** Sets the halftone properties for all toners. ** **********************************************************************/ #define CII_SetHalftoneProperties(h, halftoneProperties) \ (((h)->SetHalftoneProperties)(h, halftoneProperties)) typedef CII_RES PROC_CII_SetHalftoneProperties( CII_Handle h, CII_HalftoneProperties halftoneProperties ); /********************************************************************** ** CII_GetHalftoneProperties: METHOD ** ** ** ** Gets the imager-private representation of the halftone ** ** properties. ** **********************************************************************/ #define CII_GetHalftoneProperties(h, halftonePropertiesResult) \ (((h)->GetHalftoneProperties)(h, halftonePropertiesResult)) typedef CII_RES PROC_CII_GetHalftoneProperties( CII_Handle h, CII_HalftoneProperties* halftonePropertiesResult ); /********************************************************************** ** CII_DestroyHalftoneProperties: METHOD ** ** ** ** Should be called exactly once for each CII_HalftoneProperties ** ** returned to the client, after after which the client should not ** ** use the object again. The handle must be the same handle used ** ** to create the CII_HalftoneProperties. ** **********************************************************************/ #define CII_DestroyHalftoneProperties(h, halftoneProperties) \ (((h)->DestroyHalftoneProperties)(h, halftoneProperties)) typedef CII_RES PROC_CII_DestroyHalftoneProperties( CII_Handle h, CII_HalftoneProperties halftoneProperties ); /********************************************************************** ** CII_SetSeparation: METHOD ** ** ** ** For some devices, indicates which of the separations are to be ** ** constructed. Do not confuse this with the PostScript ** ** Separation color space. ** ** CII_RES_notImplemented => the device cannot support ** ** separations. ** ** CII_RES_invalidToner => the device cannot handle the selected ** ** toner. ** ** The color should be re-set after this method is invoked. ** **********************************************************************/ #define CII_SetSeparation(h, toner) \ (((h)->SetSeparation)(h, toner)) typedef CII_RES PROC_CII_SetSeparation( CII_Handle h, CII_Toner toner ); /********************************************************************** ** CII_SetOutputBuffers: METHOD ** ** ** ** For some devices, redirects the output to a different ** ** page/frame buffer. ** ** CII_RES_notImplemented => the device does not support ** ** changing the output buffer. ** ** CII_RES_wrongShape => the device does not support changing ** ** the dimensions of the output buffer. ** **********************************************************************/ #define CII_SetOutputBuffers(h, nBuffers, outputBuffers) \ (((h)->SetOutputBuffers)(h, nBuffers, outputBuffers)) typedef CII_RES PROC_CII_SetOutputBuffers( CII_Handle h, int nBuffers, CII_RasterRep outputBuffers[] ); /********************************************************************** ** CII_SetColorTable: METHOD ** ** ** ** Indicates the (device-dependent) color conversion tables to ** ** use. ** ** ** ** name: a null-terminated alphanumeric string naming the table; ** ** this is for informational purposes, and will generally not ** ** affect the behavior of the device. ** ** ** ** identification: a null-terminated ascii string with a longer ** ** description of the table; this will generally not affect the ** ** behavior of the device, but may be useful for diagnostic ** ** purposes. For example, it may include a description of how ** ** and when the table was created, and/or the name of the file ** ** that the table was loaded from. ** ** ** ** format: a null-terminated string identifying the format of the ** ** table. This is used by the device to determine whether the ** ** color table data is appropriate for the device. Each device ** ** will support only a limited number of formats (often 0 or ** ** 1); you will have to look elsewhere to find out what the ** ** supported formats are. As a special case, a null or ** ** zero-length format causes the device to revert to its ** ** initial color table. ** ** ** ** tableBase: A pointer to the color table data. This pointer ** ** must remain valid until a new color table is set or the ** ** handle is destroyed; furthermore, the client should not alter ** ** the table without doing another SetColorTable. ** ** ** ** tableByteLength: The length, in bytes, of the color table data. ** ** ** ** replacementHint: May give the stamp from a previous call (see ** ** stampValueResult, below). If the device can cache ** ** information about color tables, this may be used as a hint ** ** about which previous cache entry to replace. A value of 0 is ** ** recommended here unless the client really has some good ** ** information about the usage pattern of the color tables. ** ** ** ** stampValueResult: When SetColorTable is called for the first ** ** time with a given table, this should point to a ** ** zero-initialized word; the device stores a stamp in this word ** ** that it may use on subsequent calls to speed the loading of ** ** the color table data. The stamp should be presented to the ** ** device only in the case that the color table data is the same ** ** that was presented when the stamp was created. This may be ** ** used, for example, to take advantage of hardware that allows ** ** several tables to be in use at one time, without asking the ** ** client to keep track of how many such tables are available. ** ** ** ** Return codes: ** ** CII_RES_notImplemented => the device has ignored the table ** ** because the format was not recognized. ** ** CII_RES_malformedDataFile => the device has detected an ** ** error in the color table data. The check for a valid ** ** format is always done before this, so that if it is desired ** ** to test whether a particular format is known by the device ** ** before the actual table is read in, the client may pass a ** ** tableByteLength of 0 and check the return code. In the ** ** case of CII_RES_malformedDataFile, the color table should ** ** be set again (with a null format, if necessary), to ensure ** ** that a valid translation is in effect. ** ** ** ** The color should be re-set after the SetColorTable method is ** ** invoked. ** **********************************************************************/ #define CII_SetColorTable(a, b, c, d, e, f, g, h) \ (((a)->SetColorTable)(a, b, c, d, e, f, g, h)) typedef CII_RES PROC_CII_SetColorTable( CII_Handle h, char* name, char* identification, char* format, void* tableBase, unsigned int tableByteLength, unsigned int replacementHint, unsigned int* stampValueResult ); /********************************************************************** ** CII_LookupTable: TYPE ** ** ** ** Represents, by means of equally-spaced samples, a function that ** ** maps the real interval [0.0,1.0] into real values. ** ** Details are opaque to the client. These objects are ** ** heap-allocated, and so may be stored in persistent data ** ** structures. ** **********************************************************************/ typedef struct {int opaque;} *CII_LookupTable; /********************************************************************** ** CII_MakeLookupTable: METHOD ** ** ** ** The value of table[0] represents the value of the function at ** ** 0.0, table[tableSize-1] represents the value of the function at ** ** 1.0, and the remaining samples are equally-spaced in between ** ** these two extremes. Intermediate values are filled in, if ** ** necessary, by linear interpolation. These functions are used ** ** to provide some rudimentary control of the generation of ** ** device-dependent color. ** **********************************************************************/ #define CII_MakeLookupTable(h, tableSize, table, lookupTableResult) \ (((h)->MakeLookupTable)(h, tableSize, table, lookupTableResult)) typedef CII_RES PROC_CII_MakeLookupTable( CII_Handle h, unsigned int tableSize, float table[], CII_LookupTable* lookupTableResult ); /********************************************************************** ** CII_DestroyLookupTable: METHOD ** ** ** ** Should be called exactly once for each CII_LookupTable returned ** ** to the client, after after which the client should not use the ** ** object again. The handle must be the same handle used to ** ** create the CII_LookupTable. ** **********************************************************************/ #define CII_DestroyLookupTable(h, lookupTable) \ (((h)->DestroyLookupTable)(h, lookupTable)) typedef CII_RES PROC_CII_DestroyLookupTable( CII_Handle h, CII_LookupTable lookupTable ); /********************************************************************** ** CII_ColorLookupTableType: TYPE ** ** ** ** This enumeration is used to distinguish which of the various ** ** 1-d lookup tables are being referenced. ** ** ** ** CII_*_TRANSFER ** ** The RED, GREEN, BLUE, and GRAY transfer functions are ** ** applied as the final client-controlled stage of color ** ** generation (prior to any halftoning). Each of these ** ** functions transform a device-dependent component of the ** ** color independently of the other components. For a ** ** monochrome device, only the GRAY transfer function is used. ** ** For an RGB device, only the RED, GREEN, BLUE transfer ** ** functions are used, with one exception. The exception ** ** occurs whan a Gray color operator is in effect, in which ** ** case the GRAY transfer function is used prior to the ** ** conversion to RGB, and the RED, GREEN, BLUE transfer ** ** functions are not used. For a CMYK device, all four ** ** transfer functions are used; in this case, values of 0 ** ** correspond to maximum colorant, and values of 1 correspond ** ** minimum colorant; note this is the inverse of the usual ** ** sense of CMYK. ** ** There is the possibility of a device for which this ** ** expression of a final transfer function makes very little ** ** sense, for instance if the target is a CIE L*a*b* rendition. ** ** The device may ignore the transfer functions in such a ** ** case, except that the GRAY transfer shall always apply to ** ** the results of the Gray color operator. ** ** For the transfer functions, a NIL lookupTable corresponds to ** ** the identity function. ** ** All four transfer functions should be provided; if only a ** ** gray transfer function is available, it should be used for ** ** all four. ** ** ** ** CII_BLACK_GENERATION ** ** This function (BG) is used when the device needs to produce ** ** a CMYK output, and it only has three-component (CMY) color. ** ** The input to the BG is the minimum of the cyan, magenta, and ** ** yellow components, and the output is the amount of black; ** ** the range for both input and output is 0 (minimum colorant) ** ** to 1 (maximum colorant). Notice the sense of these numbers ** ** is opposite to that of the inputs and outputs of the ** ** transfer functions. ** ** A NIL BG lookupTable corresponds to the constant zero ** ** function. ** ** ** ** CII_UNDERCOLOR_REMOVAL ** ** This function (UCR) is used under the same circumstances as ** ** the black generation function, and takes the same input. ** ** The output is in the range -1 to +1, and says how much ** ** colorant to remove from each of the cyan, magenta, and ** ** yellow components. ** ** A NIL UCR lookupTable corresponds to the constant zero ** ** function. ** ** ** ** Note that this form of specification of BG and UCR functions is ** ** quite limited; some devices may benefit from functions that use ** ** more information than just MIN(C,M,Y). Such functions might be ** ** expressed as part of (device-dependent) data passed to ** ** SetColorTable. A device that recognizes this situation may end ** ** up effectively ignoring the BG and UCR lookup tables, because ** ** the color correction intrinsically generates CMYK. ** ** ** **********************************************************************/ typedef enum {CII_RED_TRANSFER, CII_GREEN_TRANSFER, CII_BLUE_TRANSFER, CII_GRAY_TRANSFER, CII_BLACK_GENERATION, CII_UNDERCOLOR_REMOVAL} CII_ColorLookupTableType; /********************************************************************** ** CII_SetColorLookupTable: METHOD ** ** ** ** Sets one of the color lookup tables. Refer to comments above ** ** for details. ** **********************************************************************/ #define CII_SetColorLookupTable(h, which, lookupTable) \ (((h)->SetColorLookupTable)(h, which, lookupTable)) typedef CII_RES PROC_CII_SetColorLookupTable( CII_Handle h, CII_ColorLookupTableType which, CII_LookupTable lookupTable ); /********************************************************************** ** CII_GetColorLookupTable: METHOD ** ** ** ** Gets one of the color lookup tables. ** **********************************************************************/ #define CII_GetColorLookupTable(h, which, lookupTableResult) \ (((h)->GetColorLookupTable)(h, which, lookupTableResult)) typedef CII_RES PROC_CII_GetColorLookupTable( CII_Handle h, CII_ColorLookupTableType which, CII_LookupTable* lookupTableResult ); /********************************************************************** ** CII_Sync: METHOD ** ** ** ** There may be a situation where the further processing of the ** ** output of a device requires the cooperation of the cii layer; ** ** for instance it may be necessary to complete processing of ** ** requests that have been internally buffered or that are being ** ** processed in parallel. The Sync method allows for this; the ** ** parameters allow for additional (device-dependent) data to be ** ** passed as appropriate. The interpretation of the data, if any, ** ** is not specified by this interface. The operation named ** ** "sync", with a null dataFormat and no data, will mean to ** ** complete all outstanding imaging requests. ** ** ** ** operationName: a null-terminated alphanumeric string naming ** ** the synchonization operation to be performed. An ** ** unrecognized operation will yield a return code of ** ** CII_RES_notImplemented. ** ** ** ** format: a null-terminated alphanumeric string identifying ** ** the format of the data. ** ** ** ** dataPointer: a pointer to any data the operation may require; ** ** devices might have operations that place results here, but ** ** they must respect the dataByteLength. ** ** ** ** dataByteLength: the length, in bytes, of the data area. ** **********************************************************************/ #define CII_Sync(h, operationName, format, dataPointer, dataByteLength) \ (((h)->Sync)(h, operationName, format, dataPointer, dataByteLength)) typedef CII_RES PROC_CII_Sync( CII_Handle h, char* operationName, char* format, void* dataPointer, unsigned int dataByteLength ); /********************************************************************** ** CII_CleanupObject: TYPE ** ** ** ** A CleanupObject, when registered with a given handle, will be ** ** invoked prior to the destruction of the handle. ** **********************************************************************/ typedef struct CII_CleanupObjectRep * CII_CleanupObject; /********************************************************************** ** CII_RegisterCleanupObject: METHOD ** ** ** ** Registers the client-supplied cleanupObject with the handle. ** ** Upon handle destruction, the cleanupObject will be ** ** unregistered, then sent the cleanup message. There may be more ** ** than one cleanupObject object registered with a given handle. ** ** RegisterCleanupObject does not check for duplicates; if there ** ** is a chance that the client has registered the cleanupObject ** ** already, it may call CII_UnRegisterCleanupObject first to ** ** eliminate any duplicates. The cleanup objects are called in ** ** reverse order of registration. ** **********************************************************************/ #define CII_RegisterCleanupObject(h, cleanupObject) \ (((h)->RegisterCleanupObject)(h, cleanupObject)) typedef CII_RES PROC_CII_RegisterCleanupObject( CII_Handle h, CII_CleanupObject cleanupObject ); /********************************************************************** ** CII_UnRegisterCleanupObject: METHOD ** ** ** ** Unregisters the cleanupObject, if it had previously been ** ** registered. In the case that cleanupObject got registered ** ** multiple times, this will only remove one registration, the ** ** most recently registered one. The match is done by pointer ** ** comparison of the cleanupObject. ** ** CII_RES_accessError => cleanupObject was not registered. ** **********************************************************************/ #define CII_UnRegisterCleanupObject(h, cleanupObject) \ (((h)->UnRegisterCleanupObject)(h, cleanupObject)) typedef CII_RES PROC_CII_UnRegisterCleanupObject( CII_Handle h, CII_CleanupObject cleanupObject ); /********************************************************************** ** CII_Cleanup: METHOD ** ** ** ** Invokes a CleanupObject ** **********************************************************************/ #define CII_Cleanup(self, h) \ (((self)->Cleanup)(self, h)) typedef CII_RES PROC_CII_Cleanup( CII_CleanupObject self, CII_Handle h ); /********************************************************************** ** CII_PathGeneratorObjectRep: OBJECT ** ** ** **********************************************************************/ typedef struct CII_PathGeneratorObjectRep { void* data; PROC_CII_GeneratePath* GeneratePath; } CII_PathGeneratorObjectRep; /********************************************************************** ** CII_CleanupObjectRep: OBJECT ** ** ** **********************************************************************/ typedef struct CII_CleanupObjectRep { void* data; PROC_CII_Cleanup* Cleanup; } CII_CleanupObjectRep; /********************************************************************** ** CII_PathSinkObjectRep: OBJECT ** ** ** **********************************************************************/ typedef struct CII_PathSinkObjectRep { void* data; PROC_CII_MoveTo* MoveTo; PROC_CII_LineTo* LineTo; PROC_CII_CurveTo* CurveTo; PROC_CII_ConicTo* ConicTo; } CII_PathSinkObjectRep; /********************************************************************** ** CII_ObjectRep: OBJECT ** ** ** **********************************************************************/ typedef struct CII_ObjectRep { void* data; PROC_CII_Destroy* Destroy; PROC_CII_DestroyColor* DestroyColor; PROC_CII_DestroyColorOperator* DestroyColorOperator; PROC_CII_DestroyClipper* DestroyClipper; PROC_CII_DestroyFont* DestroyFont; PROC_CII_SetMatrix* SetMatrix; PROC_CII_GetMatrix* GetMatrix; PROC_CII_GetInitialMatrix* GetInitialMatrix; PROC_CII_SetInitialMatrix* SetInitialMatrix; PROC_CII_MakeGrayColorOperator* MakeGrayColorOperator; PROC_CII_MakeRGBColorOperator* MakeRGBColorOperator; PROC_CII_MakeCMYKColorOperator* MakeCMYKColorOperator; PROC_CII_MakeHighlightColorOperator* MakeHighlightColorOperator; PROC_CII_MakeColor* MakeColor; PROC_CII_MakeSampledBlack* MakeSampledBlack; PROC_CII_SetColor* SetColor; PROC_CII_SetGray* SetGray; PROC_CII_SetRGB* SetRGB; PROC_CII_SetHSV* SetHSV; PROC_CII_SetCMYK* SetCMYK; PROC_CII_GetColor* GetColor; PROC_CII_MaskRectangle* MaskRectangle; PROC_CII_MaskFill* MaskFill; PROC_CII_Clip* Clip; PROC_CII_GetClipper* GetClipper; PROC_CII_SetClipper* SetClipper; PROC_CII_BuildClipperBegin* BuildClipperBegin; PROC_CII_BuildClipperEnd* BuildClipperEnd; PROC_CII_MaskStroke* MaskStroke; PROC_CII_MaskBitmap* MaskBitmap; PROC_CII_MaskDeviceTrapezoid* MaskDeviceTrapezoid; PROC_CII_DestroyMaskProgram* DestroyMaskProgram; PROC_CII_MakeMaskProgram* MakeMaskProgram; PROC_CII_MaskDeviceBoxes* MaskDeviceBoxes; PROC_CII_FindFont* FindFont; PROC_CII_ModifyFont* ModifyFont; PROC_CII_MakeFontAtom* MakeFontAtom; PROC_CII_DoHardChar* DoHardChar; PROC_CII_DoHardMetrics* DoHardMetrics; PROC_CII_Show* Show; PROC_CII_BufferedSeparationImage* BufferedSeparationImage; PROC_CII_BufferedInterleavedImage* BufferedInterleavedImage; PROC_CII_StreamImage* StreamImage; PROC_CII_MaskStreamBits* MaskStreamBits; PROC_CII_ApplyCCITTFacsimileDecompressionFilter* ApplyCCITTFacsimileDecompressionFilter; PROC_CII_MakeHalftoneProperties* MakeHalftoneProperties; PROC_CII_SetHalftoneProperties* SetHalftoneProperties; PROC_CII_GetHalftoneProperties* GetHalftoneProperties; PROC_CII_DestroyHalftoneProperties* DestroyHalftoneProperties; PROC_CII_SetSeparation* SetSeparation; PROC_CII_SetOutputBuffers* SetOutputBuffers; PROC_CII_SetColorTable* SetColorTable; PROC_CII_MakeLookupTable* MakeLookupTable; PROC_CII_DestroyLookupTable* DestroyLookupTable; PROC_CII_SetColorLookupTable* SetColorLookupTable; PROC_CII_GetColorLookupTable* GetColorLookupTable; PROC_CII_Sync* Sync; PROC_CII_RegisterCleanupObject* RegisterCleanupObject; PROC_CII_UnRegisterCleanupObject* UnRegisterCleanupObject; } CII_ObjectRep; /********************************************************************** ** CII_ImageSourceObjectRep: OBJECT ** ** ** **********************************************************************/ typedef struct CII_ImageSourceObjectRep { void* data; PROC_CII_ImageSourceRead* ImageSourceRead; PROC_CII_ImageSourceDestroy* ImageSourceDestroy; } CII_ImageSourceObjectRep; #endif /* cii_h */