Exemple #1
0
/* Draw a line */
static int
mac_draw_line (register gx_device *dev,
				  int x0, int y0,
				  int x1, int y1,
				  gx_color_index color)
{
	gx_device_macos		* mdev = (gx_device_macos *)dev;
	
	CheckMem(1024, 100*1024);
	ResetPage();
	
	GSSetFgCol(dev, mdev->currPicPos, color);
	PICT_Line(mdev->currPicPos, x0, y0, x1, y1);
	
	PICT_OpEndPicGoOn(mdev->currPicPos);
	
	return 0;
}
Exemple #2
0
/* Copy a monochrome bitmap. */
static int
mac_copy_mono (register gx_device *dev,
				  const unsigned char *base, int data_x, int raster, gx_bitmap_id id,
				  int x, int y, int w, int h,
				  gx_color_index color_0, gx_color_index color_1)
{
	gx_device_macos		* mdev = (gx_device_macos *)dev;
	
	int				byteCount = raster * h;
	short			copyMode;
	
	// this case doesn't change the picture -> return without wasting time
	if (color_0 == gx_no_color_index && color_1 == gx_no_color_index)
		return 0;
	
	fit_copy(dev, base, data_x, raster, id, x, y, w, h);
	
	CheckMem(10*1024 + byteCount*10,  100*1024 + byteCount*10);
	ResetPage();
	
	if (color_0 == gx_no_color_index)
		copyMode = srcOr;
	else if (color_1 == gx_no_color_index)
		copyMode = notSrcBic;	// this mode is untested ! (no file found which is using it)
	else
		copyMode = srcCopy;
	
	copyMode += ditherCopy;
	
	GSSetBkCol(dev, mdev->currPicPos, color_0);
	GSSetFgCol(dev, mdev->currPicPos, color_1);
	
	PICTWriteOpcode(mdev->currPicPos, 0x0098);
	PICTWriteInt(mdev->currPicPos, raster);
	PICTWriteRect(mdev->currPicPos, 0, 0, raster*8, h);
	PICTWriteRect(mdev->currPicPos, data_x, 0, w, h);
	PICTWriteRect(mdev->currPicPos, x, y, w, h);
	PICTWriteInt(mdev->currPicPos, copyMode);
	PICTWriteDataPackBits(mdev->currPicPos, base, raster, h);
	
	PICT_OpEndPicGoOn(mdev->currPicPos);
	
	return 0;
}
static int
mac_render_char(gx_xfont *xf, gx_xglyph xg, gx_device *dev,
				int xo, int yo, gx_color_index color, int required)
{
#pragma unused(dev,required)
	mac_xfont			* macxf = (mac_xfont*) xf;
	gx_device_macos		* mdev = (gx_device_macos*) macxf->dev;
	
	Str255				character;
	int					i, found;
	
	CheckMem(10*1024, 100*1024);
	ResetPage();
	
	character[0] = 1;
	character[1] = xg;
	
	GSSetFgCol(macxf->dev, mdev->currPicPos, color);
	
	found = 0;
	for (i=0; i<mdev->numUsedFonts; i++)
		if (mdev->usedFontIDs[i] == macxf->fontID)	found = 1;
	
	if (!found) {
		mdev->usedFontIDs[mdev->numUsedFonts++] = macxf->fontID;
		PICT_fontName(mdev->currPicPos, macxf->fontID, macxf->fontName);
	}
	if (mdev->lastFontID != macxf->fontID) {
		PICT_TxFont(mdev->currPicPos, macxf->fontID);
		mdev->lastFontID = macxf->fontID;
	}
	if (mdev->lastFontSize != macxf->fontSize) {
		PICT_TxSize(mdev->currPicPos, macxf->fontSize);
		mdev->lastFontSize = macxf->fontSize;
	}
	if (mdev->lastFontFace != macxf->fontFace) {
		PICT_TxFace(mdev->currPicPos, macxf->fontFace);
		mdev->lastFontFace = macxf->fontFace;
	}
	PICT_LongText(mdev->currPicPos, xo, yo, character);
	PICT_OpEndPicGoOn(mdev->currPicPos);
	
	return 0;
}
Exemple #4
0
/* Fill a rectangle with a color. */
static int
mac_fill_rectangle(register gx_device *dev,
					  int x, int y, int w, int h,
					  gx_color_index color)
{
	gx_device_macos		* mdev = (gx_device_macos *)dev;
	
	/* ignore a fullpage rect directly after an output_page, this would clear the pict */
	if (mdev->outputPage &&
			(x == 0) && (y == 0) && (w == mdev->width) && (h == mdev->height)) {
		return 0;
	}
	
	CheckMem(1024, 100*1024);
	ResetPage();
	
	GSSetFgCol(dev, mdev->currPicPos, color);
	PICT_fillRect(mdev->currPicPos, x, y, w, h);
	
	PICT_OpEndPicGoOn(mdev->currPicPos);
	
	return 0;
}
Exemple #5
0
/* Copy a color bitmap. */
static int
mac_copy_color (register gx_device *dev,
				const unsigned char *base, int data_x, int raster,  gx_bitmap_id id,
				int x, int y, int w, int h)
{
	gx_device_macos		* mdev = (gx_device_macos *)dev;
	
	int				byteCount = raster * h, color;
	gx_color_value	rgb[3];
	
	fit_copy(dev, base, data_x, raster, id, x, y, w, h);
	
	CheckMem(10*1024 + byteCount*4, 100*1024 + byteCount*4);
	ResetPage();
	
	GSSetStdCol(mdev->currPicPos);		// Sets FgCol to Black and BkCol to White
	
	if (mdev->color_info.depth == 24) {
		PICTWriteOpcode(mdev->currPicPos, 0x009A);
		PICTWriteLong(mdev->currPicPos, 0x000000FF);
		PICTWritePixMap(mdev->currPicPos, 0, 0, raster/4, h, raster, 2, 0,
						X2Fix(mdev->x_pixels_per_inch), X2Fix(mdev->y_pixels_per_inch), 32);
		PICTWriteRect(mdev->currPicPos, data_x, 0, w, h);
		PICTWriteRect(mdev->currPicPos, x, y, w, h);
		PICTWriteInt(mdev->currPicPos, srcCopy);
		
/*		memcpy(mdev->currPicPos, base, byteCount);
		(char*)(mdev->currPicPos) += byteCount;*/
		
		{
			short	i;
			byteCount = 0;
			
			for (i=0; i<raster/4*h; i++) {
			//	PICTWriteByte(mdev->currPicPos, 0x00);
				PICTWriteByte(mdev->currPicPos, 0x00);
				PICTWriteByte(mdev->currPicPos, 0x00);
				PICTWriteByte(mdev->currPicPos, 0x00);
				byteCount += 3;
			}
		}
		
		if (byteCount % 2)
			PICTWriteFillByte(mdev->currPicPos);
		
	} else if (mdev->color_info.depth <= 8) {
		ColorSpec		*colorTable;
		
		colorTable = (ColorSpec*) malloc(sizeof(ColorSpec) * (1 << mdev->color_info.depth));
		for (color=0; color < (1 << mdev->color_info.depth); color++) {
			(*dev_proc(dev, map_color_rgb))(dev, color, rgb);
			colorTable[color].value		= color;
			colorTable[color].rgb.red	= rgb[0];
			colorTable[color].rgb.green	= rgb[1];
			colorTable[color].rgb.blue	= rgb[2];
		}
		
		PICTWriteOpcode(mdev->currPicPos, 0x0098);
		PICTWritePixMap(mdev->currPicPos, 0, 0, raster*8/mdev->color_info.depth, h, raster, 1, 0,
						X2Fix(mdev->x_pixels_per_inch), X2Fix(mdev->y_pixels_per_inch),
						mdev->color_info.depth);
		PICTWriteColorTable(mdev->currPicPos, 0, (1 << mdev->color_info.depth), colorTable);
		PICTWriteRect(mdev->currPicPos, data_x, 0, w, h);
		PICTWriteRect(mdev->currPicPos, x, y, w, h);
		PICTWriteInt(mdev->currPicPos, srcCopy);
		
		PICTWriteDataPackBits(mdev->currPicPos, base, raster, h);
		
		free(colorTable);
	} else {
		gx_default_copy_color( dev, base, data_x, raster, id, x, y, w, h );
	}
	
	PICT_OpEndPicGoOn(mdev->currPicPos);
	
	return 0;
}
Exemple #6
0
/* that's why this will only work on a fully white background!!!! */
static int
mac_copy_alpha(gx_device *dev, const unsigned char *base, int data_x,
		   int raster, gx_bitmap_id id, int x, int y, int w, int h,
		   gx_color_index color, int depth)
{
	gx_device_macos		* mdev = (gx_device_macos *)dev;
	
	ColorSpec			*colorTable;
	short				copyMode, shade, maxShade = (1 << depth) - 1, byteCount = raster * h;
	gx_color_value		rgb[3];
	colorHSV			colHSV;
	colorRGB			colRGB;
	float				saturation, value;
	
	fit_copy(dev, base, data_x, raster, id, x, y, w, h);
	
	CheckMem( byteCount*4 + 200*1024, byteCount*4 + 500*1024 );
	ResetPage();
	
	colorTable = (ColorSpec*) malloc(sizeof(ColorSpec) * (maxShade+1));
	if (colorTable == NULL)
		return gs_error_VMerror;
	
	(*dev_proc(dev, map_color_rgb))(dev, color, rgb);
	colRGB.red = rgb[0];
	colRGB.green = rgb[1];
	colRGB.blue = rgb[2];
	mac_convert_rgb_hsv(&colRGB, &colHSV);
	saturation = colHSV.s;
	value = colHSV.v;
	
	for (shade=0; shade <= maxShade; shade++) {
		colorTable[shade].value = maxShade -  shade;
		
		colHSV.s = saturation * (1.0 - (float)shade/(float)maxShade);
		colHSV.v = value + ((1.0 - value) * (float)shade/(float)maxShade);
		
		mac_convert_hsv_rgb(&colHSV, &colRGB);
		colorTable[shade].rgb.red   = colRGB.red;
		colorTable[shade].rgb.green = colRGB.green;
		colorTable[shade].rgb.blue  = colRGB.blue;
	}
	copyMode = srcCopy + ditherCopy;
	
	GSSetStdCol(mdev->currPicPos);
	
	if (raster < 8) {
		PICTWriteOpcode(mdev->currPicPos, 0x0090);
	} else {
		PICTWriteOpcode(mdev->currPicPos, 0x0098);
	}
	PICTWritePixMap(mdev->currPicPos, 0, 0, raster*8/depth, h, raster, 0, 0,
					X2Fix(mdev->x_pixels_per_inch), X2Fix(mdev->y_pixels_per_inch), depth);
	PICTWriteColorTable(mdev->currPicPos, 0, maxShade+1, colorTable);
	PICTWriteRect(mdev->currPicPos, data_x, 0, w, h);
	PICTWriteRect(mdev->currPicPos, x, y, w, h);
	PICTWriteInt(mdev->currPicPos, copyMode);
	PICTWriteDataPackBits(mdev->currPicPos, base, raster, h);
	
	PICT_OpEndPicGoOn(mdev->currPicPos);
	
	free(colorTable);
	
	return 0;
}