Пример #1
0
static const char *colorstring(float r, float g, float b)
{
    static char buffer[10];
    sprintf_s(TARGETWITHLEN(buffer,10), "%s%.2x%.2x%.2x", "#", (unsigned int) (r * 255),
              (unsigned int) (g * 255), (unsigned int) (b * 255));
    return buffer;
}
Пример #2
0
void drvFIG::show_image(const PSImage & imageinfo)
{
	if (outBaseName == "") {
		errf << "images cannot be handled via standard output. Use an output file " << endl;
		return;
	}
	if (imageinfo.isFileImage) {
		// use imageinfo.FileName;
		/* 
		outf << "<image "		 
			<< " transform=\"matrix("
			<< imageinfo.normalizedImageCurrentMatrix[0] << ' '
			<< -imageinfo.normalizedImageCurrentMatrix[1] << ' '
			<< imageinfo.normalizedImageCurrentMatrix[2] << ' '
			<< -imageinfo.normalizedImageCurrentMatrix[3] << ' '
// transfer
			<< imageinfo.normalizedImageCurrentMatrix[4] << ' '
			<< currentDeviceHeight - imageinfo.normalizedImageCurrentMatrix[5]
			<< ")\"" 
			<< " width=\"" << imageinfo.width << "\"" 
			<< " height=\"" << imageinfo.height << "\"" 
			<< " xlink:href=\"" << imageinfo.FileName << "\"></image>" << endl;
    */

	Point ll, ur;
	imageinfo.getBoundingBox(ll, ur);
// Calculate BBox
	addtobbox(ll);
	addtobbox(ur);
	Point fig_ur(PntFig * ur.x_, y_offset - PntFig * ll.y_);
	Point fig_ll(PntFig * ll.x_, y_offset - PntFig * ur.y_);

	// first output link to an external *.eps file into *.fig file
	buffer << "# image\n";
	new_depth();
	buffer << "2 5 0 1 -1 -1 ";
	if (objectId)
		objectId--;				// don't let it get < 0
	buffer << objectId << " 0 -1 0.000 0 0 -1 0 0 5\n";
	buffer << "\t0 " << imageinfo.FileName << "\n";

	buffer << "\t" << (int) fig_ll.x_ << " " << (int) fig_ll.y_ << " "
		<< (int) fig_ur.x_ << " " << (int) fig_ll.y_ << " "
		<< (int) fig_ur.x_ << " " << (int) fig_ur.y_ << " "
		<< (int) fig_ll.x_ << " " << (int) fig_ur.y_ << " "
		<< (int) fig_ll.x_ << " " << (int) fig_ll.y_;
	buffer << "\n";



	} else {
	const size_t filenamelen = strlen(outBaseName.value()) + 21;
	char *EPSoutFileName = new char[filenamelen];
	const size_t fullfilenamelen = strlen(outDirName.value()) + strlen(outBaseName.value()) + 21;
	char *EPSoutFullFileName = new char[fullfilenamelen];

	sprintf_s(TARGETWITHLEN(EPSoutFileName,filenamelen), "%s%02d.eps", outBaseName.value(), imgcount++);
	sprintf_s(TARGETWITHLEN(EPSoutFullFileName,fullfilenamelen), "%s%s", outDirName.value(), EPSoutFileName);
	ofstream outi(EPSoutFullFileName);
	if (!outi) {
		errf << "Could not open file " << EPSoutFullFileName << " for output";
		exit(1);
	}
	// remember, we have to flip the image from PostScript coord to fig coords
	Point ll, ur;
	imageinfo.getBoundingBox(ll, ur);
// Calculate BBox
	addtobbox(ll);
	addtobbox(ur);
	Point fig_ur(PntFig * ur.x_, y_offset - PntFig * ll.y_);
	Point fig_ll(PntFig * ll.x_, y_offset - PntFig * ur.y_);

	// first output link to an external *.eps file into *.fig file
	buffer << "# image\n";
	new_depth();
	buffer << "2 5 0 1 -1 -1 ";
	if (objectId)
		objectId--;				// don't let it get < 0
	buffer << objectId << " 0 -1 0.000 0 0 -1 0 0 5\n";
	buffer << "\t0 " << EPSoutFileName << "\n";

	buffer << "\t" << (int) fig_ll.x_ << " " << (int) fig_ll.y_ << " "
		<< (int) fig_ur.x_ << " " << (int) fig_ll.y_ << " "
		<< (int) fig_ur.x_ << " " << (int) fig_ur.y_ << " "
		<< (int) fig_ll.x_ << " " << (int) fig_ur.y_ << " "
		<< (int) fig_ll.x_ << " " << (int) fig_ll.y_;
	buffer << "\n";



	imageinfo.writeEPSImage(outi);
	outi.close();

	delete[]EPSoutFullFileName;
	delete[]EPSoutFileName;
	}
}
Пример #3
0
void drvJAVA2::show_image(const PSImage & imageinfo)
{
	if (outBaseName == "") {
		errf << "images cannot be handled via standard output. Use an output file" << endl;
		return;
	}
	// write image data to separate file
	const size_t sizefilename = strlen(outBaseName.value()) + 21;
	char *imgOutFileName = new char[sizefilename];
	const size_t sizefullfilename = strlen(outDirName.value()) + strlen(outBaseName.value()) + 21;
	char *imgOutFullFileName = new char[sizefullfilename];

	sprintf_s(TARGETWITHLEN(imgOutFileName,sizefilename), "%s_%d.img", outBaseName.value(), numberOfImages);
	sprintf_s(TARGETWITHLEN(imgOutFullFileName,sizefullfilename), "%s%s", outDirName.value(), imgOutFileName);
	outf << "    currentPage.add(new PSImageObject(" << imageinfo.
		width << ", " << imageinfo.height << ", ";
	outf << imageinfo.bits << ", " << imageinfo.ncomp << ", ";
	switch (imageinfo.type) {
	case colorimage:
		outf << "0, ";
		break;
	case normalimage:
		outf << "1, ";
		break;
	case imagemask:
		outf << "2, ";
		break;
	default:
		errf << "\t\tFatal: unexpected case for imageinfo.type in drvjava2" << endl;	// cannot happen
		abort();
	}
	outf << (imageinfo.polarity ? "true" : "false") << "," << endl;
	outf << "      new AffineTransform(";
	outf << (imageinfo.normalizedImageCurrentMatrix[0]) << "f, ";
	outf << (-imageinfo.normalizedImageCurrentMatrix[1]) << "f, ";
	outf << (imageinfo.normalizedImageCurrentMatrix[2]) << "f, ";
	outf << (-imageinfo.normalizedImageCurrentMatrix[3]) << "f, ";
	outf << (imageinfo.normalizedImageCurrentMatrix[4]) << "f, ";
	outf << (currentDeviceHeight - imageinfo.normalizedImageCurrentMatrix[5]) << "f), " << endl;
	outf << "      \"" << imgOutFileName << "\"));" << endl;
	FILE *outFile;
	if ((outFile = fopen(imgOutFileName, "wb")) == 0L) {
		errf << "ERROR: cannot open image file " << imgOutFileName << endl;
		delete[]imgOutFileName;
		delete[]imgOutFullFileName;
		return;
	}
	if (fwrite(imageinfo.data, 1, imageinfo.nextfreedataitem, outFile) !=
		imageinfo.nextfreedataitem) {
		fclose(outFile);
		errf << "ERROR: cannot write image data to " << imgOutFileName << endl;
		delete[]imgOutFileName;
		delete[]imgOutFullFileName;
		return;
	}
	fclose(outFile);
	delete[]imgOutFullFileName;
	delete[]imgOutFileName;
	numberOfImages++;
	numberOfElements++;
}