Wrong directory!
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2760 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,292 +0,0 @@
|
||||
/*
|
||||
* PCL6.cpp
|
||||
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
||||
* Copyright 2003 Michael Pfeiffer.
|
||||
*/
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Bitmap.h>
|
||||
#include <File.h>
|
||||
#include <memory>
|
||||
#include "PCL6.h"
|
||||
#include "UIDriver.h"
|
||||
#include "JobData.h"
|
||||
#include "PrinterData.h"
|
||||
#include "PCL6Cap.h"
|
||||
#include "PackBits.h"
|
||||
#include "Halftone.h"
|
||||
#include "ValidRect.h"
|
||||
#include "DbgMsg.h"
|
||||
|
||||
#if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
|
||||
using namespace std;
|
||||
#else
|
||||
#define std
|
||||
#endif
|
||||
|
||||
PCL6Driver::PCL6Driver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap)
|
||||
: GraphicsDriver(msg, printer_data, printer_cap)
|
||||
{
|
||||
__halftone = NULL;
|
||||
__stream = NULL;
|
||||
}
|
||||
|
||||
void PCL6Driver::FlushOutBuffer(HP_StreamHandleType pStream, unsigned long cookie, HP_pUByte pOutBuffer, HP_SInt32 currentBufferLen)
|
||||
{
|
||||
writeSpoolData(pOutBuffer, currentBufferLen);
|
||||
}
|
||||
|
||||
|
||||
bool PCL6Driver::startDoc()
|
||||
{
|
||||
try {
|
||||
jobStart();
|
||||
__halftone = new Halftone(getJobData()->getSurfaceType(), getJobData()->getGamma());
|
||||
return true;
|
||||
}
|
||||
catch (TransportException &err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool PCL6Driver::startPage(int)
|
||||
{
|
||||
// XXX orientation
|
||||
HP_BeginPage_1(__stream, HP_ePortraitOrientation, mediaSize(getJobData()->getPaper()));
|
||||
HP_SetPageOrigin_1(__stream, 0, 0); // XXX
|
||||
HP_SetColorSpace_1(__stream, HP_eGray);
|
||||
HP_SetPaintTxMode_1(__stream, HP_eOpaque);
|
||||
HP_SetSourceTxMode_1(__stream, HP_eOpaque);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PCL6Driver::endPage(int)
|
||||
{
|
||||
try {
|
||||
HP_EndPage_2(__stream, getJobData()->getCopies());
|
||||
return true;
|
||||
}
|
||||
catch (TransportException &err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool PCL6Driver::endDoc(bool)
|
||||
{
|
||||
try {
|
||||
if (__halftone) {
|
||||
delete __halftone;
|
||||
}
|
||||
jobEnd();
|
||||
return true;
|
||||
}
|
||||
catch (TransportException &err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool PCL6Driver::nextBand(BBitmap *bitmap, BPoint *offset)
|
||||
{
|
||||
DBGMSG(("> nextBand\n"));
|
||||
|
||||
try {
|
||||
BRect bounds = bitmap->Bounds();
|
||||
|
||||
RECT rc;
|
||||
rc.left = (int)bounds.left;
|
||||
rc.top = (int)bounds.top;
|
||||
rc.right = (int)bounds.right;
|
||||
rc.bottom = (int)bounds.bottom;
|
||||
|
||||
int height = rc.bottom - rc.top + 1;
|
||||
|
||||
int x = (int)offset->x;
|
||||
int y = (int)offset->y;
|
||||
|
||||
int page_height = getPageHeight();
|
||||
|
||||
if (y + height > page_height) {
|
||||
height = page_height - y;
|
||||
}
|
||||
|
||||
rc.bottom = height - 1;
|
||||
|
||||
DBGMSG(("height = %d\n", height));
|
||||
DBGMSG(("x = %d\n", x));
|
||||
DBGMSG(("y = %d\n", y));
|
||||
|
||||
if (get_valid_rect(bitmap, __halftone->getPalette(), &rc)) {
|
||||
|
||||
DBGMSG(("validate rect = %d, %d, %d, %d\n",
|
||||
rc.left, rc.top, rc.right, rc.bottom));
|
||||
|
||||
x = rc.left;
|
||||
y += rc.top;
|
||||
|
||||
int width = rc.right - rc.left + 1;
|
||||
int widthByte = (width + 7) / 8; /* byte boundary */
|
||||
int padBytes = ((width + 31) / 32) * 4 - widthByte; /* line length is a multiple of 4 bytes */
|
||||
int out_row_length = widthByte + padBytes;
|
||||
int height = rc.bottom - rc.top + 1;
|
||||
int out_size = out_row_length * height;
|
||||
int delta = bitmap->BytesPerRow();
|
||||
|
||||
DBGMSG(("width = %d\n", width));
|
||||
DBGMSG(("widthByte = %d\n", widthByte));
|
||||
DBGMSG(("height = %d\n", height));
|
||||
DBGMSG(("out_size = %d\n", out_size));
|
||||
DBGMSG(("delta = %d\n", delta));
|
||||
DBGMSG(("renderobj->get_pixel_depth() = %d\n", __halftone->getPixelDepth()));
|
||||
|
||||
uchar *ptr = (uchar *)bitmap->Bits()
|
||||
+ rc.top * delta
|
||||
+ (rc.left * __halftone->getPixelDepth()) / 8;
|
||||
|
||||
int compression_method;
|
||||
int compressed_size;
|
||||
const uchar *buffer;
|
||||
|
||||
uchar *out_buffer = new uchar[out_size];
|
||||
|
||||
uchar *out_ptr = out_buffer;
|
||||
|
||||
auto_ptr<uchar> _out_buffer(out_buffer);
|
||||
|
||||
DBGMSG(("move\n"));
|
||||
|
||||
move(x, y);
|
||||
startRasterGraphics(x, y, width, height);
|
||||
|
||||
compression_method = 0; // uncompressed
|
||||
buffer = out_buffer;
|
||||
compressed_size = out_size;
|
||||
|
||||
// dither entire band into out_buffer
|
||||
for (int i = rc.top; i <= rc.bottom; i++) {
|
||||
__halftone->dither(out_ptr, ptr, x, y, width);
|
||||
// invert pixels
|
||||
uchar* out = out_ptr;
|
||||
for (int w = widthByte; w > 0; w --, out ++) {
|
||||
*out = ~*out;
|
||||
}
|
||||
// pad with 0s
|
||||
for (int w = padBytes; w > 0; w --, out ++) {
|
||||
*out = 0;
|
||||
}
|
||||
|
||||
ptr += delta;
|
||||
out_ptr += out_row_length;
|
||||
y++;
|
||||
}
|
||||
|
||||
rasterGraphics(
|
||||
compression_method,
|
||||
buffer,
|
||||
compressed_size);
|
||||
|
||||
endRasterGraphics();
|
||||
|
||||
} else {
|
||||
DBGMSG(("band bitmap is clean.\n"));
|
||||
}
|
||||
|
||||
if (y >= page_height) {
|
||||
offset->x = -1.0;
|
||||
offset->y = -1.0;
|
||||
} else {
|
||||
offset->y += height;
|
||||
}
|
||||
|
||||
DBGMSG(("< nextBand\n"));
|
||||
return true;
|
||||
}
|
||||
catch (TransportException &err) {
|
||||
BAlert *alert = new BAlert("", err.what(), "OK");
|
||||
alert->Go();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void PCL6Driver::jobStart()
|
||||
{
|
||||
// PJL header
|
||||
writeSpoolString("\033%%-12345X@PJL JOB\n"
|
||||
"PJL ENTER LANGUAGE=PCLXL\n"
|
||||
") HP-PCL XL;1;1;"
|
||||
"Comment Copyright (c) 2003 OBOS\n");
|
||||
// PCL6 begin
|
||||
__stream = HP_NewStream(16 * 1024, this);
|
||||
HP_BeginSession_1(__stream, getJobData()->getXres(), getJobData()->getYres(), HP_eInch);
|
||||
HP_OpenDataSource_1(__stream, HP_eDefaultDataSource, HP_eBinaryLowByteFirst);
|
||||
}
|
||||
|
||||
void PCL6Driver::startRasterGraphics(int x, int y, int width, int height)
|
||||
{
|
||||
__compression_method = -1;
|
||||
HP_BeginImage_1(__stream, HP_eDirectPixel, HP_e1Bit, width, height, width, height);
|
||||
HP_ReadImage_1(__stream, 0, height, HP_eNoCompression);
|
||||
}
|
||||
|
||||
void PCL6Driver::endRasterGraphics()
|
||||
{
|
||||
}
|
||||
|
||||
void PCL6Driver::rasterGraphics(
|
||||
int compression_method,
|
||||
const uchar *buffer,
|
||||
int size)
|
||||
{
|
||||
if (__compression_method != compression_method) {
|
||||
__compression_method = compression_method;
|
||||
}
|
||||
HP_EmbeddedDataPrefix32(__stream, size);
|
||||
HP_RawUByteArray(__stream, (uchar*)buffer, size);
|
||||
}
|
||||
|
||||
void PCL6Driver::jobEnd()
|
||||
{
|
||||
HP_CloseDataSource_1(__stream);
|
||||
HP_EndSession_1(__stream);
|
||||
HP_FinishStream(__stream);
|
||||
// PJL footer
|
||||
writeSpoolString("\033%%-12345X@PJL EOJ\n"
|
||||
"\033%%-12345X");
|
||||
}
|
||||
|
||||
void PCL6Driver::move(int x, int y)
|
||||
{
|
||||
// XXX optimise use "smallest" data type
|
||||
HP_SetCursor_3(__stream, x, y);
|
||||
}
|
||||
|
||||
HP_UByte PCL6Driver::mediaSize(JobData::PAPER paper)
|
||||
{
|
||||
switch (paper) {
|
||||
case JobData::LETTER: return HP_eLetterPaper;
|
||||
case JobData::LEGAL: return HP_eLegalPaper;
|
||||
case JobData::A4: return HP_eA4Paper;
|
||||
case JobData::EXECUTIVE: return HP_eExecPaper;
|
||||
case JobData::LEDGER: return HP_eLedgerPaper;
|
||||
case JobData::A3: return HP_eA3Paper;
|
||||
/*
|
||||
case : return HP_eCOM10Envelope;
|
||||
case : return HP_eMonarchEnvelope;
|
||||
case : return HP_eC5Envelope;
|
||||
case : return HP_eDLEnvelope;
|
||||
case : return HP_eJB4Paper;
|
||||
case : return HP_eJB5Paper;
|
||||
case : return HP_eB5Envelope;
|
||||
case : return HP_eB5Paper;
|
||||
case : return HP_eJPostcard;
|
||||
case : return HP_eJDoublePostcard;
|
||||
case : return HP_eA5Paper;
|
||||
case : return HP_eA6Paper;
|
||||
case : return HP_eJB6Paper;
|
||||
case : return HP_eJIS8KPaper;
|
||||
case : return HP_eJIS16KPaper;
|
||||
case : return HP_eJISExecPaper;
|
||||
*/
|
||||
default: HP_eLegalPaper;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* PCL5.h
|
||||
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef __PCL6_H
|
||||
#define __PCL6_H
|
||||
|
||||
#include "GraphicsDriver.h"
|
||||
#include "jetlib.h"
|
||||
|
||||
class Halftone;
|
||||
|
||||
class PCL6Driver : public GraphicsDriver, private MJetlibClient {
|
||||
public:
|
||||
PCL6Driver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap);
|
||||
|
||||
virtual void FlushOutBuffer(HP_StreamHandleType pStream,
|
||||
unsigned long cookie,
|
||||
HP_pUByte pOutBuffer,
|
||||
HP_SInt32 currentBufferLen);
|
||||
|
||||
protected:
|
||||
virtual bool startDoc();
|
||||
virtual bool startPage(int page);
|
||||
virtual bool nextBand(BBitmap *bitmap, BPoint *offset);
|
||||
virtual bool endPage(int page);
|
||||
virtual bool endDoc(bool success);
|
||||
|
||||
private:
|
||||
HP_UByte mediaSize(JobData::PAPER paper);
|
||||
void move(int x, int y);
|
||||
void jobStart();
|
||||
void startRasterGraphics(int x, int y, int width, int height);
|
||||
void endRasterGraphics();
|
||||
void rasterGraphics(
|
||||
int compression_method,
|
||||
const uchar *buffer,
|
||||
int size);
|
||||
void jobEnd();
|
||||
|
||||
HP_StreamHandleType __stream;
|
||||
int __compression_method;
|
||||
Halftone *__halftone;
|
||||
};
|
||||
|
||||
#endif /* __PCL5_H */
|
||||
Binary file not shown.
@@ -1,149 +0,0 @@
|
||||
/*
|
||||
* PCL6Cap.cpp
|
||||
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "PrinterData.h"
|
||||
#include "PCL6Cap.h"
|
||||
|
||||
#define TO72DPI(a) (a * 72.0f / 600.0f)
|
||||
|
||||
const PaperCap a3(
|
||||
"A3",
|
||||
false,
|
||||
JobData::A3,
|
||||
BRect(0.0f, 0.0f, TO72DPI(7014.0f), TO72DPI(9920.0f)),
|
||||
BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(6894.0f), TO72DPI(9800.0f)));
|
||||
|
||||
const PaperCap a4(
|
||||
"A4",
|
||||
true,
|
||||
JobData::A4,
|
||||
BRect(0.0f, 0.0f, TO72DPI(4960.0f), TO72DPI(7014.0f)),
|
||||
BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(4840.0f), TO72DPI(6894.0f)));
|
||||
|
||||
const PaperCap a5(
|
||||
"A5",
|
||||
false,
|
||||
JobData::A5,
|
||||
BRect(0.0f, 0.0f, TO72DPI(3506.0f), TO72DPI(4960.0f)),
|
||||
BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(3386.0f), TO72DPI(4840.0f)));
|
||||
|
||||
const PaperCap japanese_postcard(
|
||||
"Japanese Postcard",
|
||||
false,
|
||||
JobData::JAPANESE_POSTCARD,
|
||||
BRect(0.0f, 0.0f, TO72DPI(2362.0f), TO72DPI(3506.0f)),
|
||||
BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(2242.0f), TO72DPI(3386.0f)));
|
||||
|
||||
const PaperCap b4(
|
||||
"B4",
|
||||
false,
|
||||
JobData::B4,
|
||||
BRect(0.0f, 0.0f, TO72DPI(6070.0f), TO72DPI(8598.0f)),
|
||||
BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(5950.0f), TO72DPI(8478.0f)));
|
||||
|
||||
const PaperCap b5(
|
||||
"B5",
|
||||
false,
|
||||
JobData::B5,
|
||||
BRect(0.0f, 0.0f, TO72DPI(4298.0f), TO72DPI(6070.0f)),
|
||||
BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(4178.0f), TO72DPI(5950.0f)));
|
||||
|
||||
const PaperCap letter(
|
||||
"Letter",
|
||||
false,
|
||||
JobData::LETTER,
|
||||
BRect(0.0f, 0.0f, TO72DPI(5100.0f), TO72DPI(6600.0f)),
|
||||
BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(4980.0f), TO72DPI(6480.0f)));
|
||||
|
||||
const PaperCap legal(
|
||||
"Legal",
|
||||
false,
|
||||
JobData::LEGAL,
|
||||
BRect(0.0f, 0.0f, TO72DPI(5100.0f), TO72DPI(8400.0f)),
|
||||
BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(4980.0f), TO72DPI(8280.0f)));
|
||||
|
||||
const PaperSourceCap autobin("Auto", true, JobData::AUTO);
|
||||
|
||||
const ResolutionCap dpi300("300dpi", true, 300, 300);
|
||||
const ResolutionCap dpi600("600dpi", false, 600, 600);
|
||||
const ResolutionCap dpi1200("1200dpi", false, 1200, 1200);
|
||||
|
||||
const PaperCap *papers[] = {
|
||||
&a4,
|
||||
&a3,
|
||||
&a5,
|
||||
&b4,
|
||||
&b5,
|
||||
&letter,
|
||||
&legal
|
||||
};
|
||||
|
||||
const PaperSourceCap *papersources[] = {
|
||||
&autobin,
|
||||
};
|
||||
|
||||
const ResolutionCap *resolutions[] = {
|
||||
&dpi300,
|
||||
&dpi600,
|
||||
&dpi1200,
|
||||
};
|
||||
|
||||
const ColorCap color("Color", false, JobData::kCOLOR);
|
||||
const ColorCap monochrome("Monochrome", true, JobData::kMONOCHROME);
|
||||
|
||||
const ColorCap *colors[] = {
|
||||
// &color,
|
||||
&monochrome
|
||||
};
|
||||
|
||||
PCL6Cap::PCL6Cap(const PrinterData *printer_data)
|
||||
: PrinterCap(printer_data)
|
||||
{
|
||||
}
|
||||
|
||||
int PCL6Cap::countCap(CAPID capid) const
|
||||
{
|
||||
switch (capid) {
|
||||
case PAPER:
|
||||
return sizeof(papers) / sizeof(papers[0]);
|
||||
case PAPERSOURCE:
|
||||
return sizeof(papersources) / sizeof(papersources[0]);
|
||||
case RESOLUTION:
|
||||
return sizeof(resolutions) / sizeof(resolutions[0]);
|
||||
case COLOR:
|
||||
return sizeof(colors) / sizeof(colors[0]);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
const BaseCap **PCL6Cap::enumCap(CAPID capid) const
|
||||
{
|
||||
switch (capid) {
|
||||
case PAPER:
|
||||
return (const BaseCap **)papers;
|
||||
case PAPERSOURCE:
|
||||
return (const BaseCap **)papersources;
|
||||
case RESOLUTION:
|
||||
return (const BaseCap **)resolutions;
|
||||
case COLOR:
|
||||
return (const BaseCap **)colors;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool PCL6Cap::isSupport(CAPID capid) const
|
||||
{
|
||||
switch (capid) {
|
||||
case PAPER:
|
||||
case PAPERSOURCE:
|
||||
case RESOLUTION:
|
||||
case COLOR:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
* PCL5Cap.h
|
||||
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef __PCL5CAP_H
|
||||
#define __PCL5CAP_H
|
||||
|
||||
#include "PrinterCap.h"
|
||||
|
||||
class PCL6Cap : public PrinterCap {
|
||||
public:
|
||||
PCL6Cap(const PrinterData *printer_data);
|
||||
virtual int countCap(CAPID) const;
|
||||
virtual bool isSupport(CAPID) const;
|
||||
virtual const BaseCap **enumCap(CAPID) const;
|
||||
};
|
||||
|
||||
#endif /* __PCL5CAP_H */
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* PCL6Entry.cpp
|
||||
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
||||
* Copyright 2003 Michael Pfeiffer.
|
||||
*/
|
||||
|
||||
#include <File.h>
|
||||
#include <Message.h>
|
||||
#include <Node.h>
|
||||
|
||||
#include "Exports.h"
|
||||
#include "PCL6.h"
|
||||
#include "PrinterData.h"
|
||||
#include "PCL6Cap.h"
|
||||
#include "UIDriver.h"
|
||||
#include "AboutBox.h"
|
||||
#include "DbgMsg.h"
|
||||
|
||||
char *add_printer(char *printer_name)
|
||||
{
|
||||
DBGMSG((">PCL6: add_printer\n"));
|
||||
DBGMSG(("\tprinter_name: %s\n", printer_name));
|
||||
DBGMSG(("<PCL6: add_printer\n"));
|
||||
return printer_name;
|
||||
}
|
||||
|
||||
BMessage *config_page(BNode *node, BMessage *msg)
|
||||
{
|
||||
DBGMSG((">PCL6: config_page\n"));
|
||||
DUMP_BMESSAGE(msg);
|
||||
DUMP_BNODE(node);
|
||||
|
||||
PrinterData printer_data(node);
|
||||
PCL6Cap printer_cap(&printer_data);
|
||||
UIDriver drv(msg, &printer_data, &printer_cap);
|
||||
BMessage *result = drv.configPage();
|
||||
|
||||
DUMP_BMESSAGE(result);
|
||||
DBGMSG(("<PCL6: config_page\n"));
|
||||
return result;
|
||||
}
|
||||
|
||||
BMessage *config_job(BNode *node, BMessage *msg)
|
||||
{
|
||||
DBGMSG((">PCL6: config_job\n"));
|
||||
DUMP_BMESSAGE(msg);
|
||||
DUMP_BNODE(node);
|
||||
|
||||
PrinterData printer_data(node);
|
||||
PCL6Cap printer_cap(&printer_data);
|
||||
UIDriver drv(msg, &printer_data, &printer_cap);
|
||||
BMessage *result = drv.configJob();
|
||||
|
||||
DUMP_BMESSAGE(result);
|
||||
DBGMSG(("<PCL6: config_job\n"));
|
||||
return result;
|
||||
}
|
||||
|
||||
BMessage *take_job(BFile *spool, BNode *node, BMessage *msg)
|
||||
{
|
||||
DBGMSG((">PCL6: take_job\n"));
|
||||
DUMP_BMESSAGE(msg);
|
||||
DUMP_BNODE(node);
|
||||
|
||||
PrinterData printer_data(node);
|
||||
PCL6Cap printer_cap(&printer_data);
|
||||
PCL6Driver drv(msg, &printer_data, &printer_cap);
|
||||
BMessage *result = drv.takeJob(spool);
|
||||
|
||||
// DUMP_BMESSAGE(result);
|
||||
DBGMSG(("<PCL6: take_job\n"));
|
||||
return result;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
AboutBox app("application/x-vnd.PCL6-compatible", "PCL6 Compatible", "0.1",
|
||||
"libprint Copyright © 1999-2000 Y.Takagi\n"
|
||||
"PCL6 driver Copyright © 2003 Michael Pfeiffer.\n"
|
||||
"All Rights Reserved.");
|
||||
app.Run();
|
||||
return 0;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user