ftp.nice.ch/pub/next/graphics/convertors/Convert_PICT.NIHS.bs.tar.gz#/Convert_PICT/Source/PictConverter.h

This is PictConverter.h in view mode; [Download] [Up]

/***********************************************************************\
Converter class for Convert PICT which converts graphics from PICT to eps formats.
Copyright (C) 1993 David John Burrowes

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

The author, David John Burrowes, can be reached at:
	davidjohn@kira.net.netcom.com
	David John Burrowes
	1926 Ivy #10
	San Mateo, CA 94403-1367
\***********************************************************************/

/*
====================================================================
	This is $Revision: 1.10 $ of this file
	It was last modified by $Author: death $ on $Date: 93/04/04 23:29:53 $
Note that this file was created while using the New Century Schoolbook Roman typeface.  You may find that some things line up strangely if you don't use that family.

History:
	93.07.18	djb	Added PicCommentOperation type, and instance variable for the same.	

$Log:	PictConverter.h,v $
 * Revision 1.10  93/04/04  23:29:53  death
 * Sun Apr  4 23:29:53 PDT 1993
 * 
 * Revision 1.9  93/01/09  21:07:07  death
 * Sat Jan  9 21:07:07 PST 1993
 * 
 * Revision 1.8  93/01/01  11:51:16  death
 * Fri Jan  1 11:51:16 PST 1993
 * 
 * Revision 1.7  92/12/31  15:33:53  death
 * Thu Dec 31 15:33:53 PST 1992
 * 
 * Revision 1.6  92/12/05  23:06:26  death
 * Sat Dec  5 23:06:25 PST 1992
 * 
 ====================================================================
 */

 
#import "AbstractConverter.h"
#import "PICTFile.h"

//
//	type styles
//
#define boldBit 1
#define italicBit 2
#define underlineBit 4
#define outlineBit 8
#define shadowBit 0x10
#define condenseBit 0x20
#define extendBit 0x40

//
//	PICT modes
//
#define macSrcCopy 0
#define macSrcOr 1
#define macSrcXor 2
#define macSrcBic 3
#define macNotSrcCopy 4
#define macNotSrcOr 5
#define macNotSrcXor 6
#define macNotSrcBic 7
#define macPatCopy 8
#define macPatOr 9
#define macPatXor 10
#define macPatBic 11
#define macNotPatCopy 12
#define macNotPatOr 13
#define macNotPatXor 14
#define macNotPatBic 15
// Arithmetic modes defined in Inide Mac V.  
#define blend 32
#define addPin 33
#define addOver 34
#define subPin 35
#define addMax 37
#define subOver 38
#define adMin 39
// a transparent mode
#define transparent 36
//
//	93.07.18	djb	added.
//	A mysterious pen mode defined in a tech note.
//	It's effect is, it seems, to be to cause QuickDraw to process stuff, but not 
//	actually draw anything.
//
#define	magicMode	23

//
//	Old style colors  (what space are those numbers in?
//
#define	oldBlackColor	0x0021
#define	oldWhiteColor	0x001E
#define	oldRedColor		0x00D1
#define	oldGreenColor	0x0149
#define	oldBlueColor		0x0185
#define	oldCyanColor		0x010D
#define	oldMagentaColor	0x0095
#define	oldYellowColor	0x0059


//
//	Pixmap stuff
//
struct PixMap {
	PICTRect bounds;			/*encloses bitmap*/
	INTEGER pmVersion;			/*pixMap version number*/
	INTEGER packType; 			/*defines packing format*/
	LONGINT packSize;			/*length of pixel data*/
	FIXED hRes; 			/*horiz. resolution (ppi)*/
	FIXED vRes; 			/*vert. resolution (ppi)*/
	INTEGER pixelType;			/*defines pixel type*/
	INTEGER pixelSize;			/*# bits in pixel*/
	INTEGER cmpCount; 			/*# components in pixel*/
	INTEGER cmpSize;				/*# bits per component*/
	LONGINT planeBytes;			/*offset to next plane*/
	LONGINT pmTable; 			/*color map for this pixMap*/
	LONGINT pmReserved;			/*for future use. MUST BE 0*/
};

typedef struct PixMap modPixMap;


typedef enum piccommentoptype
{
	ConvertPicComments,
	DiscardPicComments
}
PicCommentOpType;


@interface PictConverter:AbstractConverter
{
	Instance	sourceFile,
			destFile;
	Instance	textConverter;
	Boolean	UsedPatterns,
			UsedColors,
			UsedLines,
			UsedText,
			UsedRectangles,
			UsedRoundRectangles,
			UsedOvals,
			UsedArcs,
			UsedPolygons,
			UsedRegions,
			UsedBitmaps,
			UsedComments,
			UsedMiscellaneous;
	CString	CodeDir;
	Boolean	PackingSetting;
	Boolean	UsersCharConvertChoice;
	Boolean	ConvertCurrentCharacters;
	PicCommentOpType	PicCommentOperation;
}

//
//	Administrative/ setup
//
- init;
- free;
- SetImagePacking: (Boolean) packimages UsingPSIn: (CString) newCodeDirectory;
- SetConvertAllChars: (Boolean) convertAll;
- SetPicCommentConversion: (PicCommentOpType) picConversion;
- (Boolean) isThisAGoodFile: theFile;
- (CString) SimpleStringConvert: (CString) theString;
- BuildHeaderInto: thisFile;
- AppendFile: (CString) codeFile To: thisFile;
- BuildPrologInto: thisFile;
- ConvertPICTfile: pictfile ToEPSfile: epsfile;
//
//	High level opcode parsers
//
- (Boolean) ParseOpcode: (PICTOpcode) opCode;
//
//	Opcode processing.
//
- (Boolean) ParseMiscOpcode: (PICTOpcode) opcode;
- (Boolean) ParseLineOpcode: (PICTOpcode) opcode;
- (Boolean) ParseTextOpcode: (PICTOpcode) opcode;
- (Boolean) ParseRectangleOpcode: (PICTOpcode) opcode;
- (Boolean) ParseRoundRectangleOpcode: (PICTOpcode) opcode;
- (Boolean) ParseOvalOpcode: (PICTOpcode) opcode;
- (Boolean) ParseArcOpcode: (PICTOpcode) opcode;
- (Boolean) ParsePolygonOpcode: (PICTOpcode) opcode;
- (Boolean) ParseRegionOpcode: (PICTOpcode) opcode;
- (Boolean) ParseBitmapOpcode: (PICTOpcode) opcode;
- (Boolean) ParseCommentOpcode: (PICTOpcode) opcode;
- ParseShortComment: (Integer) kind;
//
//	Processing utilities
//
- Skip2PlusData;
- Skip4PlusData;
- SkipSizedObject;
- ConvertHexBytes: (PositiveInteger) theBytes;
- WritePoint: (PICTPoint*) thePoint;
- WriteRect: (PICTRect*) theRect;
- WritePSProcedureName: (CString) theName;
//
//	Primary data conversion routines
//
- ConvertArc;
- ConvertAngles;
- ConvertPolygon;
- ConvertRegion;
- ConvertMode;
- ConvertFamily;
- ConvertFace;
- WriteString: (CString) theString;
- ConvertOldColor;
- ConvertRGBColor;
//
//	Bitmap and pattern processing
//
- ConvertInvertedHexBytes: (PositiveInteger) theBytes;
- ConvertPict1Pattern;
- ConvertPict2Pattern;
- GetPixMapFrom: SourceFile  Into: (modPixMap*) nativeMap;
- ConvertBitmapWithRegion: (Boolean) hasRegion PackedData: (Boolean) isPacked;
- ConvertDirectBitmapWithRegion: (Boolean) hasRegion;  // new with 1.2
- ConvertPackType1WithHeight: (Integer) dataHigh
				AndWidth: (Integer) rowBytes
				AndOffiset: (Integer) bitmapOffset; // New with 1.2
- ConvertPackType2WithHeight: (Integer) dataHigh
				AndWidth: (Integer) rowBytes
				AndOffiset: (Integer) bitmapOffset; // New with 1.2
- ConvertPackType4WithHeight: (Integer) dataHigh
				AndWidth: (Integer) rowBytes
				AndOffiset: (Integer) bitmapOffset;  // New with 1.2
- ExtractImageDataUsingDataWidth: (PositiveInteger) rawWidth
	Scanlines: (Integer) numLines
	ScanlineLength: (Integer) bytesPerScanline
	ScanlineStart: (Integer) bitOffset
	AndPixelDepth: (Integer) numBits
	IsCompressed: (Boolean)  sourcePacked
	UsesColor: (Boolean) ColorUsed;
- ConvertColorTable;
- Unpack: (PositiveInteger) numBytes
	BytesFrom:  (ByteString) sourceLine
	Into:  (ByteString) destLine;
-(PositiveInteger) Pack: (PositiveInteger) numBytes
	BytesFrom:  (ByteString) source
	Into:  (ByteString) dest;
- Invert: (Integer) numBytes In: (ByteString) theBuffer;
- (ByteString) Copy: (PositiveInteger) sourceSize
	BitsAtOffset: (PositiveInteger) offset
	From: (ByteString) source
	Into: (ByteString) dest;

@end

#define	ERR_APPENDFAILED	-30
#define	ERR_BADSOURCESIZE	201
#define	ERR_UNKNOWNPACK	-1000
#define	ERR_BADPACK			1001
#define	ERR_NOSIXTEEN		-1002

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.