Style cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37370 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,45 +1,57 @@
|
|||||||
/*
|
/*
|
||||||
** DeltaRowCompression.cpp
|
** DeltaRowCompression.cpp
|
||||||
** Copyright 2005, Michael Pfeiffer, [email protected]. All rights reserved.
|
** Copyright 2005, Michael Pfeiffer, [email protected].
|
||||||
|
** All rights reserved.
|
||||||
** Distributed under the terms of the OpenBeOS License.
|
** Distributed under the terms of the OpenBeOS License.
|
||||||
*/
|
*/
|
||||||
#include "DeltaRowCompression.h"
|
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
|
||||||
|
#include "DeltaRowCompression.h"
|
||||||
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
|
||||||
AbstractDeltaRowCompressor::AbstractDeltaRowCompressor(int rowSize, uchar initialSeed)
|
#include <SupportDefs.h>
|
||||||
: fSeedRow(new uchar[rowSize])
|
|
||||||
, fSize(rowSize)
|
|
||||||
, fInitialSeed(initialSeed)
|
AbstractDeltaRowCompressor::AbstractDeltaRowCompressor(int rowSize,
|
||||||
|
uchar initialSeed)
|
||||||
|
:
|
||||||
|
fSeedRow(new uchar[rowSize]),
|
||||||
|
fSize(rowSize),
|
||||||
|
fInitialSeed(initialSeed)
|
||||||
{
|
{
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AbstractDeltaRowCompressor::~AbstractDeltaRowCompressor()
|
AbstractDeltaRowCompressor::~AbstractDeltaRowCompressor()
|
||||||
{
|
{
|
||||||
delete fSeedRow;
|
delete fSeedRow;
|
||||||
fSeedRow = NULL;
|
fSeedRow = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t AbstractDeltaRowCompressor::InitCheck()
|
|
||||||
|
status_t
|
||||||
|
AbstractDeltaRowCompressor::InitCheck()
|
||||||
{
|
{
|
||||||
if (fSeedRow != NULL) {
|
if (fSeedRow != NULL)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
} else {
|
else
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractDeltaRowCompressor::Reset()
|
|
||||||
|
void
|
||||||
|
AbstractDeltaRowCompressor::Reset()
|
||||||
{
|
{
|
||||||
if (fSeedRow != NULL) {
|
if (fSeedRow != NULL)
|
||||||
memset(fSeedRow, fInitialSeed, fSize);
|
memset(fSeedRow, fInitialSeed, fSize);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int AbstractDeltaRowCompressor::CompressRaw(const uchar* row, bool updateSeedRow, bool updateDeltaRow)
|
|
||||||
|
int
|
||||||
|
AbstractDeltaRowCompressor::CompressRaw(const uchar* row, bool updateSeedRow,
|
||||||
|
bool updateDeltaRow)
|
||||||
{
|
{
|
||||||
int index = DiffersIndex(row, 0);
|
int index = DiffersIndex(row, 0);
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
@@ -56,24 +68,21 @@ int AbstractDeltaRowCompressor::CompressRaw(const uchar* row, bool updateSeedRow
|
|||||||
|
|
||||||
// delta starts at index and contains length bytes
|
// delta starts at index and contains length bytes
|
||||||
do {
|
do {
|
||||||
|
|
||||||
// control byte limits data bytes to 8 bytes
|
// control byte limits data bytes to 8 bytes
|
||||||
int deltaBytes = length;
|
int deltaBytes = length;
|
||||||
if (length > 8) {
|
if (length > 8)
|
||||||
deltaBytes = 8;
|
deltaBytes = 8;
|
||||||
}
|
|
||||||
|
|
||||||
// calculate offset
|
// calculate offset
|
||||||
int totalOffset = index - seedRowIndex;
|
int totalOffset = index - seedRowIndex;
|
||||||
bool needsOffsetBytes = totalOffset > 30;
|
bool needsOffsetBytes = totalOffset > 30;
|
||||||
int offset = totalOffset;
|
int offset = totalOffset;
|
||||||
// control byte limits offset value to 31
|
// control byte limits offset value to 31
|
||||||
if (needsOffsetBytes) {
|
if (needsOffsetBytes)
|
||||||
offset = 31;
|
offset = 31;
|
||||||
}
|
|
||||||
|
|
||||||
// write control byte (delta bytes bits 5-7; offset bits 0-4)
|
// write control byte (delta bytes bits 5-7; offset bits 0-4)
|
||||||
Put(((deltaBytes-1) << 5) | offset);
|
Put(((deltaBytes - 1) << 5) | offset);
|
||||||
|
|
||||||
if (needsOffsetBytes) {
|
if (needsOffsetBytes) {
|
||||||
// write additional offset bytes after control byte
|
// write additional offset bytes after control byte
|
||||||
@@ -112,18 +121,25 @@ int AbstractDeltaRowCompressor::CompressRaw(const uchar* row, bool updateSeedRow
|
|||||||
return fDeltaRowIndex;
|
return fDeltaRowIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AbstractDeltaRowCompressor::CalculateSize(const uchar* row, bool updateSeedRow)
|
|
||||||
|
int
|
||||||
|
AbstractDeltaRowCompressor::CalculateSize(const uchar* row, bool updateSeedRow)
|
||||||
{
|
{
|
||||||
return CompressRaw(row, updateSeedRow, false);
|
return CompressRaw(row, updateSeedRow, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractDeltaRowCompressor::Compress(const uchar* row)
|
|
||||||
|
void
|
||||||
|
AbstractDeltaRowCompressor::Compress(const uchar* row)
|
||||||
{
|
{
|
||||||
CompressRaw(row, true, true);
|
CompressRaw(row, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef TEST_DELTA_ROW_COMPRESSION
|
#ifdef TEST_DELTA_ROW_COMPRESSION
|
||||||
void test(AbstractDeltaRowCompressor* compressor, uchar* row) {
|
|
||||||
|
void
|
||||||
|
test(AbstractDeltaRowCompressor* compressor, uchar* row) {
|
||||||
int size = compressor->CalculateSize(row);
|
int size = compressor->CalculateSize(row);
|
||||||
printf("size %d\n", size);
|
printf("size %d\n", size);
|
||||||
|
|
||||||
@@ -139,7 +155,9 @@ void test(AbstractDeltaRowCompressor* compressor, uchar* row) {
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
|
int
|
||||||
|
main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
int n = 5;
|
int n = 5;
|
||||||
uchar row1[] = {0, 0, 0, 0, 0};
|
uchar row1[] = {0, 0, 0, 0, 0};
|
||||||
@@ -152,4 +170,4 @@ int main(int argc, char *argv[])
|
|||||||
test(&compressor, row3);
|
test(&compressor, row3);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif // TEST_DELTA_ROW_COMPRESSION
|
||||||
|
|||||||
@@ -1,118 +1,123 @@
|
|||||||
/*
|
/*
|
||||||
** DeltaRowCompression.h
|
** DeltaRowCompression.h
|
||||||
** Copyright 2005, Michael Pfeiffer, [email protected]. All rights reserved.
|
** Copyright 2005, Michael Pfeiffer, [email protected].
|
||||||
|
** All rights reserved.
|
||||||
** Distributed under the terms of the OpenBeOS License.
|
** Distributed under the terms of the OpenBeOS License.
|
||||||
*/
|
*/
|
||||||
#ifndef _DELTA_ROW_COMPRESSION_H
|
#ifndef _DELTA_ROW_COMPRESSION_H
|
||||||
#define _DELTA_ROW_COMPRESSION_H
|
#define _DELTA_ROW_COMPRESSION_H
|
||||||
|
|
||||||
|
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
|
|
||||||
|
|
||||||
class AbstractDeltaRowCompressor {
|
class AbstractDeltaRowCompressor {
|
||||||
public:
|
public:
|
||||||
AbstractDeltaRowCompressor(int rowSize, uchar initialSeed);
|
AbstractDeltaRowCompressor(int rowSize,
|
||||||
virtual ~AbstractDeltaRowCompressor();
|
uchar initialSeed);
|
||||||
|
virtual ~AbstractDeltaRowCompressor();
|
||||||
|
|
||||||
// InitCheck returns B_OK on successful construction of this object or
|
// InitCheck returns B_OK on successful construction of this object or
|
||||||
// B_NO_MEMORY if the buffer for the seed row could not be allocated.
|
// B_NO_MEMORY if the buffer for the seed row could not be allocated.
|
||||||
status_t InitCheck();
|
status_t InitCheck();
|
||||||
|
|
||||||
// Clears the seed row to the initial seed specified in the constructor
|
// Clears the seed row to the initial seed specified in the constructor
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
// Returns the size of the delta row.
|
// Returns the size of the delta row.
|
||||||
// The size is 0 if the row is equal to the seed row (previous row).
|
// The size is 0 if the row is equal to the seed row (previous row).
|
||||||
// The seed row is updated only if updateSeedRow is true.
|
// The seed row is updated only if updateSeedRow is true.
|
||||||
int CalculateSize(const uchar* row, bool updateSeedRow = false);
|
int CalculateSize(const uchar* row,
|
||||||
|
bool updateSeedRow = false);
|
||||||
|
|
||||||
// Compresses the row using the delta row compression algorithm.
|
// Compresses the row using the delta row compression algorithm.
|
||||||
// The seed row is updated.
|
// The seed row is updated.
|
||||||
void Compress(const uchar* row);
|
void Compress(const uchar* row);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// append byte to delta row
|
// append byte to delta row
|
||||||
virtual void AppendByteToDeltaRow(uchar byte) = 0;
|
virtual void AppendByteToDeltaRow(uchar byte) = 0;
|
||||||
|
|
||||||
// returns the current size of the delta row
|
// returns the current size of the delta row
|
||||||
inline int CurrentDeltaRowSize() {
|
inline int CurrentDeltaRowSize()
|
||||||
return fDeltaRowIndex;
|
{
|
||||||
}
|
return fDeltaRowIndex;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Returns the index where seed row and row differ
|
// Returns the index where seed row and row differ
|
||||||
// or -1 if both arrays are equal.
|
// or -1 if both arrays are equal.
|
||||||
inline int DiffersIndex(const uchar* row, int index)
|
inline int DiffersIndex(const uchar* row, int index)
|
||||||
{
|
{
|
||||||
while (index < fSize) {
|
while (index < fSize) {
|
||||||
if (fSeedRow[index] != row[index]) {
|
if (fSeedRow[index] != row[index])
|
||||||
return index;
|
return index;
|
||||||
}
|
index ++;
|
||||||
|
}
|
||||||
index ++;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the number of bytes that row differs from seed row
|
// Returns the number of bytes that row differs from seed row
|
||||||
// starting at the specified index.
|
// starting at the specified index.
|
||||||
inline int DiffersLength(const uchar* row, int index)
|
inline int DiffersLength(const uchar* row, int index)
|
||||||
{
|
{
|
||||||
int startIndex = index;
|
int startIndex = index;
|
||||||
|
while (index < fSize) {
|
||||||
while (index < fSize) {
|
if (fSeedRow[index] == row[index])
|
||||||
if (fSeedRow[index] == row[index]) {
|
break;
|
||||||
break;
|
index ++;
|
||||||
}
|
}
|
||||||
|
return index - startIndex;
|
||||||
index ++;
|
}
|
||||||
}
|
|
||||||
return index - startIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compresses row with delta row compression algorithm.
|
// Compresses row with delta row compression algorithm.
|
||||||
// The seed row is updated only if updateSeedRow is true.
|
// The seed row is updated only if updateSeedRow is true.
|
||||||
// If updateDeltaRow is true the method AppendByteToDeltaRow is called.
|
// If updateDeltaRow is true the method AppendByteToDeltaRow is called.
|
||||||
int CompressRaw(const uchar* row, bool updateSeedRow, bool updateDeltaRow);
|
int CompressRaw(const uchar* row, bool updateSeedRow,
|
||||||
|
bool updateDeltaRow);
|
||||||
|
|
||||||
// write byte to delta row and calculate size of delta row
|
// write byte to delta row and calculate size of delta row
|
||||||
void Put(uchar byte) {
|
void Put(uchar byte)
|
||||||
if (fUpdateDeltaRow) {
|
{
|
||||||
AppendByteToDeltaRow(byte);
|
if (fUpdateDeltaRow)
|
||||||
}
|
AppendByteToDeltaRow(byte);
|
||||||
fDeltaRowIndex ++;
|
fDeltaRowIndex ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
uchar* fSeedRow; // the seed row
|
uchar* fSeedRow; // the seed row
|
||||||
int fSize; // the size of the seed row in bytes
|
int fSize; // the size of the seed row in bytes
|
||||||
uchar fInitialSeed; // the value to initialize the seed row with
|
uchar fInitialSeed;
|
||||||
|
// the value to initialize the seed row with
|
||||||
|
|
||||||
int fDeltaRowIndex; // the index of the next byte to be written into the delta row
|
int fDeltaRowIndex;
|
||||||
bool fUpdateDeltaRow; // write delta row
|
// the index of the next byte to be written into
|
||||||
|
// the delta row
|
||||||
|
bool fUpdateDeltaRow; // write delta row
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class DeltaRowCompressor : public AbstractDeltaRowCompressor
|
class DeltaRowCompressor : public AbstractDeltaRowCompressor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DeltaRowCompressor(int rowSize, uchar initialSeed)
|
DeltaRowCompressor(int rowSize, uchar initialSeed)
|
||||||
: AbstractDeltaRowCompressor(rowSize, initialSeed)
|
:
|
||||||
{
|
AbstractDeltaRowCompressor(rowSize, initialSeed)
|
||||||
// nothing to do
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
// The delta row to be written to.
|
// The delta row to be written to.
|
||||||
void SetDeltaRow(uchar* deltaRow) {
|
void SetDeltaRow(uchar* deltaRow)
|
||||||
fDeltaRow = deltaRow;
|
{
|
||||||
}
|
fDeltaRow = deltaRow;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void AppendByteToDeltaRow(uchar byte) {
|
virtual void AppendByteToDeltaRow(uchar byte)
|
||||||
fDeltaRow[CurrentDeltaRowSize()] = byte;
|
{
|
||||||
}
|
fDeltaRow[CurrentDeltaRowSize()] = byte;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uchar* fDeltaRow; // the delta row
|
uchar* fDeltaRow; // the delta row
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -4,22 +4,24 @@
|
|||||||
* Copyright 2003 Michael Pfeiffer.
|
* Copyright 2003 Michael Pfeiffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "PCL6.h"
|
||||||
|
|
||||||
|
#include <memory.h>
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
|
|
||||||
#include "DbgMsg.h"
|
#include "DbgMsg.h"
|
||||||
#include "DeltaRowCompression.h"
|
#include "DeltaRowCompression.h"
|
||||||
#include "Halftone.h"
|
#include "Halftone.h"
|
||||||
#include "JobData.h"
|
#include "JobData.h"
|
||||||
#include "PackBits.h"
|
#include "PackBits.h"
|
||||||
#include "PCL6.h"
|
|
||||||
#include "PCL6Cap.h"
|
#include "PCL6Cap.h"
|
||||||
#include "PCL6Config.h"
|
#include "PCL6Config.h"
|
||||||
#include "PrinterData.h"
|
|
||||||
#include "PCL6Rasterizer.h"
|
#include "PCL6Rasterizer.h"
|
||||||
|
#include "PrinterData.h"
|
||||||
#include "UIDriver.h"
|
#include "UIDriver.h"
|
||||||
#include "ValidRect.h"
|
#include "ValidRect.h"
|
||||||
|
|
||||||
@@ -29,74 +31,87 @@ using namespace std;
|
|||||||
#define std
|
#define std
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// DeltaRowStreamCompressor writes the delta row directly to the
|
// DeltaRowStreamCompressor writes the delta row directly to the
|
||||||
// in the contructor specified stream.
|
// in the contructor specified stream.
|
||||||
class DeltaRowStreamCompressor : public AbstractDeltaRowCompressor
|
class DeltaRowStreamCompressor : public AbstractDeltaRowCompressor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DeltaRowStreamCompressor(int rowSize, uchar initialSeed, PCL6Writer *writer)
|
DeltaRowStreamCompressor(int rowSize, uchar initialSeed,
|
||||||
: AbstractDeltaRowCompressor(rowSize, initialSeed)
|
PCL6Writer* writer)
|
||||||
, fWriter(writer)
|
:
|
||||||
{
|
AbstractDeltaRowCompressor(rowSize, initialSeed),
|
||||||
// nothing to do
|
fWriter(writer)
|
||||||
}
|
{}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void AppendByteToDeltaRow(uchar byte) {
|
void AppendByteToDeltaRow(uchar byte)
|
||||||
fWriter->Append(byte);
|
{
|
||||||
}
|
fWriter->Append(byte);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PCL6Writer *fWriter;
|
PCL6Writer* fWriter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PCL6Driver::PCL6Driver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap)
|
PCL6Driver::PCL6Driver(BMessage* msg, PrinterData* printer_data,
|
||||||
: GraphicsDriver(msg, printer_data, printer_cap)
|
const PrinterCap* printer_cap)
|
||||||
|
:
|
||||||
|
GraphicsDriver(msg, printer_data, printer_cap)
|
||||||
{
|
{
|
||||||
fHalftone = NULL;
|
fHalftone = NULL;
|
||||||
fWriter = NULL;
|
fWriter = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCL6Driver::write(const uint8 *data, uint32 size)
|
|
||||||
|
void
|
||||||
|
PCL6Driver::write(const uint8* data, uint32 size)
|
||||||
{
|
{
|
||||||
writeSpoolData(data, size);
|
writeSpoolData(data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PCL6Driver::startDoc()
|
|
||||||
|
bool
|
||||||
|
PCL6Driver::startDoc()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
jobStart();
|
jobStart();
|
||||||
fHalftone = new Halftone(getJobData()->getSurfaceType(), getJobData()->getGamma(), getJobData()->getInkDensity(), getJobData()->getDitherType());
|
fHalftone = new Halftone(getJobData()->getSurfaceType(),
|
||||||
|
getJobData()->getGamma(), getJobData()->getInkDensity(),
|
||||||
|
getJobData()->getDitherType());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (TransportException &err) {
|
catch (TransportException& err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PCL6Driver::endDoc(bool)
|
|
||||||
|
bool
|
||||||
|
PCL6Driver::endDoc(bool)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (fHalftone) {
|
if (fHalftone)
|
||||||
delete fHalftone;
|
delete fHalftone;
|
||||||
}
|
|
||||||
jobEnd();
|
jobEnd();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (TransportException &err) {
|
catch (TransportException& err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PCL6Driver::nextBand(BBitmap *bitmap, BPoint *offset)
|
|
||||||
|
bool
|
||||||
|
PCL6Driver::nextBand(BBitmap* bitmap, BPoint* offset)
|
||||||
{
|
{
|
||||||
DBGMSG(("> nextBand\n"));
|
DBGMSG(("> nextBand\n"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int y = (int)offset->y;
|
int y = (int)offset->y;
|
||||||
|
|
||||||
PCL6Rasterizer *rasterizer;
|
PCL6Rasterizer* rasterizer;
|
||||||
if (useColorMode()) {
|
if (useColorMode()) {
|
||||||
#if COLOR_DEPTH == 8
|
#if COLOR_DEPTH == 8
|
||||||
rasterizer = new ColorRGBRasterizer(fHalftone);
|
rasterizer = new ColorRGBRasterizer(fHalftone);
|
||||||
@@ -105,25 +120,27 @@ bool PCL6Driver::nextBand(BBitmap *bitmap, BPoint *offset)
|
|||||||
#else
|
#else
|
||||||
#error COLOR_DEPTH must be either 1 or 8!
|
#error COLOR_DEPTH must be either 1 or 8!
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else
|
||||||
rasterizer = new MonochromeRasterizer(fHalftone);
|
rasterizer = new MonochromeRasterizer(fHalftone);
|
||||||
}
|
|
||||||
auto_ptr<Rasterizer> _rasterizer(rasterizer);
|
auto_ptr<Rasterizer> _rasterizer(rasterizer);
|
||||||
bool valid = rasterizer->SetBitmap((int)offset->x, (int)offset->y, bitmap, getPageHeight());
|
bool valid = rasterizer->SetBitmap((int)offset->x, (int)offset->y,
|
||||||
|
bitmap, getPageHeight());
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
rasterizer->InitializeBuffer();
|
rasterizer->InitializeBuffer();
|
||||||
|
|
||||||
// Use compressor to calculate delta row size
|
// Use compressor to calculate delta row size
|
||||||
DeltaRowCompressor *deltaRowCompressor = NULL;
|
DeltaRowCompressor* deltaRowCompressor = NULL;
|
||||||
if (supportsDeltaRowCompression()) {
|
if (supportsDeltaRowCompression()) {
|
||||||
deltaRowCompressor = new DeltaRowCompressor(rasterizer->GetOutRowSize(), 0);
|
deltaRowCompressor =
|
||||||
|
new DeltaRowCompressor(rasterizer->GetOutRowSize(), 0);
|
||||||
if (deltaRowCompressor->InitCheck() != B_OK) {
|
if (deltaRowCompressor->InitCheck() != B_OK) {
|
||||||
delete deltaRowCompressor;
|
delete deltaRowCompressor;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto_ptr<DeltaRowCompressor> _deltaRowCompressor(deltaRowCompressor);
|
auto_ptr<DeltaRowCompressor>_deltaRowCompressor(deltaRowCompressor);
|
||||||
int deltaRowSize = 0;
|
int deltaRowSize = 0;
|
||||||
|
|
||||||
// remember position
|
// remember position
|
||||||
@@ -131,22 +148,26 @@ bool PCL6Driver::nextBand(BBitmap *bitmap, BPoint *offset)
|
|||||||
int yPage = rasterizer->GetY();
|
int yPage = rasterizer->GetY();
|
||||||
|
|
||||||
while (rasterizer->HasNextLine()) {
|
while (rasterizer->HasNextLine()) {
|
||||||
const uchar *rowBuffer = (uchar*)rasterizer->RasterizeNextLine();
|
const uchar* rowBuffer =
|
||||||
|
static_cast<const uchar*>(rasterizer->RasterizeNextLine());
|
||||||
|
|
||||||
if (deltaRowCompressor != NULL) {
|
if (deltaRowCompressor != NULL) {
|
||||||
int size = deltaRowCompressor->CalculateSize(rowBuffer, true);
|
int size =
|
||||||
deltaRowSize += size + 2; // two bytes for the row byte count
|
deltaRowCompressor->CalculateSize(rowBuffer, true);
|
||||||
|
deltaRowSize += size + 2;
|
||||||
|
// two bytes for the row byte count
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
y = rasterizer->GetY();
|
y = rasterizer->GetY();
|
||||||
|
|
||||||
uchar *outBuffer = rasterizer->GetOutBuffer();
|
uchar* outBuffer = rasterizer->GetOutBuffer();
|
||||||
int outBufferSize = rasterizer->GetOutBufferSize();
|
int outBufferSize = rasterizer->GetOutBufferSize();
|
||||||
int outRowSize = rasterizer->GetOutRowSize();
|
int outRowSize = rasterizer->GetOutRowSize();
|
||||||
int width = rasterizer->GetWidth();
|
int width = rasterizer->GetWidth();
|
||||||
int height = rasterizer->GetHeight();
|
int height = rasterizer->GetHeight();
|
||||||
writeBitmap(outBuffer, outBufferSize, outRowSize, xPage, yPage, width, height, deltaRowSize);
|
writeBitmap(outBuffer, outBufferSize, outRowSize, xPage, yPage,
|
||||||
|
width, height, deltaRowSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y >= getPageHeight()) {
|
if (y >= getPageHeight()) {
|
||||||
@@ -158,14 +179,17 @@ bool PCL6Driver::nextBand(BBitmap *bitmap, BPoint *offset)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (TransportException &err) {
|
catch (TransportException& err) {
|
||||||
BAlert *alert = new BAlert("", err.what(), "OK");
|
BAlert* alert = new BAlert("", err.what(), "OK");
|
||||||
alert->Go();
|
alert->Go();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCL6Driver::writeBitmap(const uchar* buffer, int outSize, int rowSize, int x, int y, int width, int height, int deltaRowSize)
|
|
||||||
|
void
|
||||||
|
PCL6Driver::writeBitmap(const uchar* buffer, int outSize, int rowSize, int x,
|
||||||
|
int y, int width, int height, int deltaRowSize)
|
||||||
{
|
{
|
||||||
// choose the best compression method
|
// choose the best compression method
|
||||||
PCL6Writer::Compression compressionMethod = PCL6Writer::kNoCompression;
|
PCL6Writer::Compression compressionMethod = PCL6Writer::kNoCompression;
|
||||||
@@ -193,43 +217,55 @@ void PCL6Driver::writeBitmap(const uchar* buffer, int outSize, int rowSize, int
|
|||||||
|
|
||||||
startRasterGraphics(x, y, width, height, compressionMethod);
|
startRasterGraphics(x, y, width, height, compressionMethod);
|
||||||
|
|
||||||
rasterGraphics(buffer, outSize, dataSize, rowSize, height, compressionMethod);
|
rasterGraphics(buffer, outSize, dataSize, rowSize, height,
|
||||||
|
compressionMethod);
|
||||||
|
|
||||||
endRasterGraphics();
|
endRasterGraphics();
|
||||||
|
|
||||||
#if DISPLAY_COMPRESSION_STATISTICS
|
#if DISPLAY_COMPRESSION_STATISTICS
|
||||||
fprintf(stderr, "Out Size %d %2.2f\n", (int)outSize, 100.0);
|
fprintf(stderr, "Out Size %d %2.2f\n", (int)outSize, 100.0);
|
||||||
#if ENABLE_RLE_COMPRESSION
|
#if ENABLE_RLE_COMPRESSION
|
||||||
fprintf(stderr, "RLE Size %d %2.2f\n", (int)rleSize, 100.0 * rleSize / outSize);
|
fprintf(stderr, "RLE Size %d %2.2f\n", (int)rleSize,
|
||||||
|
100.0 * rleSize / outSize);
|
||||||
#endif
|
#endif
|
||||||
#if ENABLE_DELTA_ROW_COMPRESSION
|
#if ENABLE_DELTA_ROW_COMPRESSION
|
||||||
fprintf(stderr, "Delta Row Size %d %2.2f\n", (int)deltaRowSize, 100.0 * deltaRowSize / outSize);
|
fprintf(stderr, "Delta Row Size %d %2.2f\n", (int)deltaRowSize,
|
||||||
|
100.0 * deltaRowSize / outSize);
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr, "Data Size %d %2.2f\n", (int)dataSize, 100.0 * dataSize / outSize);
|
fprintf(stderr, "Data Size %d %2.2f\n", (int)dataSize,
|
||||||
|
100.0 * dataSize / outSize);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCL6Driver::jobStart()
|
void
|
||||||
|
PCL6Driver::jobStart()
|
||||||
{
|
{
|
||||||
// PCL6 begin
|
// PCL6 begin
|
||||||
fWriter = new PCL6Writer(this);
|
fWriter = new PCL6Writer(this);
|
||||||
PCL6Writer::ProtocolClass pc = (PCL6Writer::ProtocolClass)getProtocolClass();
|
PCL6Writer::ProtocolClass pc =
|
||||||
fWriter->PJLHeader(pc, getJobData()->getXres(), "Copyright (c) 2003, 2004 Haiku");
|
(PCL6Writer::ProtocolClass)getProtocolClass();
|
||||||
fWriter->BeginSession(getJobData()->getXres(), getJobData()->getYres(), PCL6Writer::kInch, PCL6Writer::kBackChAndErrPage);
|
fWriter->PJLHeader(pc, getJobData()->getXres(),
|
||||||
|
"Copyright (c) 2003, 2004 Haiku");
|
||||||
|
fWriter->BeginSession(getJobData()->getXres(), getJobData()->getYres(),
|
||||||
|
PCL6Writer::kInch, PCL6Writer::kBackChAndErrPage);
|
||||||
fWriter->OpenDataSource();
|
fWriter->OpenDataSource();
|
||||||
fMediaSide = PCL6Writer::kFrontMediaSide;
|
fMediaSide = PCL6Writer::kFrontMediaSide;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PCL6Driver::startPage(int)
|
|
||||||
|
bool
|
||||||
|
PCL6Driver::startPage(int)
|
||||||
{
|
{
|
||||||
PCL6Writer::Orientation orientation = PCL6Writer::kPortrait;
|
PCL6Writer::Orientation orientation = PCL6Writer::kPortrait;
|
||||||
if (getJobData()->getOrientation() == JobData::kLandscape) {
|
if (getJobData()->getOrientation() == JobData::kLandscape) {
|
||||||
orientation = PCL6Writer::kLandscape;
|
orientation = PCL6Writer::kLandscape;
|
||||||
}
|
}
|
||||||
|
|
||||||
PCL6Writer::MediaSize mediaSize = PCL6Driver::mediaSize(getJobData()->getPaper());
|
PCL6Writer::MediaSize mediaSize =
|
||||||
PCL6Writer::MediaSource mediaSource = PCL6Driver::mediaSource(getJobData()->getPaperSource());
|
PCL6Driver::mediaSize(getJobData()->getPaper());
|
||||||
|
PCL6Writer::MediaSource mediaSource =
|
||||||
|
PCL6Driver::mediaSource(getJobData()->getPaperSource());
|
||||||
if (getJobData()->getPrintStyle() == JobData::kSimplex) {
|
if (getJobData()->getPrintStyle() == JobData::kSimplex) {
|
||||||
fWriter->BeginPage(orientation, mediaSize, mediaSource);
|
fWriter->BeginPage(orientation, mediaSize, mediaSource);
|
||||||
} else if (getJobData()->getPrintStyle() == JobData::kDuplex) {
|
} else if (getJobData()->getPrintStyle() == JobData::kDuplex) {
|
||||||
@@ -237,27 +273,29 @@ bool PCL6Driver::startPage(int)
|
|||||||
fWriter->BeginPage(orientation, mediaSize, mediaSource,
|
fWriter->BeginPage(orientation, mediaSize, mediaSource,
|
||||||
PCL6Writer::kDuplexVerticalBinding, fMediaSide);
|
PCL6Writer::kDuplexVerticalBinding, fMediaSide);
|
||||||
|
|
||||||
if (fMediaSide == PCL6Writer::kFrontMediaSide) {
|
if (fMediaSide == PCL6Writer::kFrontMediaSide)
|
||||||
fMediaSide = PCL6Writer::kBackMediaSide;
|
fMediaSide = PCL6Writer::kBackMediaSide;
|
||||||
} else {
|
else
|
||||||
fMediaSide = PCL6Writer::kFrontMediaSide;
|
fMediaSide = PCL6Writer::kFrontMediaSide;
|
||||||
}
|
} else
|
||||||
} else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
// PageOrigin from Windows NT printer driver
|
// PageOrigin from Windows NT printer driver
|
||||||
int x = 142 * getJobData()->getXres() / 600;
|
int x = 142 * getJobData()->getXres() / 600;
|
||||||
int y = 100 * getJobData()->getYres() / 600;
|
int y = 100 * getJobData()->getYres() / 600;
|
||||||
fWriter->SetPageOrigin(x, y);
|
fWriter->SetPageOrigin(x, y);
|
||||||
fWriter->SetColorSpace(useColorMode() ? PCL6Writer::kRGB : PCL6Writer::kGray);
|
fWriter->SetColorSpace(useColorMode() ? PCL6Writer::kRGB
|
||||||
|
: PCL6Writer::kGray);
|
||||||
fWriter->SetPaintTxMode(PCL6Writer::kOpaque);
|
fWriter->SetPaintTxMode(PCL6Writer::kOpaque);
|
||||||
fWriter->SetSourceTxMode(PCL6Writer::kOpaque);
|
fWriter->SetSourceTxMode(PCL6Writer::kOpaque);
|
||||||
fWriter->SetROP(204);
|
fWriter->SetROP(204);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCL6Driver::startRasterGraphics(int x, int y, int width, int height, PCL6Writer::Compression compressionMethod)
|
|
||||||
|
void
|
||||||
|
PCL6Driver::startRasterGraphics(int x, int y, int width, int height,
|
||||||
|
PCL6Writer::Compression compressionMethod)
|
||||||
{
|
{
|
||||||
PCL6Writer::ColorDepth colorDepth;
|
PCL6Writer::ColorDepth colorDepth;
|
||||||
if (useColorMode()) {
|
if (useColorMode()) {
|
||||||
@@ -268,26 +306,25 @@ void PCL6Driver::startRasterGraphics(int x, int y, int width, int height, PCL6Wr
|
|||||||
#else
|
#else
|
||||||
#error COLOR_DEPTH must be either 1 or 8!
|
#error COLOR_DEPTH must be either 1 or 8!
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else
|
||||||
colorDepth = PCL6Writer::k1Bit;
|
colorDepth = PCL6Writer::k1Bit;
|
||||||
}
|
|
||||||
fWriter->BeginImage(PCL6Writer::kDirectPixel, colorDepth, width, height, width, height);
|
fWriter->BeginImage(PCL6Writer::kDirectPixel, colorDepth, width, height,
|
||||||
|
width, height);
|
||||||
fWriter->ReadImage(compressionMethod, 0, height);
|
fWriter->ReadImage(compressionMethod, 0, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCL6Driver::endRasterGraphics()
|
|
||||||
|
void
|
||||||
|
PCL6Driver::endRasterGraphics()
|
||||||
{
|
{
|
||||||
fWriter->EndImage();
|
fWriter->EndImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCL6Driver::rasterGraphics(
|
|
||||||
const uchar *buffer,
|
void
|
||||||
int bufferSize,
|
PCL6Driver::rasterGraphics(const uchar* buffer, int bufferSize, int dataSize,
|
||||||
int dataSize,
|
int rowSize, int height, int compressionMethod)
|
||||||
int rowSize,
|
|
||||||
int height,
|
|
||||||
int compressionMethod
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
// write bitmap byte size
|
// write bitmap byte size
|
||||||
fWriter->EmbeddedDataPrefix32(dataSize);
|
fWriter->EmbeddedDataPrefix32(dataSize);
|
||||||
@@ -295,7 +332,7 @@ void PCL6Driver::rasterGraphics(
|
|||||||
// write data
|
// write data
|
||||||
if (compressionMethod == PCL6Writer::kRLECompression) {
|
if (compressionMethod == PCL6Writer::kRLECompression) {
|
||||||
// use RLE compression
|
// use RLE compression
|
||||||
uchar *outBuffer = new uchar[dataSize];
|
uchar* outBuffer = new uchar[dataSize];
|
||||||
pack_bits(outBuffer, buffer, bufferSize);
|
pack_bits(outBuffer, buffer, bufferSize);
|
||||||
fWriter->Append(outBuffer, dataSize);
|
fWriter->Append(outBuffer, dataSize);
|
||||||
delete[] outBuffer;
|
delete[] outBuffer;
|
||||||
@@ -326,18 +363,22 @@ void PCL6Driver::rasterGraphics(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PCL6Driver::endPage(int)
|
|
||||||
|
bool
|
||||||
|
PCL6Driver::endPage(int)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
fWriter->EndPage(getJobData()->getCopies());
|
fWriter->EndPage(getJobData()->getCopies());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (TransportException &err) {
|
catch (TransportException& err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCL6Driver::jobEnd()
|
|
||||||
|
void
|
||||||
|
PCL6Driver::jobEnd()
|
||||||
{
|
{
|
||||||
fWriter->CloseDataSource();
|
fWriter->CloseDataSource();
|
||||||
fWriter->EndSession();
|
fWriter->EndSession();
|
||||||
@@ -347,44 +388,60 @@ void PCL6Driver::jobEnd()
|
|||||||
fWriter = NULL;
|
fWriter = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCL6Driver::move(int x, int y)
|
|
||||||
|
void
|
||||||
|
PCL6Driver::move(int x, int y)
|
||||||
{
|
{
|
||||||
fWriter->SetCursor(x, y);
|
fWriter->SetCursor(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PCL6Driver::supportsRLECompression()
|
PCL6Driver::supportsRLECompression()
|
||||||
{
|
{
|
||||||
return getJobData()->getColor() != JobData::kColorCompressionDisabled;
|
return getJobData()->getColor() != JobData::kColorCompressionDisabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PCL6Driver::supportsDeltaRowCompression()
|
PCL6Driver::supportsDeltaRowCompression()
|
||||||
{
|
{
|
||||||
return getProtocolClass() >= PCL6Writer::kProtocolClass2_1 &&
|
return getProtocolClass() >= PCL6Writer::kProtocolClass2_1
|
||||||
getJobData()->getColor() != JobData::kColorCompressionDisabled;
|
&& getJobData()->getColor() != JobData::kColorCompressionDisabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PCL6Driver::useColorMode()
|
PCL6Driver::useColorMode()
|
||||||
{
|
{
|
||||||
return getJobData()->getColor() != JobData::kMonochrome;
|
return getJobData()->getColor() != JobData::kMonochrome;
|
||||||
}
|
}
|
||||||
|
|
||||||
PCL6Writer::MediaSize PCL6Driver::mediaSize(JobData::Paper paper)
|
|
||||||
|
PCL6Writer::MediaSize
|
||||||
|
PCL6Driver::mediaSize(JobData::Paper paper)
|
||||||
{
|
{
|
||||||
switch (paper) {
|
switch (paper) {
|
||||||
case JobData::kLetter: return PCL6Writer::kLetterPaper;
|
case JobData::kLetter:
|
||||||
case JobData::kLegal: return PCL6Writer::kLegalPaper;
|
return PCL6Writer::kLetterPaper;
|
||||||
case JobData::kA4: return PCL6Writer::kA4Paper;
|
case JobData::kLegal:
|
||||||
case JobData::kExecutive: return PCL6Writer::kExecPaper;
|
return PCL6Writer::kLegalPaper;
|
||||||
case JobData::kLedger: return PCL6Writer::kLedgerPaper;
|
case JobData::kA4:
|
||||||
case JobData::kA3: return PCL6Writer::kA3Paper;
|
return PCL6Writer::kA4Paper;
|
||||||
case JobData::kB5: return PCL6Writer::kB5Paper;
|
case JobData::kExecutive:
|
||||||
case JobData::kJapanesePostcard:
|
return PCL6Writer::kExecPaper;
|
||||||
return PCL6Writer::kJPostcard;
|
case JobData::kLedger:
|
||||||
case JobData::kA5: return PCL6Writer::kA5Paper;
|
return PCL6Writer::kLedgerPaper;
|
||||||
case JobData::kB4: return PCL6Writer::kJB4Paper;
|
case JobData::kA3:
|
||||||
|
return PCL6Writer::kA3Paper;
|
||||||
|
case JobData::kB5:
|
||||||
|
return PCL6Writer::kB5Paper;
|
||||||
|
case JobData::kJapanesePostcard:
|
||||||
|
return PCL6Writer::kJPostcard;
|
||||||
|
case JobData::kA5:
|
||||||
|
return PCL6Writer::kA5Paper;
|
||||||
|
case JobData::kB4:
|
||||||
|
return PCL6Writer::kJB4Paper;
|
||||||
/*
|
/*
|
||||||
case : return PCL6Writer::kCOM10Envelope;
|
case : return PCL6Writer::kCOM10Envelope;
|
||||||
case : return PCL6Writer::kMonarchEnvelope;
|
case : return PCL6Writer::kMonarchEnvelope;
|
||||||
@@ -407,20 +464,28 @@ PCL6Writer::MediaSize PCL6Driver::mediaSize(JobData::Paper paper)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PCL6Writer::MediaSource PCL6Driver::mediaSource(JobData::PaperSource source)
|
|
||||||
|
PCL6Writer::MediaSource
|
||||||
|
PCL6Driver::mediaSource(JobData::PaperSource source)
|
||||||
{
|
{
|
||||||
switch (source) {
|
switch (source) {
|
||||||
case JobData::kAuto: return PCL6Writer::kAutoSelect;
|
case JobData::kAuto:
|
||||||
case JobData::kCassette1: return PCL6Writer::kDefaultSource;
|
return PCL6Writer::kAutoSelect;
|
||||||
case JobData::kCassette2: return PCL6Writer::kEnvelopeTray;
|
case JobData::kCassette1:
|
||||||
case JobData::kLower: return PCL6Writer::kLowerCassette;
|
return PCL6Writer::kDefaultSource;
|
||||||
case JobData::kUpper: return PCL6Writer::kUpperCassette;
|
case JobData::kCassette2:
|
||||||
case JobData::kMiddle: return PCL6Writer::kThirdCassette;
|
return PCL6Writer::kEnvelopeTray;
|
||||||
case JobData::kManual: return PCL6Writer::kManualFeed;
|
case JobData::kLower:
|
||||||
case JobData::kCassette3: return PCL6Writer::kMultiPurposeTray;
|
return PCL6Writer::kLowerCassette;
|
||||||
|
case JobData::kUpper:
|
||||||
|
return PCL6Writer::kUpperCassette;
|
||||||
|
case JobData::kMiddle:
|
||||||
|
return PCL6Writer::kThirdCassette;
|
||||||
|
case JobData::kManual:
|
||||||
|
return PCL6Writer::kManualFeed;
|
||||||
|
case JobData::kCassette3:
|
||||||
|
return PCL6Writer::kMultiPurposeTray;
|
||||||
default:
|
default:
|
||||||
return PCL6Writer::kAutoSelect;
|
return PCL6Writer::kAutoSelect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
||||||
* Copyright 2003 Michael Pfeiffer.
|
* Copyright 2003 Michael Pfeiffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __PCL6_H
|
#ifndef __PCL6_H
|
||||||
#define __PCL6_H
|
#define __PCL6_H
|
||||||
|
|
||||||
@@ -12,45 +11,46 @@
|
|||||||
#include "PCL6Cap.h"
|
#include "PCL6Cap.h"
|
||||||
#include "PCL6Writer.h"
|
#include "PCL6Writer.h"
|
||||||
|
|
||||||
|
|
||||||
class Halftone;
|
class Halftone;
|
||||||
|
|
||||||
class PCL6Driver : public GraphicsDriver, public PCL6WriterStream
|
|
||||||
|
class PCL6Driver : public GraphicsDriver, public PCL6WriterStream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PCL6Driver(BMessage *msg, PrinterData *printer_data, const PrinterCap *printer_cap);
|
PCL6Driver(BMessage* msg, PrinterData* printer_data,
|
||||||
|
const PrinterCap* printer_cap);
|
||||||
|
|
||||||
void write(const uint8 *data, uint32 size);
|
void write(const uint8* data, uint32 size);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool startDoc();
|
virtual bool startDoc();
|
||||||
virtual bool startPage(int page);
|
virtual bool startPage(int page);
|
||||||
virtual bool nextBand(BBitmap *bitmap, BPoint *offset);
|
virtual bool nextBand(BBitmap* bitmap, BPoint* offset);
|
||||||
virtual bool endPage(int page);
|
virtual bool endPage(int page);
|
||||||
virtual bool endDoc(bool success);
|
virtual bool endDoc(bool success);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool supportsRLECompression();
|
bool supportsRLECompression();
|
||||||
bool supportsDeltaRowCompression();
|
bool supportsDeltaRowCompression();
|
||||||
bool useColorMode();
|
bool useColorMode();
|
||||||
PCL6Writer::MediaSize mediaSize(JobData::Paper paper);
|
PCL6Writer::MediaSize mediaSize(JobData::Paper paper);
|
||||||
PCL6Writer::MediaSource mediaSource(JobData::PaperSource source);
|
PCL6Writer::MediaSource mediaSource(JobData::PaperSource source);
|
||||||
void move(int x, int y);
|
void move(int x, int y);
|
||||||
void jobStart();
|
void jobStart();
|
||||||
void writeBitmap(const uchar* buffer, int outSize, int rowSize, int x, int y, int width, int height, int deltaRowSize);
|
void writeBitmap(const uchar* buffer, int outSize, int rowSize,
|
||||||
void startRasterGraphics(int x, int y, int width, int height, PCL6Writer::Compression compressionMethod);
|
int x, int y, int width, int height, int deltaRowSize);
|
||||||
void endRasterGraphics();
|
void startRasterGraphics(int x, int y, int width, int height,
|
||||||
void rasterGraphics(
|
PCL6Writer::Compression compressionMethod);
|
||||||
const uchar *buffer,
|
void endRasterGraphics();
|
||||||
int bufferSize,
|
void rasterGraphics(const uchar* buffer, int bufferSize,
|
||||||
int dataSize,
|
int dataSize, int rowSize, int height,
|
||||||
int rowSize,
|
int compression_method);
|
||||||
int height,
|
void jobEnd();
|
||||||
int compression_method);
|
|
||||||
void jobEnd();
|
|
||||||
|
|
||||||
PCL6Writer *fWriter;
|
PCL6Writer* fWriter;
|
||||||
PCL6Writer::MediaSide fMediaSide; // side if in duplex mode
|
PCL6Writer::MediaSide fMediaSide; // side if in duplex mode
|
||||||
Halftone *fHalftone;
|
Halftone* fHalftone;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __PCL6_H */
|
#endif // __PCL6_H
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
||||||
* Copyright 2003-2007 Michael Pfeiffer.
|
* Copyright 2003-2007 Michael Pfeiffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "PCL6Cap.h"
|
#include "PCL6Cap.h"
|
||||||
|
|
||||||
#include "PCL6Config.h"
|
#include "PCL6Config.h"
|
||||||
#include "PCL6Writer.h"
|
#include "PCL6Writer.h"
|
||||||
#include "PrinterData.h"
|
#include "PrinterData.h"
|
||||||
@@ -133,58 +133,65 @@ const PaperCap b4(
|
|||||||
// since 2.1
|
// since 2.1
|
||||||
|
|
||||||
// since 1.1
|
// since 1.1
|
||||||
const PaperSourceCap defaultSource("Default", false, JobData::kCassette1);
|
const PaperSourceCap defaultSource("Default", false, JobData::kCassette1);
|
||||||
const PaperSourceCap autobin("Auto", true, JobData::kAuto);
|
const PaperSourceCap autobin("Auto", true, JobData::kAuto);
|
||||||
const PaperSourceCap manualFeed("Manual Feed", false, JobData::kManual);
|
const PaperSourceCap manualFeed("Manual Feed", false, JobData::kManual);
|
||||||
const PaperSourceCap multiPurposeTray("Multi Purpose Tray", false, JobData::kCassette3);
|
const PaperSourceCap multiPurposeTray("Multi Purpose Tray", false,
|
||||||
const PaperSourceCap upperCassette("Upper Cassette", false, JobData::kUpper);
|
JobData::kCassette3);
|
||||||
const PaperSourceCap lowerCassette("Lower Cassette", false, JobData::kLower);
|
const PaperSourceCap upperCassette("Upper Cassette", false, JobData::kUpper);
|
||||||
const PaperSourceCap envelopeTray("Envelope Tray", false, JobData::kCassette2);
|
const PaperSourceCap lowerCassette("Lower Cassette", false, JobData::kLower);
|
||||||
|
const PaperSourceCap envelopeTray("Envelope Tray", false,
|
||||||
|
JobData::kCassette2);
|
||||||
// since 2.0:
|
// since 2.0:
|
||||||
const PaperSourceCap thridCassette("Thrid Cassette", false, JobData::kMiddle);
|
const PaperSourceCap thridCassette("Thrid Cassette", false, JobData::kMiddle);
|
||||||
|
|
||||||
const ResolutionCap dpi150("150dpi", false, 150, 150);
|
const ResolutionCap dpi150("150dpi", false, 150, 150);
|
||||||
const ResolutionCap dpi300("300dpi", true, 300, 300);
|
const ResolutionCap dpi300("300dpi", true, 300, 300);
|
||||||
const ResolutionCap dpi600("600dpi", false, 600, 600);
|
const ResolutionCap dpi600("600dpi", false, 600, 600);
|
||||||
const ResolutionCap dpi1200("1200dpi", false, 1200, 1200);
|
const ResolutionCap dpi1200("1200dpi", false, 1200, 1200);
|
||||||
|
|
||||||
const PrintStyleCap simplex("Simplex", true, JobData::kSimplex);
|
const PrintStyleCap simplex("Simplex", true, JobData::kSimplex);
|
||||||
const PrintStyleCap duplex("Duplex", false, JobData::kDuplex);
|
const PrintStyleCap duplex("Duplex", false, JobData::kDuplex);
|
||||||
|
|
||||||
const ProtocolClassCap pc1_1("PCL 6 Protocol Class 1.1", true, PCL6Writer::kProtocolClass1_1,
|
const ProtocolClassCap pc1_1("PCL 6 Protocol Class 1.1", true,
|
||||||
"The printer driver supports the following features of protocol class 1.1:\n"
|
PCL6Writer::kProtocolClass1_1,
|
||||||
"* Monochrome and Color Printing.\n"
|
"The printer driver supports the following features of protocol class 1.1:"
|
||||||
"* Paper Formats: Letter, Legal, A4, A3, A5 and Japanese Postcard.\n"
|
"\n"
|
||||||
"* Paper Sources: Auto, Default, Manual Feed, Multi-Purpose Tray, Upper and Lower Cassette and Envelope Tray.\n"
|
"* Monochrome and Color Printing.\n"
|
||||||
"* Resolutions: 150, 300, 600 and 1200 DPI."
|
"* Paper Formats: Letter, Legal, A4, A3, A5 and Japanese Postcard.\n"
|
||||||
|
"* Paper Sources: Auto, Default, Manual Feed, Multi-Purpose Tray, Upper "
|
||||||
|
"and Lower Cassette and Envelope Tray.\n"
|
||||||
|
"* Resolutions: 150, 300, 600 and 1200 DPI."
|
||||||
#if ENABLE_RLE_COMPRESSION
|
#if ENABLE_RLE_COMPRESSION
|
||||||
"\n* Compression Method: RLE."
|
"\n* Compression Method: RLE."
|
||||||
#else
|
#else
|
||||||
"\n* Compression Method: None."
|
"\n* Compression Method: None."
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
const ProtocolClassCap pc2_0("PCL 6 Protocol Class 2.0", false, PCL6Writer::kProtocolClass2_0,
|
const ProtocolClassCap pc2_0("PCL 6 Protocol Class 2.0", false,
|
||||||
"In addition to features of protocol class 1.1, the printer driver supports the "
|
PCL6Writer::kProtocolClass2_0,
|
||||||
"following features of protocol class 2.0:\n"
|
"In addition to features of protocol class 1.1, the printer driver "
|
||||||
"* Additonal Paper Source: Third Cassette."
|
"supports the following features of protocol class 2.0:\n"
|
||||||
// "\n* JPEG compression (not implemented yet)"
|
"* Additonal Paper Source: Third Cassette."
|
||||||
|
// "\n* JPEG compression (not implemented yet)"
|
||||||
);
|
);
|
||||||
|
|
||||||
const ProtocolClassCap pc2_1("PCL 6 Protocol Class 2.1", false, PCL6Writer::kProtocolClass2_1,
|
const ProtocolClassCap pc2_1("PCL 6 Protocol Class 2.1", false,
|
||||||
"In addition to features of previous protocol classes, the printer driver supports the "
|
PCL6Writer::kProtocolClass2_1,
|
||||||
"following features of protocol class 2.1:\n"
|
"In addition to features of previous protocol classes, the printer driver "
|
||||||
"* Additional Paper Format: B5."
|
"supports the following features of protocol class 2.1:\n"
|
||||||
|
"* Additional Paper Format: B5."
|
||||||
#if ENABLE_DELTA_ROW_COMPRESSION
|
#if ENABLE_DELTA_ROW_COMPRESSION
|
||||||
"\n* Additional Compression Method: Delta Row Compression."
|
"\n* Additional Compression Method: Delta Row Compression."
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
// Disable until driver supports new features of protocol class 3.0
|
// Disable until driver supports new features of protocol class 3.0
|
||||||
//const ProtocolClassCap pc3_0("PCL 6 Protocol Class 3.0", false, PCL6Writer::kProtocolClass3_0,
|
// const ProtocolClassCap pc3_0("PCL 6 Protocol Class 3.0", false,
|
||||||
//"Protocol Class 3.0");
|
// PCL6Writer::kProtocolClass3_0, "Protocol Class 3.0");
|
||||||
|
|
||||||
const PaperCap *papers1_1[] = {
|
const PaperCap* papers1_1[] = {
|
||||||
&letter,
|
&letter,
|
||||||
&legal,
|
&legal,
|
||||||
&a4,
|
&a4,
|
||||||
@@ -194,7 +201,7 @@ const PaperCap *papers1_1[] = {
|
|||||||
&japanese_postcard
|
&japanese_postcard
|
||||||
};
|
};
|
||||||
|
|
||||||
const PaperCap *papers2_1[] = {
|
const PaperCap* papers2_1[] = {
|
||||||
&letter,
|
&letter,
|
||||||
&legal,
|
&legal,
|
||||||
&a4,
|
&a4,
|
||||||
@@ -205,7 +212,7 @@ const PaperCap *papers2_1[] = {
|
|||||||
&japanese_postcard
|
&japanese_postcard
|
||||||
};
|
};
|
||||||
|
|
||||||
const PaperSourceCap *paperSources1_1[] = {
|
const PaperSourceCap* paperSources1_1[] = {
|
||||||
&autobin,
|
&autobin,
|
||||||
&defaultSource,
|
&defaultSource,
|
||||||
&envelopeTray,
|
&envelopeTray,
|
||||||
@@ -215,7 +222,7 @@ const PaperSourceCap *paperSources1_1[] = {
|
|||||||
&multiPurposeTray
|
&multiPurposeTray
|
||||||
};
|
};
|
||||||
|
|
||||||
const PaperSourceCap *paperSources2_0[] = {
|
const PaperSourceCap* paperSources2_0[] = {
|
||||||
&autobin,
|
&autobin,
|
||||||
&defaultSource,
|
&defaultSource,
|
||||||
&envelopeTray,
|
&envelopeTray,
|
||||||
@@ -226,19 +233,19 @@ const PaperSourceCap *paperSources2_0[] = {
|
|||||||
&multiPurposeTray
|
&multiPurposeTray
|
||||||
};
|
};
|
||||||
|
|
||||||
const ResolutionCap *resolutions[] = {
|
const ResolutionCap* resolutions[] = {
|
||||||
&dpi150,
|
&dpi150,
|
||||||
&dpi300,
|
&dpi300,
|
||||||
&dpi600,
|
&dpi600,
|
||||||
&dpi1200,
|
&dpi1200,
|
||||||
};
|
};
|
||||||
|
|
||||||
const PrintStyleCap *printStyles[] = {
|
const PrintStyleCap* printStyles[] = {
|
||||||
&simplex,
|
&simplex,
|
||||||
&duplex
|
&duplex
|
||||||
};
|
};
|
||||||
|
|
||||||
const ProtocolClassCap *protocolClasses[] = {
|
const ProtocolClassCap* protocolClasses[] = {
|
||||||
&pc1_1,
|
&pc1_1,
|
||||||
&pc2_0,
|
&pc2_0,
|
||||||
&pc2_1
|
&pc2_1
|
||||||
@@ -247,84 +254,89 @@ const ProtocolClassCap *protocolClasses[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ColorCap color("Color", false, JobData::kColor);
|
const ColorCap color("Color", false, JobData::kColor);
|
||||||
const ColorCap colorCompressionDisabled("Color (No Compression)", false, JobData::kColorCompressionDisabled);
|
const ColorCap colorCompressionDisabled("Color (No Compression)", false,
|
||||||
|
JobData::kColorCompressionDisabled);
|
||||||
const ColorCap monochrome("Shades of Gray", true, JobData::kMonochrome);
|
const ColorCap monochrome("Shades of Gray", true, JobData::kMonochrome);
|
||||||
|
|
||||||
const ColorCap *colors[] = {
|
const ColorCap* colors[] = {
|
||||||
&color,
|
&color,
|
||||||
&colorCompressionDisabled,
|
&colorCompressionDisabled,
|
||||||
&monochrome
|
&monochrome
|
||||||
};
|
};
|
||||||
|
|
||||||
PCL6Cap::PCL6Cap(const PrinterData *printer_data)
|
|
||||||
: PrinterCap(printer_data)
|
PCL6Cap::PCL6Cap(const PrinterData* printer_data)
|
||||||
|
:
|
||||||
|
PrinterCap(printer_data)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int PCL6Cap::countCap(CapID capid) const
|
|
||||||
|
int
|
||||||
|
PCL6Cap::countCap(CapID capid) const
|
||||||
{
|
{
|
||||||
switch (capid) {
|
switch (capid) {
|
||||||
case kPaper:
|
case kPaper:
|
||||||
if (getProtocolClass() >= PCL6Writer::kProtocolClass2_1) {
|
if (getProtocolClass() >= PCL6Writer::kProtocolClass2_1)
|
||||||
return sizeof(papers2_1) / sizeof(papers2_1[0]);
|
return sizeof(papers2_1) / sizeof(papers2_1[0]);
|
||||||
}
|
return sizeof(papers1_1) / sizeof(papers1_1[0]);
|
||||||
return sizeof(papers1_1) / sizeof(papers1_1[0]);
|
case kPaperSource:
|
||||||
case kPaperSource:
|
if (getProtocolClass() >= PCL6Writer::kProtocolClass2_0)
|
||||||
if (getProtocolClass() >= PCL6Writer::kProtocolClass2_0) {
|
return sizeof(paperSources2_0) / sizeof(paperSources2_0[0]);
|
||||||
return sizeof(paperSources2_0) / sizeof(paperSources2_0[0]);
|
return sizeof(paperSources1_1) / sizeof(paperSources1_1[0]);
|
||||||
}
|
case kResolution:
|
||||||
return sizeof(paperSources1_1) / sizeof(paperSources1_1[0]);
|
return sizeof(resolutions) / sizeof(resolutions[0]);
|
||||||
case kResolution:
|
case kColor:
|
||||||
return sizeof(resolutions) / sizeof(resolutions[0]);
|
return sizeof(colors) / sizeof(colors[0]);
|
||||||
case kColor:
|
case kPrintStyle:
|
||||||
return sizeof(colors) / sizeof(colors[0]);
|
return sizeof(printStyles) / sizeof(printStyles[0]);
|
||||||
case kPrintStyle:
|
case kProtocolClass:
|
||||||
return sizeof(printStyles) / sizeof(printStyles[0]);
|
return sizeof(protocolClasses) / sizeof(protocolClasses[0]);
|
||||||
case kProtocolClass:
|
default:
|
||||||
return sizeof(protocolClasses) / sizeof(protocolClasses[0]);
|
return 0;
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const BaseCap **PCL6Cap::enumCap(CapID capid) const
|
|
||||||
|
const BaseCap**
|
||||||
|
PCL6Cap::enumCap(CapID capid) const
|
||||||
{
|
{
|
||||||
switch (capid) {
|
switch (capid) {
|
||||||
case kPaper:
|
case kPaper:
|
||||||
if (getProtocolClass() >= PCL6Writer::kProtocolClass2_1) {
|
if (getProtocolClass() >= PCL6Writer::kProtocolClass2_1)
|
||||||
return (const BaseCap **)papers2_1;
|
return (const BaseCap **)papers2_1;
|
||||||
}
|
return (const BaseCap**)papers1_1;
|
||||||
return (const BaseCap **)papers1_1;
|
case kPaperSource:
|
||||||
case kPaperSource:
|
if (getProtocolClass() >= PCL6Writer::kProtocolClass2_0)
|
||||||
if (getProtocolClass() >= PCL6Writer::kProtocolClass2_0) {
|
return (const BaseCap **)paperSources2_0;
|
||||||
return (const BaseCap **)paperSources2_0;
|
return (const BaseCap**)paperSources1_1;
|
||||||
}
|
case kResolution:
|
||||||
return (const BaseCap **)paperSources1_1;
|
return (const BaseCap**)resolutions;
|
||||||
case kResolution:
|
case kColor:
|
||||||
return (const BaseCap **)resolutions;
|
return (const BaseCap**)colors;
|
||||||
case kColor:
|
case kPrintStyle:
|
||||||
return (const BaseCap **)colors;
|
return (const BaseCap**)printStyles;
|
||||||
case kPrintStyle:
|
case kProtocolClass:
|
||||||
return (const BaseCap **)printStyles;
|
return (const BaseCap**)protocolClasses;
|
||||||
case kProtocolClass:
|
default:
|
||||||
return (const BaseCap **)protocolClasses;
|
return NULL;
|
||||||
default:
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PCL6Cap::isSupport(CapID capid) const
|
|
||||||
|
bool
|
||||||
|
PCL6Cap::isSupport(CapID capid) const
|
||||||
{
|
{
|
||||||
switch (capid) {
|
switch (capid) {
|
||||||
case kPaper:
|
case kPaper:
|
||||||
case kPaperSource:
|
case kPaperSource:
|
||||||
case kResolution:
|
case kResolution:
|
||||||
case kColor:
|
case kColor:
|
||||||
case kCopyCommand:
|
case kCopyCommand:
|
||||||
case kPrintStyle:
|
case kPrintStyle:
|
||||||
case kProtocolClass:
|
case kProtocolClass:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,18 +2,19 @@
|
|||||||
* PCL6Cap.h
|
* PCL6Cap.h
|
||||||
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __PCL6CAP_H
|
#ifndef __PCL6CAP_H
|
||||||
#define __PCL6CAP_H
|
#define __PCL6CAP_H
|
||||||
|
|
||||||
|
|
||||||
#include "PrinterCap.h"
|
#include "PrinterCap.h"
|
||||||
|
|
||||||
|
|
||||||
class PCL6Cap : public PrinterCap {
|
class PCL6Cap : public PrinterCap {
|
||||||
public:
|
public:
|
||||||
PCL6Cap(const PrinterData *printer_data);
|
PCL6Cap(const PrinterData* printer_data);
|
||||||
virtual int countCap(CapID) const;
|
virtual int countCap(CapID) const;
|
||||||
virtual bool isSupport(CapID) const;
|
virtual bool isSupport(CapID) const;
|
||||||
virtual const BaseCap **enumCap(CapID) const;
|
virtual const BaseCap **enumCap(CapID) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __PCL6CAP_H */
|
#endif // __PCL6CAP_H
|
||||||
|
|||||||
@@ -2,29 +2,28 @@
|
|||||||
* PCL6Config.cpp
|
* PCL6Config.cpp
|
||||||
* Copyright 2005 Michael Pfeiffer.
|
* Copyright 2005 Michael Pfeiffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _PCL6_CONFIG
|
#ifndef _PCL6_CONFIG
|
||||||
#define _PCL6_CONFIG
|
#define _PCL6_CONFIG
|
||||||
|
|
||||||
// Compression method configuration
|
// Compression method configuration
|
||||||
// Set to 0 to disable compression and to 1 to enable compression
|
// Set to 0 to disable compression and to 1 to enable compression
|
||||||
// Note compression takes place only if it takes less space than uncompressed data!
|
// Note compression takes place only if it takes less space than uncompressed
|
||||||
|
// data!
|
||||||
|
|
||||||
// Run-Length-Encoding Compression
|
// Run-Length-Encoding Compression
|
||||||
#define ENABLE_RLE_COMPRESSION 1
|
#define ENABLE_RLE_COMPRESSION 1
|
||||||
//#define ENABLE_RLE_COMPRESSION 0
|
//#define ENABLE_RLE_COMPRESSION 0
|
||||||
|
|
||||||
// Delta Row Compression
|
// Delta Row Compression
|
||||||
#define ENABLE_DELTA_ROW_COMPRESSION 1
|
#define ENABLE_DELTA_ROW_COMPRESSION 1
|
||||||
|
|
||||||
// Color depth for color printing.
|
// Color depth for color printing.
|
||||||
// Use either 1 or 8.
|
// Use either 1 or 8.
|
||||||
// If 1 bit depth is used, the class Halftone is used for dithering
|
// If 1 bit depth is used, the class Halftone is used for dithering
|
||||||
// otherwise dithering is not performed.
|
// otherwise dithering is not performed.
|
||||||
#define COLOR_DEPTH 1
|
#define COLOR_DEPTH 1
|
||||||
//#define COLOR_DEPTH 8
|
//#define COLOR_DEPTH 8
|
||||||
|
|
||||||
#define DISPLAY_COMPRESSION_STATISTICS 0
|
#define DISPLAY_COMPRESSION_STATISTICS 0
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -4,14 +4,19 @@
|
|||||||
* Copyright 2003 Michael Pfeiffer.
|
* Copyright 2003 Michael Pfeiffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "PCL6.h"
|
#include "PCL6.h"
|
||||||
#include "PCL6Cap.h"
|
#include "PCL6Cap.h"
|
||||||
#include "PrinterDriver.h"
|
#include "PrinterDriver.h"
|
||||||
|
|
||||||
|
|
||||||
class PCL6PrinterDriver : public PrinterDriver
|
class PCL6PrinterDriver : public PrinterDriver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PCL6PrinterDriver(BNode* printerFolder) : PrinterDriver(printerFolder) {}
|
PCL6PrinterDriver(BNode* printerFolder)
|
||||||
|
:
|
||||||
|
PrinterDriver(printerFolder)
|
||||||
|
{}
|
||||||
|
|
||||||
const char* GetSignature() const
|
const char* GetSignature() const
|
||||||
{
|
{
|
||||||
@@ -23,7 +28,7 @@ public:
|
|||||||
return "PCL6 compatible";
|
return "PCL6 compatible";
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* GetVersion() const
|
const char* GetVersion() const
|
||||||
{
|
{
|
||||||
return "0.2";
|
return "0.2";
|
||||||
}
|
}
|
||||||
@@ -38,14 +43,16 @@ public:
|
|||||||
return new PCL6Cap(printerData);
|
return new PCL6Cap(printerData);
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsDriver* InstantiateGraphicsDriver(BMessage* settings, PrinterData* printerData, PrinterCap* printerCap)
|
GraphicsDriver* InstantiateGraphicsDriver(BMessage* settings,
|
||||||
|
PrinterData* printerData, PrinterCap* printerCap)
|
||||||
{
|
{
|
||||||
return new PCL6Driver(settings, printerData, printerCap);
|
return new PCL6Driver(settings, printerData, printerCap);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
PrinterDriver* instantiate_printer_driver(BNode* printerFolder)
|
|
||||||
|
PrinterDriver*
|
||||||
|
instantiate_printer_driver(BNode* printerFolder)
|
||||||
{
|
{
|
||||||
return new PCL6PrinterDriver(printerFolder);
|
return new PCL6PrinterDriver(printerFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
** PCL6Rasterizer.cpp
|
** PCL6Rasterizer.cpp
|
||||||
** Copyright 2005, Michael Pfeiffer, [email protected]. All rights reserved.
|
** Copyright 2005, Michael Pfeiffer, [email protected].
|
||||||
|
** All rights reserved.
|
||||||
** Distributed under the terms of the OpenBeOS License.
|
** Distributed under the terms of the OpenBeOS License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "PCL6Rasterizer.h"
|
#include "PCL6Rasterizer.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef _PCL6_RASTERIZER_TEST_
|
#ifdef _PCL6_RASTERIZER_TEST_
|
||||||
|
|
||||||
static void dump(uchar *buffer, int size);
|
static void dump(uchar* buffer, int size);
|
||||||
static void dump_bits(uchar *buffer, int size);
|
static void dump_bits(uchar* buffer, int size);
|
||||||
|
|
||||||
#define DUMP(text, buffer, size) { fprintf text; dump(buffer, size); }
|
#define DUMP(text, buffer, size) { fprintf text; dump(buffer, size); }
|
||||||
#define DUMP_BITS(text, buffer, size) { fprintf text; dump_bits(buffer, size); }
|
#define DUMP_BITS(text, buffer, size) { fprintf text; dump_bits(buffer, size); }
|
||||||
@@ -22,17 +25,22 @@ static void dump_bits(uchar *buffer, int size);
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// MonochromeRasterizer
|
|
||||||
|
|
||||||
MonochromeRasterizer::MonochromeRasterizer(Halftone *halftone)
|
// #pragma - MonochromeRasterizer
|
||||||
: PCL6Rasterizer(halftone)
|
|
||||||
, fOutBuffer(NULL)
|
|
||||||
{ }
|
MonochromeRasterizer::MonochromeRasterizer(Halftone* halftone)
|
||||||
|
:
|
||||||
|
PCL6Rasterizer(halftone),
|
||||||
|
fOutBuffer(NULL)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MonochromeRasterizer::InitializeBuffer() {
|
MonochromeRasterizer::InitializeBuffer()
|
||||||
|
{
|
||||||
fWidthByte = RowBufferSize(GetWidth(), 1, 1);
|
fWidthByte = RowBufferSize(GetWidth(), 1, 1);
|
||||||
/* line length is a multiple of 4 bytes */
|
// line length is a multiple of 4 bytes
|
||||||
fOutRowSize = RowBufferSize(GetWidth(), 1, 4);
|
fOutRowSize = RowBufferSize(GetWidth(), 1, 4);
|
||||||
fPadBytes = fOutRowSize - fWidthByte;
|
fPadBytes = fOutRowSize - fWidthByte;
|
||||||
// Total size
|
// Total size
|
||||||
@@ -41,38 +49,42 @@ MonochromeRasterizer::InitializeBuffer() {
|
|||||||
fCurrentLine = GetOutBuffer();
|
fCurrentLine = GetOutBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
const void *
|
|
||||||
MonochromeRasterizer::RasterizeLine(int x, int y, const ColorRGB32Little* source) {
|
const void*
|
||||||
|
MonochromeRasterizer::RasterizeLine(int x, int y,
|
||||||
|
const ColorRGB32Little* source)
|
||||||
|
{
|
||||||
GetHalftone()->dither(fCurrentLine, (const uchar*)source, x, y, GetWidth());
|
GetHalftone()->dither(fCurrentLine, (const uchar*)source, x, y, GetWidth());
|
||||||
|
|
||||||
uchar *out = fCurrentLine;
|
uchar* out = fCurrentLine;
|
||||||
|
|
||||||
// invert pixels
|
// invert pixels
|
||||||
for (int w = fWidthByte; w > 0; w --, out ++) {
|
for (int w = fWidthByte; w > 0; w --, out ++)
|
||||||
*out = ~*out;
|
*out = ~*out;
|
||||||
}
|
|
||||||
|
|
||||||
// pad with 0s
|
// pad with zeros
|
||||||
for (int w = fPadBytes; w > 0; w --, out ++) {
|
for (int w = fPadBytes; w > 0; w --, out ++)
|
||||||
*out = 0;
|
*out = 0;
|
||||||
}
|
|
||||||
|
|
||||||
void *result = fCurrentLine;
|
void* result = fCurrentLine;
|
||||||
fCurrentLine += fOutRowSize;
|
fCurrentLine += fOutRowSize;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ColorRGBRasterizer
|
// #pragma - ColorRGBRasterizer
|
||||||
|
|
||||||
|
|
||||||
|
ColorRGBRasterizer::ColorRGBRasterizer(Halftone* halftone)
|
||||||
|
:
|
||||||
|
PCL6Rasterizer(halftone)
|
||||||
|
{}
|
||||||
|
|
||||||
ColorRGBRasterizer::ColorRGBRasterizer(Halftone *halftone)
|
|
||||||
: PCL6Rasterizer(halftone)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ColorRGBRasterizer::InitializeBuffer() {
|
ColorRGBRasterizer::InitializeBuffer() {
|
||||||
fWidthByte = RowBufferSize(GetWidth(), 24, 1);
|
fWidthByte = RowBufferSize(GetWidth(), 24, 1);
|
||||||
// line length is a multiple of 4 bytes
|
// line length is a multiple of 4 bytes
|
||||||
fOutRowSize = RowBufferSize(GetWidth(), 24, 4);
|
fOutRowSize = RowBufferSize(GetWidth(), 24, 4);
|
||||||
fPadBytes = fOutRowSize - fWidthByte;
|
fPadBytes = fOutRowSize - fWidthByte;
|
||||||
// Total size
|
// Total size
|
||||||
@@ -81,10 +93,12 @@ ColorRGBRasterizer::InitializeBuffer() {
|
|||||||
fCurrentLine = GetOutBuffer();
|
fCurrentLine = GetOutBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
const void *
|
|
||||||
ColorRGBRasterizer::RasterizeLine(int x, int y, const ColorRGB32Little* source) {
|
const void*
|
||||||
|
ColorRGBRasterizer::RasterizeLine(int x, int y,
|
||||||
uchar *out = fCurrentLine;
|
const ColorRGB32Little* source)
|
||||||
|
{
|
||||||
|
uchar* out = fCurrentLine;
|
||||||
int width = GetWidth();
|
int width = GetWidth();
|
||||||
for (int w = width; w > 0; w --) {
|
for (int w = width; w > 0; w --) {
|
||||||
*out++ = source->red;
|
*out++ = source->red;
|
||||||
@@ -94,29 +108,30 @@ ColorRGBRasterizer::RasterizeLine(int x, int y, const ColorRGB32Little* source)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pad with 0s
|
// pad with 0s
|
||||||
for (int w = fPadBytes; w > 0; w --, out ++) {
|
for (int w = fPadBytes; w > 0; w --, out ++)
|
||||||
*out = 0;
|
*out = 0;
|
||||||
}
|
|
||||||
|
|
||||||
void *result = fCurrentLine;
|
void* result = fCurrentLine;
|
||||||
fCurrentLine += fOutRowSize;
|
fCurrentLine += fOutRowSize;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ColorRasterizer
|
// #pragma - ColorRasterizer
|
||||||
|
|
||||||
ColorRasterizer::ColorRasterizer::ColorRasterizer(Halftone *halftone)
|
|
||||||
: PCL6Rasterizer(halftone)
|
ColorRasterizer::ColorRasterizer::ColorRasterizer(Halftone* halftone)
|
||||||
{
|
:
|
||||||
for (int plane = 0; plane < 3; plane ++) {
|
PCL6Rasterizer(halftone)
|
||||||
|
{
|
||||||
|
for (int plane = 0; plane < 3; plane ++)
|
||||||
fPlaneBuffers[plane] = NULL;
|
fPlaneBuffers[plane] = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
halftone->setPlanes(Halftone::kPlaneRGB1);
|
halftone->setPlanes(Halftone::kPlaneRGB1);
|
||||||
halftone->setBlackValue(Halftone::kLowValueMeansBlack);
|
halftone->setBlackValue(Halftone::kLowValueMeansBlack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ColorRasterizer::~ColorRasterizer() {
|
ColorRasterizer::~ColorRasterizer() {
|
||||||
for (int plane = 0; plane < 3; plane ++) {
|
for (int plane = 0; plane < 3; plane ++) {
|
||||||
delete fPlaneBuffers[plane];
|
delete fPlaneBuffers[plane];
|
||||||
@@ -124,10 +139,11 @@ ColorRasterizer::~ColorRasterizer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ColorRasterizer::InitializeBuffer() {
|
ColorRasterizer::InitializeBuffer() {
|
||||||
fWidthByte = RowBufferSize(GetWidth(), 3, 1);
|
fWidthByte = RowBufferSize(GetWidth(), 3, 1);
|
||||||
// line length is a multiple of 4 bytes
|
// line length is a multiple of 4 bytes
|
||||||
fOutRowSize = RowBufferSize(GetWidth(), 3, 4);
|
fOutRowSize = RowBufferSize(GetWidth(), 3, 4);
|
||||||
fPadBytes = fOutRowSize - fWidthByte;
|
fPadBytes = fOutRowSize - fWidthByte;
|
||||||
// Total size
|
// Total size
|
||||||
@@ -141,21 +157,24 @@ ColorRasterizer::InitializeBuffer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
kRed = 1,
|
kRed = 1,
|
||||||
kGreen = 2,
|
kGreen = 2,
|
||||||
kBlue = 4,
|
kBlue = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
const void *
|
|
||||||
ColorRasterizer::RasterizeLine(int x, int y, const ColorRGB32Little* source) {
|
const void*
|
||||||
|
ColorRasterizer::RasterizeLine(int x, int y, const ColorRGB32Little* source)
|
||||||
DUMP((stderr, "\nRGB32 row at x %d y %d:\n", x, y), (uchar*)source, GetWidth() * 4);
|
{
|
||||||
|
DUMP((stderr, "\nRGB32 row at x %d y %d:\n", x, y), (uchar*)source,
|
||||||
|
GetWidth() * 4);
|
||||||
|
|
||||||
// dither each color component
|
// dither each color component
|
||||||
for (int plane = 0; plane < 3; plane ++) {
|
for (int plane = 0; plane < 3; plane ++)
|
||||||
GetHalftone()->dither(fPlaneBuffers[plane], (const uchar*)source, x, y, GetWidth());
|
GetHalftone()->dither(fPlaneBuffers[plane], (const uchar*)source, x, y,
|
||||||
}
|
GetWidth());
|
||||||
|
|
||||||
DUMP_BITS((stderr, "red "), fPlaneBuffers[0], fPlaneBufferSize);
|
DUMP_BITS((stderr, "red "), fPlaneBuffers[0], fPlaneBufferSize);
|
||||||
DUMP_BITS((stderr, "green "), fPlaneBuffers[1], fPlaneBufferSize);
|
DUMP_BITS((stderr, "green "), fPlaneBuffers[1], fPlaneBufferSize);
|
||||||
@@ -166,56 +185,57 @@ ColorRasterizer::RasterizeLine(int x, int y, const ColorRGB32Little* source) {
|
|||||||
DUMP_BITS((stderr, "merged\n"), fCurrentLine, fOutRowSize);
|
DUMP_BITS((stderr, "merged\n"), fCurrentLine, fOutRowSize);
|
||||||
DUMP((stderr, "\n"), fCurrentLine, fOutRowSize);
|
DUMP((stderr, "\n"), fCurrentLine, fOutRowSize);
|
||||||
|
|
||||||
void *result = fCurrentLine;
|
void* result = fCurrentLine;
|
||||||
fCurrentLine += fOutRowSize;
|
fCurrentLine += fOutRowSize;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ColorRasterizer::MergePlaneBuffersToCurrentLine()
|
ColorRasterizer::MergePlaneBuffersToCurrentLine()
|
||||||
{
|
{
|
||||||
// merge the three planes into output buffer
|
// merge the three planes into output buffer
|
||||||
int remainingPixels = GetWidth();
|
int remainingPixels = GetWidth();
|
||||||
uchar *out = fCurrentLine;
|
uchar* out = fCurrentLine;
|
||||||
uchar value = 0;
|
uchar value = 0;
|
||||||
uchar outMask = 0x80; // current bit mask (1 << (8 - bit)) in output buffer
|
uchar outMask = 0x80; // current bit mask (1 << (8 - bit)) in output buffer
|
||||||
|
|
||||||
// iterate over the three plane buffers
|
// iterate over the three plane buffers
|
||||||
for (int i = 0; i < fPlaneBufferSize; i ++) {
|
for (int i = 0; i < fPlaneBufferSize; i ++) {
|
||||||
int pixels = 8;
|
int pixels = 8;
|
||||||
if (remainingPixels < 8) {
|
if (remainingPixels < 8)
|
||||||
pixels = remainingPixels;
|
pixels = remainingPixels;
|
||||||
}
|
|
||||||
remainingPixels -= pixels;
|
remainingPixels -= pixels;
|
||||||
|
|
||||||
if (remainingPixels >= 8) {
|
if (remainingPixels >= 8) {
|
||||||
register const uchar
|
register const uchar
|
||||||
red = fPlaneBuffers[0][i],
|
red = fPlaneBuffers[0][i],
|
||||||
green = fPlaneBuffers[1][i],
|
green = fPlaneBuffers[1][i],
|
||||||
blue = fPlaneBuffers[2][i];
|
blue = fPlaneBuffers[2][i];
|
||||||
|
|
||||||
register uchar value = 0;
|
register uchar value = 0;
|
||||||
if (red & 0x80) value = 0x80;
|
if (red & 0x80) value = 0x80;
|
||||||
if (red & 0x40) value |= 0x10;
|
if (red & 0x40) value |= 0x10;
|
||||||
if (red & 0x20) value |= 0x02;
|
if (red & 0x20) value |= 0x02;
|
||||||
|
|
||||||
if (green & 0x80) value |= 0x40;
|
if (green & 0x80) value |= 0x40;
|
||||||
if (green & 0x40) value |= 0x08;
|
if (green & 0x40) value |= 0x08;
|
||||||
if (green & 0x20) value |= 0x01;
|
if (green & 0x20) value |= 0x01;
|
||||||
|
|
||||||
if (blue & 0x80) value |= 0x20;
|
if (blue & 0x80) value |= 0x20;
|
||||||
if (blue & 0x40) value |= 0x04;
|
if (blue & 0x40) value |= 0x04;
|
||||||
|
|
||||||
*out++ = value;
|
*out++ = value;
|
||||||
|
|
||||||
value = 0;
|
value = 0;
|
||||||
if (blue & 0x20) value = 0x80;
|
if (blue & 0x20) value = 0x80;
|
||||||
if (blue & 0x10) value |= 0x10;
|
if (blue & 0x10) value |= 0x10;
|
||||||
if (blue & 0x08) value |= 0x02;
|
if (blue & 0x08) value |= 0x02;
|
||||||
|
|
||||||
if (red & 0x10) value |= 0x40;
|
if (red & 0x10) value |= 0x40;
|
||||||
if (red & 0x08) value |= 0x08;
|
if (red & 0x08) value |= 0x08;
|
||||||
if (red & 0x04) value |= 0x01;
|
if (red & 0x04) value |= 0x01;
|
||||||
|
|
||||||
if (green & 0x10) value |= 0x20;
|
if (green & 0x10) value |= 0x20;
|
||||||
if (green & 0x08) value |= 0x04;
|
if (green & 0x08) value |= 0x04;
|
||||||
@@ -226,39 +246,35 @@ ColorRasterizer::MergePlaneBuffersToCurrentLine()
|
|||||||
if (green & 0x02) value |= 0x10;
|
if (green & 0x02) value |= 0x10;
|
||||||
if (green & 0x01) value |= 0x02;
|
if (green & 0x01) value |= 0x02;
|
||||||
|
|
||||||
if (blue & 0x04) value |= 0x40;
|
if (blue & 0x04) value |= 0x40;
|
||||||
if (blue & 0x02) value |= 0x08;
|
if (blue & 0x02) value |= 0x08;
|
||||||
if (blue & 0x01) value |= 0x01;
|
if (blue & 0x01) value |= 0x01;
|
||||||
|
|
||||||
if (red & 0x02) value |= 0x20;
|
if (red & 0x02) value |= 0x20;
|
||||||
if (red & 0x01) value |= 0x04;
|
if (red & 0x01) value |= 0x04;
|
||||||
*out++ = value;
|
*out++ = value;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
register const uchar
|
register const uchar
|
||||||
red = fPlaneBuffers[0][i],
|
red = fPlaneBuffers[0][i],
|
||||||
green = fPlaneBuffers[1][i],
|
green = fPlaneBuffers[1][i],
|
||||||
blue = fPlaneBuffers[2][i];
|
blue = fPlaneBuffers[2][i];
|
||||||
// for each bit in the current byte of each plane
|
// for each bit in the current byte of each plane
|
||||||
uchar mask = 0x80;
|
uchar mask = 0x80;
|
||||||
for (; pixels > 0; pixels --) {
|
for (; pixels > 0; pixels --) {
|
||||||
int rgb = 0;
|
int rgb = 0;
|
||||||
|
|
||||||
if (red & mask) {
|
if (red & mask)
|
||||||
rgb |= kRed;
|
rgb |= kRed;
|
||||||
}
|
if (green & mask)
|
||||||
if (green & mask) {
|
|
||||||
rgb |= kGreen;
|
rgb |= kGreen;
|
||||||
}
|
if (blue & mask)
|
||||||
if (blue & mask) {
|
|
||||||
rgb |= kBlue;
|
rgb |= kBlue;
|
||||||
}
|
|
||||||
|
|
||||||
for (int plane = 0; plane < 3; plane ++) {
|
for (int plane = 0; plane < 3; plane ++) {
|
||||||
// copy pixel value to output value
|
// copy pixel value to output value
|
||||||
if (rgb & (1 << plane)) {
|
if (rgb & (1 << plane))
|
||||||
value |= outMask;
|
value |= outMask;
|
||||||
}
|
|
||||||
|
|
||||||
// increment output mask
|
// increment output mask
|
||||||
if (outMask == 0x01) {
|
if (outMask == 0x01) {
|
||||||
@@ -267,9 +283,8 @@ ColorRasterizer::MergePlaneBuffersToCurrentLine()
|
|||||||
*out = value;
|
*out = value;
|
||||||
out ++;
|
out ++;
|
||||||
value = 0;
|
value = 0;
|
||||||
} else {
|
} else
|
||||||
outMask >>= 1;
|
outMask >>= 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mask >>= 1;
|
mask >>= 1;
|
||||||
}
|
}
|
||||||
@@ -287,20 +302,20 @@ ColorRasterizer::MergePlaneBuffersToCurrentLine()
|
|||||||
out ++;
|
out ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (out - fCurrentLine != fWidthByte) {
|
if (out - fCurrentLine != fWidthByte)
|
||||||
fprintf(stderr, "Error buffer overflow: %d != %d\n", fWidthByte, (int)(out - fCurrentLine));
|
fprintf(stderr, "Error buffer overflow: %d != %d\n", fWidthByte,
|
||||||
}
|
static_cast<int>(out - fCurrentLine));
|
||||||
|
|
||||||
// pad with 0s
|
// pad with zeros
|
||||||
for (int w = fPadBytes; w > 0; w --, out ++) {
|
for (int w = fPadBytes; w > 0; w --, out ++)
|
||||||
*out = 0xff;
|
*out = 0xff;
|
||||||
}
|
|
||||||
|
|
||||||
if (out - fCurrentLine != fOutRowSize) {
|
if (out - fCurrentLine != fOutRowSize)
|
||||||
fprintf(stderr, "Error buffer overflow: %d != %d\n", fOutRowSize, (int)(out - fCurrentLine));
|
fprintf(stderr, "Error buffer overflow: %d != %d\n", fOutRowSize,
|
||||||
}
|
static_cast<int>(out - fCurrentLine));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef _PCL6_RASTERIZER_TEST_
|
#ifdef _PCL6_RASTERIZER_TEST_
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
@@ -309,7 +324,9 @@ ColorRasterizer::MergePlaneBuffersToCurrentLine()
|
|||||||
#define COLUMNS 40
|
#define COLUMNS 40
|
||||||
#define BIT_COLUMNS 6
|
#define BIT_COLUMNS 6
|
||||||
|
|
||||||
static void dump(uchar *buffer, int size)
|
|
||||||
|
static void
|
||||||
|
dump(uchar* buffer, int size)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
for (int i = 0; i < size; i ++) {
|
for (int i = 0; i < size; i ++) {
|
||||||
@@ -328,7 +345,9 @@ static void dump(uchar *buffer, int size)
|
|||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dump_bits(uchar *buffer, int size)
|
|
||||||
|
static void
|
||||||
|
dump_bits(uchar* buffer, int size)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
for (int i = 0; i < size; i ++) {
|
for (int i = 0; i < size; i ++) {
|
||||||
@@ -354,25 +373,29 @@ static void dump_bits(uchar *buffer, int size)
|
|||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fill(uchar *_row, int width, ColorRGB32Little color)
|
|
||||||
|
static void
|
||||||
|
fill(uchar* _row, int width, ColorRGB32Little color)
|
||||||
{
|
{
|
||||||
ColorRGB32Little *row = (ColorRGB32Little *)_row;
|
ColorRGB32Little* row = static_cast<ColorRGB32Little*>(_row);
|
||||||
for (int i = 0; i < width; i ++) {
|
for (int i = 0; i < width; i ++) {
|
||||||
*row = color;
|
*row = color;
|
||||||
row ++;
|
row ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initializeBitmap(BBitmap *bitmap, int width, int height)
|
|
||||||
|
static void
|
||||||
|
initializeBitmap(BBitmap* bitmap, int width, int height)
|
||||||
{
|
{
|
||||||
int bpr = bitmap->BytesPerRow();
|
int bpr = bitmap->BytesPerRow();
|
||||||
uchar *row = (uchar*)bitmap->Bits();
|
uchar* row = (uchar*)bitmap->Bits();
|
||||||
// BGRA
|
// BGRA
|
||||||
ColorRGB32Little black = {0, 0, 0, 0};
|
ColorRGB32Little black = {0, 0, 0, 0};
|
||||||
ColorRGB32Little white = {255, 255, 255, 0};
|
ColorRGB32Little white = {255, 255, 255, 0};
|
||||||
ColorRGB32Little red = {0, 0, 255, 0};
|
ColorRGB32Little red = {0, 0, 255, 0};
|
||||||
ColorRGB32Little green = {0, 255, 0, 0};
|
ColorRGB32Little green = {0, 255, 0, 0};
|
||||||
ColorRGB32Little blue = {255, 0, 0, 0};
|
ColorRGB32Little blue = {255, 0, 0, 0};
|
||||||
|
|
||||||
fprintf(stderr, "black row\n");
|
fprintf(stderr, "black row\n");
|
||||||
fill(row, width, black);
|
fill(row, width, black);
|
||||||
@@ -387,7 +410,7 @@ static void initializeBitmap(BBitmap *bitmap, int width, int height)
|
|||||||
row += bpr;
|
row += bpr;
|
||||||
|
|
||||||
fprintf(stderr, "red green blue pattern");
|
fprintf(stderr, "red green blue pattern");
|
||||||
ColorRGB32Little *color = (ColorRGB32Little*)row;
|
ColorRGB32Little* color = (ColorRGB32Little*)row;
|
||||||
for (int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
switch (i % 3) {
|
switch (i % 3) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -404,7 +427,9 @@ static void initializeBitmap(BBitmap *bitmap, int width, int height)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
{
|
{
|
||||||
const int width = 10;
|
const int width = 10;
|
||||||
const int height = 4;
|
const int height = 4;
|
||||||
@@ -417,7 +442,7 @@ int main()
|
|||||||
Halftone halftone(B_RGB32, 0.25f, 0.0f, Halftone::kTypeFloydSteinberg);
|
Halftone halftone(B_RGB32, 0.25f, 0.0f, Halftone::kTypeFloydSteinberg);
|
||||||
#endif
|
#endif
|
||||||
ColorRasterizer rasterizer(&halftone);
|
ColorRasterizer rasterizer(&halftone);
|
||||||
BBitmap bitmap(BRect(0, 0, width-1, height-1), B_RGB32);
|
BBitmap bitmap(BRect(0, 0, width - 1, height - 1), B_RGB32);
|
||||||
|
|
||||||
initializeBitmap(&bitmap, width, height);
|
initializeBitmap(&bitmap, width, height);
|
||||||
|
|
||||||
@@ -428,4 +453,4 @@ int main()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif // _PCL6_RASTERIZER_TEST_
|
||||||
|
|||||||
@@ -1,111 +1,139 @@
|
|||||||
/*
|
/*
|
||||||
** PCL6Rasterizer.h
|
** PCL6Rasterizer.h
|
||||||
** Copyright 2005, Michael Pfeiffer, [email protected]. All rights reserved.
|
** Copyright 2005, Michael Pfeiffer, [email protected].
|
||||||
|
** All rights reserved.
|
||||||
** Distributed under the terms of the OpenBeOS License.
|
** Distributed under the terms of the OpenBeOS License.
|
||||||
*/
|
*/
|
||||||
#ifndef _PCL6_RASTERIZER_H
|
#ifndef _PCL6_RASTERIZER_H
|
||||||
#define _PCL6_RASTERIZER_H
|
#define _PCL6_RASTERIZER_H
|
||||||
|
|
||||||
|
|
||||||
#include "Rasterizer.h"
|
#include "Rasterizer.h"
|
||||||
|
|
||||||
|
|
||||||
class PCL6Rasterizer : public Rasterizer
|
class PCL6Rasterizer : public Rasterizer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PCL6Rasterizer(Halftone *halftone)
|
PCL6Rasterizer(Halftone* halftone)
|
||||||
: Rasterizer(halftone)
|
:
|
||||||
, fOutBuffer(NULL)
|
Rasterizer(halftone),
|
||||||
, fOutBufferSize(0)
|
fOutBuffer(NULL),
|
||||||
{
|
fOutBufferSize(0)
|
||||||
}
|
{}
|
||||||
|
|
||||||
~PCL6Rasterizer()
|
~PCL6Rasterizer()
|
||||||
{
|
{
|
||||||
delete fOutBuffer;
|
delete fOutBuffer;
|
||||||
fOutBuffer = NULL;
|
fOutBuffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetOutBufferSize(int size) { fOutBufferSize = size; }
|
void SetOutBufferSize(int size)
|
||||||
int GetOutBufferSize() { return fOutBufferSize; }
|
{
|
||||||
|
fOutBufferSize = size;
|
||||||
uchar *GetOutBuffer() { return fOutBuffer; }
|
}
|
||||||
|
int GetOutBufferSize()
|
||||||
|
{
|
||||||
|
return fOutBufferSize;
|
||||||
|
}
|
||||||
|
uchar* GetOutBuffer()
|
||||||
|
{
|
||||||
|
return fOutBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void InitializeBuffer() {
|
virtual void InitializeBuffer()
|
||||||
fOutBuffer = new uchar[fOutBufferSize];
|
{
|
||||||
}
|
fOutBuffer = new uchar[fOutBufferSize];
|
||||||
|
}
|
||||||
|
|
||||||
virtual int GetOutRowSize() = 0;
|
virtual int GetOutRowSize() = 0;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uchar *fOutBuffer;
|
uchar* fOutBuffer;
|
||||||
int fOutBufferSize;
|
int fOutBufferSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MonochromeRasterizer : public PCL6Rasterizer
|
class MonochromeRasterizer : public PCL6Rasterizer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MonochromeRasterizer(Halftone *halftone);
|
MonochromeRasterizer(Halftone* halftone);
|
||||||
|
|
||||||
|
void InitializeBuffer();
|
||||||
|
|
||||||
void InitializeBuffer();
|
int GetOutRowSize()
|
||||||
|
{
|
||||||
int GetOutRowSize() { return fOutRowSize; }
|
return fOutRowSize;
|
||||||
|
}
|
||||||
|
|
||||||
const void *RasterizeLine(int x, int y, const ColorRGB32Little* source);
|
const void* RasterizeLine(int x, int y,
|
||||||
|
const ColorRGB32Little* source);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int fWidthByte;
|
int fWidthByte;
|
||||||
int fOutRowSize;
|
int fOutRowSize;
|
||||||
int fPadBytes;
|
int fPadBytes;
|
||||||
int fOutSize;
|
int fOutSize;
|
||||||
uchar *fOutBuffer;
|
uchar* fOutBuffer;
|
||||||
uchar *fCurrentLine;
|
uchar* fCurrentLine;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Output format RGB 8bit per channel
|
// Output format RGB 8bit per channel
|
||||||
class ColorRGBRasterizer : public PCL6Rasterizer
|
class ColorRGBRasterizer : public PCL6Rasterizer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ColorRGBRasterizer(Halftone *halftone) ;
|
ColorRGBRasterizer(Halftone* halftone);
|
||||||
|
|
||||||
void InitializeBuffer();
|
void InitializeBuffer();
|
||||||
|
|
||||||
int GetOutRowSize() { return fOutRowSize; }
|
int GetOutRowSize()
|
||||||
|
{
|
||||||
|
return fOutRowSize;
|
||||||
|
}
|
||||||
|
|
||||||
const void *RasterizeLine(int x, int y, const ColorRGB32Little* source);
|
const void* RasterizeLine(int x, int y,
|
||||||
|
const ColorRGB32Little* source);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int fWidthByte;
|
int fWidthByte;
|
||||||
int fOutRowSize;
|
int fOutRowSize;
|
||||||
int fPadBytes;
|
int fPadBytes;
|
||||||
uchar *fCurrentLine;
|
uchar* fCurrentLine;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef uchar *PlaneBuffer;
|
|
||||||
|
typedef uchar* PlaneBuffer;
|
||||||
|
|
||||||
|
|
||||||
// Output format: RGB 1bit per channel
|
// Output format: RGB 1bit per channel
|
||||||
// Class Halftone is used for dithering
|
// Class Halftone is used for dithering
|
||||||
class ColorRasterizer : public PCL6Rasterizer
|
class ColorRasterizer : public PCL6Rasterizer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ColorRasterizer(Halftone *halftone);
|
ColorRasterizer(Halftone* halftone);
|
||||||
|
|
||||||
~ColorRasterizer();
|
~ColorRasterizer();
|
||||||
|
|
||||||
void InitializeBuffer();
|
void InitializeBuffer();
|
||||||
|
|
||||||
int GetOutRowSize() { return fOutRowSize; }
|
int GetOutRowSize()
|
||||||
|
{
|
||||||
|
return fOutRowSize;
|
||||||
|
}
|
||||||
|
|
||||||
const void *RasterizeLine(int x, int y, const ColorRGB32Little* source);
|
const void* RasterizeLine(int x, int y,
|
||||||
|
const ColorRGB32Little* source);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void MergePlaneBuffersToCurrentLine();
|
void MergePlaneBuffersToCurrentLine();
|
||||||
|
|
||||||
int fWidthByte;
|
int fWidthByte;
|
||||||
int fOutRowSize;
|
int fOutRowSize;
|
||||||
int fPadBytes;
|
int fPadBytes;
|
||||||
uchar *fCurrentLine;
|
uchar* fCurrentLine;
|
||||||
|
|
||||||
int fPlaneBufferSize;
|
int fPlaneBufferSize;
|
||||||
PlaneBuffer fPlaneBuffers[3];
|
PlaneBuffer fPlaneBuffers[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // _PCL6_RASTERIZER_H
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
** PCL6Writer.cpp
|
** PCL6Writer.cpp
|
||||||
** Copyright 2005, Michael Pfeiffer, [email protected]. All rights reserved.
|
** Copyright 2005, Michael Pfeiffer, [email protected].
|
||||||
|
** All rights reserved.
|
||||||
** Distributed under the terms of the OpenBeOS License.
|
** Distributed under the terms of the OpenBeOS License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "PCL6Writer.h"
|
#include "PCL6Writer.h"
|
||||||
|
|
||||||
#include <ByteOrder.h>
|
#include <ByteOrder.h>
|
||||||
@@ -10,53 +13,66 @@
|
|||||||
|
|
||||||
#define BYTE_AT(lvalue, index) (((uint8*)(&lvalue))[index])
|
#define BYTE_AT(lvalue, index) (((uint8*)(&lvalue))[index])
|
||||||
|
|
||||||
PCL6Writer::PCL6Writer(PCL6WriterStream *stream, uint32 bufferSize)
|
|
||||||
: fStream(stream),
|
PCL6Writer::PCL6Writer(PCL6WriterStream* stream, uint32 bufferSize)
|
||||||
fBuffer(new uint8[bufferSize]),
|
:
|
||||||
fSize(bufferSize),
|
fStream(stream),
|
||||||
fIndex(0)
|
fBuffer(new uint8[bufferSize]),
|
||||||
|
fSize(bufferSize),
|
||||||
|
fIndex(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PCL6Writer::~PCL6Writer() {
|
|
||||||
|
PCL6Writer::~PCL6Writer()
|
||||||
|
{
|
||||||
delete fBuffer;
|
delete fBuffer;
|
||||||
fBuffer = NULL;
|
fBuffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// throws TransportException
|
// throws TransportException
|
||||||
void
|
void
|
||||||
PCL6Writer::Append(uint8 value) {
|
PCL6Writer::Append(uint8 value)
|
||||||
if (fIndex == fSize) {
|
{
|
||||||
|
if (fIndex == fSize)
|
||||||
Flush();
|
Flush();
|
||||||
}
|
|
||||||
fBuffer[fIndex] = value;
|
fBuffer[fIndex] = value;
|
||||||
fIndex ++;
|
fIndex ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::Flush() {
|
PCL6Writer::Flush()
|
||||||
|
{
|
||||||
if (fIndex > 0) {
|
if (fIndex > 0) {
|
||||||
fStream->write(fBuffer, fIndex);
|
fStream->write(fBuffer, fIndex);
|
||||||
fIndex = 0;
|
fIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::Append(int16 value) {
|
PCL6Writer::Append(int16 value)
|
||||||
|
{
|
||||||
int16 v = B_HOST_TO_LENDIAN_INT16(value);
|
int16 v = B_HOST_TO_LENDIAN_INT16(value);
|
||||||
Append(BYTE_AT(v, 0));
|
Append(BYTE_AT(v, 0));
|
||||||
Append(BYTE_AT(v, 1));
|
Append(BYTE_AT(v, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::Append(uint16 value) {
|
PCL6Writer::Append(uint16 value)
|
||||||
|
{
|
||||||
int16 v = B_HOST_TO_LENDIAN_INT16(value);
|
int16 v = B_HOST_TO_LENDIAN_INT16(value);
|
||||||
Append(BYTE_AT(v, 0));
|
Append(BYTE_AT(v, 0));
|
||||||
Append(BYTE_AT(v, 1));
|
Append(BYTE_AT(v, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::Append(int32 value) {
|
PCL6Writer::Append(int32 value)
|
||||||
|
{
|
||||||
int32 v = B_HOST_TO_LENDIAN_INT32(value);
|
int32 v = B_HOST_TO_LENDIAN_INT32(value);
|
||||||
Append(BYTE_AT(v, 0));
|
Append(BYTE_AT(v, 0));
|
||||||
Append(BYTE_AT(v, 1));
|
Append(BYTE_AT(v, 1));
|
||||||
@@ -64,8 +80,10 @@ PCL6Writer::Append(int32 value) {
|
|||||||
Append(BYTE_AT(v, 3));
|
Append(BYTE_AT(v, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::Append(uint32 value) {
|
PCL6Writer::Append(uint32 value)
|
||||||
|
{
|
||||||
int32 v = B_HOST_TO_LENDIAN_INT32(value);
|
int32 v = B_HOST_TO_LENDIAN_INT32(value);
|
||||||
Append(BYTE_AT(v, 0));
|
Append(BYTE_AT(v, 0));
|
||||||
Append(BYTE_AT(v, 1));
|
Append(BYTE_AT(v, 1));
|
||||||
@@ -73,8 +91,10 @@ PCL6Writer::Append(uint32 value) {
|
|||||||
Append(BYTE_AT(v, 3));
|
Append(BYTE_AT(v, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::Append(float value) {
|
PCL6Writer::Append(float value)
|
||||||
|
{
|
||||||
float v = B_HOST_TO_LENDIAN_FLOAT(value);
|
float v = B_HOST_TO_LENDIAN_FLOAT(value);
|
||||||
Append(BYTE_AT(v, 0));
|
Append(BYTE_AT(v, 0));
|
||||||
Append(BYTE_AT(v, 1));
|
Append(BYTE_AT(v, 1));
|
||||||
@@ -82,8 +102,10 @@ PCL6Writer::Append(float value) {
|
|||||||
Append(BYTE_AT(v, 3));
|
Append(BYTE_AT(v, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::Append(const uint8* data, uint32 size) {
|
PCL6Writer::Append(const uint8* data, uint32 size)
|
||||||
|
{
|
||||||
for (uint32 i = 0; i < size; i++) {
|
for (uint32 i = 0; i < size; i++) {
|
||||||
Append(data[i]);
|
Append(data[i]);
|
||||||
}
|
}
|
||||||
@@ -91,7 +113,8 @@ PCL6Writer::Append(const uint8* data, uint32 size) {
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::AppendString(const char *string) {
|
PCL6Writer::AppendString(const char* string)
|
||||||
|
{
|
||||||
uint8 ch = *string;
|
uint8 ch = *string;
|
||||||
while (ch != 0) {
|
while (ch != 0) {
|
||||||
Append(ch);
|
Append(ch);
|
||||||
@@ -100,60 +123,80 @@ PCL6Writer::AppendString(const char *string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::AppendOperator(Operator op) {
|
PCL6Writer::AppendOperator(Operator op)
|
||||||
|
{
|
||||||
Append((uint8)op);
|
Append((uint8)op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::AppendAttribute(Attribute attr) {
|
PCL6Writer::AppendAttribute(Attribute attr)
|
||||||
|
{
|
||||||
AppendDataTag(k8BitAttrId);
|
AppendDataTag(k8BitAttrId);
|
||||||
Append((uint8)attr);
|
Append((uint8)attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::AppendDataTag(DataTag tag) {
|
PCL6Writer::AppendDataTag(DataTag tag)
|
||||||
|
{
|
||||||
Append((uint8)tag);
|
Append((uint8)tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::AppendData(uint8 value) {
|
PCL6Writer::AppendData(uint8 value)
|
||||||
|
{
|
||||||
AppendDataTag(kUByteData);
|
AppendDataTag(kUByteData);
|
||||||
Append(value);
|
Append(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::AppendData(int16 value) {
|
PCL6Writer::AppendData(int16 value)
|
||||||
|
{
|
||||||
AppendDataTag(kSInt16Data);
|
AppendDataTag(kSInt16Data);
|
||||||
Append(value);
|
Append(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::AppendData(uint16 value) {
|
PCL6Writer::AppendData(uint16 value)
|
||||||
|
{
|
||||||
AppendDataTag(kUInt16Data);
|
AppendDataTag(kUInt16Data);
|
||||||
Append(value);
|
Append(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::AppendData(int32 value) {
|
PCL6Writer::AppendData(int32 value)
|
||||||
|
{
|
||||||
AppendDataTag(kSInt32Data);
|
AppendDataTag(kSInt32Data);
|
||||||
Append(value);
|
Append(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::AppendData(uint32 value) {
|
PCL6Writer::AppendData(uint32 value)
|
||||||
|
{
|
||||||
AppendDataTag(kUInt32Data);
|
AppendDataTag(kUInt32Data);
|
||||||
Append(value);
|
Append(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::AppendData(float value) {
|
PCL6Writer::AppendData(float value)
|
||||||
|
{
|
||||||
AppendDataTag(kReal32Data);
|
AppendDataTag(kReal32Data);
|
||||||
Append(value);
|
Append(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::EmbeddedDataPrefix(uint32 size) {
|
PCL6Writer::EmbeddedDataPrefix(uint32 size)
|
||||||
|
{
|
||||||
if (size < 256) {
|
if (size < 256) {
|
||||||
AppendDataTag(kEmbeddedDataByte);
|
AppendDataTag(kEmbeddedDataByte);
|
||||||
Append((uint8)size);
|
Append((uint8)size);
|
||||||
@@ -163,60 +206,72 @@ PCL6Writer::EmbeddedDataPrefix(uint32 size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::EmbeddedDataPrefix32(uint32 size) {
|
PCL6Writer::EmbeddedDataPrefix32(uint32 size)
|
||||||
|
{
|
||||||
AppendDataTag(kEmbeddedData);
|
AppendDataTag(kEmbeddedData);
|
||||||
Append(size);
|
Append(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::AppendDataXY(uint8 x, uint8 y) {
|
PCL6Writer::AppendDataXY(uint8 x, uint8 y)
|
||||||
|
{
|
||||||
AppendDataTag(kUByteXY);
|
AppendDataTag(kUByteXY);
|
||||||
Append(x); Append(y);
|
Append(x); Append(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::AppendDataXY(int16 x, int16 y) {
|
PCL6Writer::AppendDataXY(int16 x, int16 y)
|
||||||
|
{
|
||||||
AppendDataTag(kSInt16XY);
|
AppendDataTag(kSInt16XY);
|
||||||
Append(x); Append(y);
|
Append(x); Append(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::AppendDataXY(uint16 x, uint16 y) {
|
PCL6Writer::AppendDataXY(uint16 x, uint16 y)
|
||||||
|
{
|
||||||
AppendDataTag(kUInt16XY);
|
AppendDataTag(kUInt16XY);
|
||||||
Append(x); Append(y);
|
Append(x); Append(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::AppendDataXY(int32 x, int32 y) {
|
PCL6Writer::AppendDataXY(int32 x, int32 y)
|
||||||
|
{
|
||||||
AppendDataTag(kSInt32XY);
|
AppendDataTag(kSInt32XY);
|
||||||
Append(x); Append(y);
|
Append(x); Append(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::AppendDataXY(uint32 x, uint32 y) {
|
PCL6Writer::AppendDataXY(uint32 x, uint32 y)
|
||||||
|
{
|
||||||
AppendDataTag(kUInt32XY);
|
AppendDataTag(kUInt32XY);
|
||||||
Append(x); Append(y);
|
Append(x); Append(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::AppendDataXY(float x, float y) {
|
PCL6Writer::AppendDataXY(float x, float y)
|
||||||
|
{
|
||||||
AppendDataTag(kReal32XY);
|
AppendDataTag(kReal32XY);
|
||||||
Append(x); Append(y);
|
Append(x); Append(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::PJLHeader(ProtocolClass protocolClass, int dpi, const char *comment)
|
PCL6Writer::PJLHeader(ProtocolClass protocolClass, int dpi, const char* comment)
|
||||||
{
|
{
|
||||||
BString string;
|
BString string;
|
||||||
AppendString("\033%-12345X@PJL JOB\n"
|
AppendString("\033%-12345X@PJL JOB\n@PJL SET RESOLUTION=");
|
||||||
"@PJL SET RESOLUTION=");
|
|
||||||
string << dpi;
|
string << dpi;
|
||||||
AppendString(string.String());
|
AppendString(string.String());
|
||||||
AppendString("\n"
|
AppendString("\n@PJL ENTER LANGUAGE=PCLXL\n) HP-PCL XL;");
|
||||||
"@PJL ENTER LANGUAGE=PCLXL\n"
|
|
||||||
") HP-PCL XL;");
|
|
||||||
|
|
||||||
const char* pc = "";
|
const char* pc = "";
|
||||||
switch (protocolClass) {
|
switch (protocolClass) {
|
||||||
case kProtocolClass1_1:
|
case kProtocolClass1_1:
|
||||||
@@ -242,16 +297,18 @@ PCL6Writer::PJLHeader(ProtocolClass protocolClass, int dpi, const char *comment)
|
|||||||
AppendString("\n");
|
AppendString("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::PJLFooter()
|
PCL6Writer::PJLFooter()
|
||||||
{
|
{
|
||||||
AppendString("\033%-12345X@PJL EOJ\n"
|
AppendString("\033%-12345X@PJL EOJ\n\033%-12345X");
|
||||||
"\033%-12345X");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::BeginSession(uint16 xres, uint16 yres, UnitOfMeasure unitOfMeasure, ErrorReporting errorReporting) {
|
PCL6Writer::BeginSession(uint16 xres, uint16 yres, UnitOfMeasure unitOfMeasure,
|
||||||
|
ErrorReporting errorReporting)
|
||||||
|
{
|
||||||
AppendDataXY(xres, yres);
|
AppendDataXY(xres, yres);
|
||||||
AppendAttribute(kUnitsPerMeasure);
|
AppendAttribute(kUnitsPerMeasure);
|
||||||
|
|
||||||
@@ -264,13 +321,17 @@ PCL6Writer::BeginSession(uint16 xres, uint16 yres, UnitOfMeasure unitOfMeasure,
|
|||||||
AppendOperator(kBeginSession);
|
AppendOperator(kBeginSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::EndSession() {
|
PCL6Writer::EndSession()
|
||||||
|
{
|
||||||
AppendOperator(kEndSession);
|
AppendOperator(kEndSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::OpenDataSource() {
|
PCL6Writer::OpenDataSource()
|
||||||
|
{
|
||||||
AppendData((uint8)kDefaultDataSource);
|
AppendData((uint8)kDefaultDataSource);
|
||||||
AppendAttribute(kSourceType);
|
AppendAttribute(kSourceType);
|
||||||
|
|
||||||
@@ -280,14 +341,18 @@ PCL6Writer::OpenDataSource() {
|
|||||||
AppendOperator(kOpenDataSource);
|
AppendOperator(kOpenDataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::CloseDataSource() {
|
PCL6Writer::CloseDataSource()
|
||||||
|
{
|
||||||
AppendOperator(kCloseDataSource);
|
AppendOperator(kCloseDataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::BeginPage(Orientation orientation, MediaSize mediaSize, MediaSource mediaSource) {
|
PCL6Writer::BeginPage(Orientation orientation, MediaSize mediaSize,
|
||||||
|
MediaSource mediaSource)
|
||||||
|
{
|
||||||
AppendData((uint8)orientation);
|
AppendData((uint8)orientation);
|
||||||
AppendAttribute(kOrientation);
|
AppendAttribute(kOrientation);
|
||||||
|
|
||||||
@@ -300,8 +365,11 @@ PCL6Writer::BeginPage(Orientation orientation, MediaSize mediaSize, MediaSource
|
|||||||
AppendOperator(kBeginPage);
|
AppendOperator(kBeginPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::BeginPage(Orientation orientation, MediaSize mediaSize, MediaSource mediaSource, DuplexPageMode duplexPageMode, MediaSide mediaSide) {
|
PCL6Writer::BeginPage(Orientation orientation, MediaSize mediaSize,
|
||||||
|
MediaSource mediaSource, DuplexPageMode duplexPageMode, MediaSide mediaSide)
|
||||||
|
{
|
||||||
AppendData((uint8)orientation);
|
AppendData((uint8)orientation);
|
||||||
AppendAttribute(kOrientation);
|
AppendAttribute(kOrientation);
|
||||||
|
|
||||||
@@ -320,8 +388,10 @@ PCL6Writer::BeginPage(Orientation orientation, MediaSize mediaSize, MediaSource
|
|||||||
AppendOperator(kBeginPage);
|
AppendOperator(kBeginPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::EndPage(uint16 copies) {
|
PCL6Writer::EndPage(uint16 copies)
|
||||||
|
{
|
||||||
// if (copies != 1) {
|
// if (copies != 1) {
|
||||||
AppendData(copies);
|
AppendData(copies);
|
||||||
AppendAttribute(kPageCopies);
|
AppendAttribute(kPageCopies);
|
||||||
@@ -332,47 +402,58 @@ PCL6Writer::EndPage(uint16 copies) {
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::SetPageOrigin(int16 x, int16 y) {
|
PCL6Writer::SetPageOrigin(int16 x, int16 y)
|
||||||
|
{
|
||||||
AppendDataXY(x, y);
|
AppendDataXY(x, y);
|
||||||
AppendAttribute(kPageOrigin);
|
AppendAttribute(kPageOrigin);
|
||||||
|
|
||||||
AppendOperator(kSetPageOrigin);
|
AppendOperator(kSetPageOrigin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::SetColorSpace(ColorSpace colorSpace) {
|
PCL6Writer::SetColorSpace(ColorSpace colorSpace)
|
||||||
|
{
|
||||||
AppendData((uint8)colorSpace);
|
AppendData((uint8)colorSpace);
|
||||||
AppendAttribute(kColorSpace);
|
AppendAttribute(kColorSpace);
|
||||||
|
|
||||||
AppendOperator(kSetColorSpace);
|
AppendOperator(kSetColorSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::SetPaintTxMode(Transparency transparency) {
|
PCL6Writer::SetPaintTxMode(Transparency transparency)
|
||||||
|
{
|
||||||
AppendData((uint8)transparency);
|
AppendData((uint8)transparency);
|
||||||
AppendAttribute(kTxMode);
|
AppendAttribute(kTxMode);
|
||||||
|
|
||||||
AppendOperator(kSetPaintTxMode);
|
AppendOperator(kSetPaintTxMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::SetSourceTxMode(Transparency transparency) {
|
PCL6Writer::SetSourceTxMode(Transparency transparency)
|
||||||
|
{
|
||||||
AppendData((uint8)transparency);
|
AppendData((uint8)transparency);
|
||||||
AppendAttribute(kTxMode);
|
AppendAttribute(kTxMode);
|
||||||
|
|
||||||
AppendOperator(kSetSourceTxMode);
|
AppendOperator(kSetSourceTxMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::SetROP(uint8 rop) {
|
PCL6Writer::SetROP(uint8 rop)
|
||||||
|
{
|
||||||
AppendData((uint8)rop);
|
AppendData((uint8)rop);
|
||||||
AppendAttribute(kROP3);
|
AppendAttribute(kROP3);
|
||||||
|
|
||||||
AppendOperator(kSetROP);
|
AppendOperator(kSetROP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::SetCursor(int16 x, int16 y) {
|
PCL6Writer::SetCursor(int16 x, int16 y)
|
||||||
|
{
|
||||||
AppendDataXY(x, y);
|
AppendDataXY(x, y);
|
||||||
AppendAttribute(kPoint);
|
AppendAttribute(kPoint);
|
||||||
|
|
||||||
@@ -380,8 +461,11 @@ PCL6Writer::SetCursor(int16 x, int16 y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::BeginImage(ColorMapping colorMapping, ColorDepth colorDepth, uint16 sourceWidth, uint16 sourceHeight, uint16 destWidth, uint16 destHeight) {
|
PCL6Writer::BeginImage(ColorMapping colorMapping, ColorDepth colorDepth,
|
||||||
|
uint16 sourceWidth, uint16 sourceHeight, uint16 destWidth,
|
||||||
|
uint16 destHeight)
|
||||||
|
{
|
||||||
AppendData((uint8)colorMapping);
|
AppendData((uint8)colorMapping);
|
||||||
AppendAttribute(kColorMapping);
|
AppendAttribute(kColorMapping);
|
||||||
|
|
||||||
@@ -400,8 +484,11 @@ PCL6Writer::BeginImage(ColorMapping colorMapping, ColorDepth colorDepth, uint16
|
|||||||
AppendOperator(kBeginImage);
|
AppendOperator(kBeginImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::ReadImage(Compression compression, uint16 startLine, uint16 blockHeight, uint8 padBytes) {
|
PCL6Writer::ReadImage(Compression compression, uint16 startLine,
|
||||||
|
uint16 blockHeight, uint8 padBytes)
|
||||||
|
{
|
||||||
AppendData(startLine);
|
AppendData(startLine);
|
||||||
AppendAttribute(kStartLine);
|
AppendAttribute(kStartLine);
|
||||||
|
|
||||||
@@ -423,9 +510,9 @@ PCL6Writer::ReadImage(Compression compression, uint16 startLine, uint16 blockHei
|
|||||||
AppendOperator(kReadImage);
|
AppendOperator(kReadImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PCL6Writer::EndImage() {
|
PCL6Writer::EndImage()
|
||||||
|
{
|
||||||
AppendOperator(kEndImage);
|
AppendOperator(kEndImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,362 +1,376 @@
|
|||||||
/*
|
/*
|
||||||
** PCL6Writer.h
|
** PCL6Writer.h
|
||||||
** Copyright 2005, Michael Pfeiffer, [email protected]. All rights reserved.
|
** Copyright 2005, Michael Pfeiffer, [email protected].
|
||||||
|
** All rights reserved.
|
||||||
** Distributed under the terms of the OpenBeOS License.
|
** Distributed under the terms of the OpenBeOS License.
|
||||||
*/
|
*/
|
||||||
#ifndef _PCL6_WRITER_H
|
#ifndef _PCL6_WRITER_H
|
||||||
#define _PCL6_WRITER_H
|
#define _PCL6_WRITER_H
|
||||||
|
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
class PCL6Driver;
|
class PCL6Driver;
|
||||||
|
|
||||||
|
|
||||||
class PCL6WriterStream {
|
class PCL6WriterStream {
|
||||||
public:
|
public:
|
||||||
virtual ~PCL6WriterStream() {}
|
virtual ~PCL6WriterStream() {}
|
||||||
virtual void write(const uint8 *data, uint32 size) = 0;
|
virtual void write(const uint8* data, uint32 size) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class PCL6Writer {
|
class PCL6Writer {
|
||||||
public:
|
public:
|
||||||
// DO NOT change this enumerations the order is important!!!
|
// DO NOT change this enumerations the order is important!!!
|
||||||
enum Orientation {
|
enum Orientation {
|
||||||
kPortrait,
|
kPortrait,
|
||||||
kLandscape,
|
kLandscape,
|
||||||
kReversePortrait,
|
kReversePortrait,
|
||||||
kReverseLandscape
|
kReverseLandscape
|
||||||
};
|
};
|
||||||
|
|
||||||
enum MediaSize {
|
enum MediaSize {
|
||||||
kLetterPaper,
|
kLetterPaper,
|
||||||
kLegalPaper,
|
kLegalPaper,
|
||||||
kA4Paper,
|
kA4Paper,
|
||||||
kExecPaper,
|
kExecPaper,
|
||||||
kLedgerPaper,
|
kLedgerPaper,
|
||||||
kA3Paper,
|
kA3Paper,
|
||||||
kCOM10Envelope,
|
kCOM10Envelope,
|
||||||
kMonarchEnvelope,
|
kMonarchEnvelope,
|
||||||
kC5Envelope,
|
kC5Envelope,
|
||||||
kDLEnvelope,
|
kDLEnvelope,
|
||||||
kJB4Paper,
|
kJB4Paper,
|
||||||
kJB5Paper,
|
kJB5Paper,
|
||||||
kB5Envelope,
|
kB5Envelope,
|
||||||
kB5Paper,
|
kB5Paper,
|
||||||
kJPostcard,
|
kJPostcard,
|
||||||
kJDoublePostcard,
|
kJDoublePostcard,
|
||||||
kA5Paper,
|
kA5Paper,
|
||||||
kA6Paper,
|
kA6Paper,
|
||||||
kJB6Paper,
|
kJB6Paper,
|
||||||
kJIS8KPaper,
|
kJIS8KPaper,
|
||||||
kJIS16KPaper,
|
kJIS16KPaper,
|
||||||
kJISExecPaper
|
kJISExecPaper
|
||||||
};
|
};
|
||||||
|
|
||||||
enum MediaSource {
|
enum MediaSource {
|
||||||
kDefaultSource,
|
kDefaultSource,
|
||||||
kAutoSelect,
|
kAutoSelect,
|
||||||
kManualFeed,
|
kManualFeed,
|
||||||
kMultiPurposeTray,
|
kMultiPurposeTray,
|
||||||
kUpperCassette,
|
kUpperCassette,
|
||||||
kLowerCassette,
|
kLowerCassette,
|
||||||
kEnvelopeTray,
|
kEnvelopeTray,
|
||||||
kThirdCassette
|
kThirdCassette
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Compression {
|
enum Compression {
|
||||||
kNoCompression,
|
kNoCompression,
|
||||||
kRLECompression,
|
kRLECompression,
|
||||||
kJPEGCompression,
|
kJPEGCompression,
|
||||||
kDeltaRowCompression
|
kDeltaRowCompression
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ColorSpace {
|
enum ColorSpace {
|
||||||
kBiLevel,
|
kBiLevel,
|
||||||
kGray,
|
kGray,
|
||||||
kRGB,
|
kRGB,
|
||||||
kCMY,
|
kCMY,
|
||||||
kCIELab,
|
kCIELab,
|
||||||
kCRGB,
|
kCRGB,
|
||||||
kSRGB
|
kSRGB
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ColorDepth {
|
enum ColorDepth {
|
||||||
k1Bit,
|
k1Bit,
|
||||||
k4Bit,
|
k4Bit,
|
||||||
k8Bit
|
k8Bit
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ColorMapping {
|
enum ColorMapping {
|
||||||
kDirectPixel,
|
kDirectPixel,
|
||||||
kIndexedPixel,
|
kIndexedPixel,
|
||||||
kDirectPlane
|
kDirectPlane
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Transparency {
|
enum Transparency {
|
||||||
kOpaque,
|
kOpaque,
|
||||||
kTransparent
|
kTransparent
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DuplexPageMode {
|
enum DuplexPageMode {
|
||||||
kDuplexHorizontalBinding,
|
kDuplexHorizontalBinding,
|
||||||
kDuplexVerticalBinding
|
kDuplexVerticalBinding
|
||||||
};
|
};
|
||||||
|
|
||||||
enum MediaSide {
|
enum MediaSide {
|
||||||
kFrontMediaSide,
|
kFrontMediaSide,
|
||||||
kBackMediaSide
|
kBackMediaSide
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SimplexPageMode {
|
enum SimplexPageMode {
|
||||||
kSimplexFrontSide
|
kSimplexFrontSide
|
||||||
};
|
};
|
||||||
|
|
||||||
enum UnitOfMeasure {
|
enum UnitOfMeasure {
|
||||||
kInch,
|
kInch,
|
||||||
kMillimeter,
|
kMillimeter,
|
||||||
kTenthsOfAMillimeter
|
kTenthsOfAMillimeter
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ErrorReporting {
|
enum ErrorReporting {
|
||||||
kNoReporting,
|
kNoReporting,
|
||||||
kBackChannel,
|
kBackChannel,
|
||||||
kErrorPage,
|
kErrorPage,
|
||||||
kBackChAndErrPage,
|
kBackChAndErrPage,
|
||||||
kNWBackChannel,
|
kNWBackChannel,
|
||||||
kNWErrorPage,
|
kNWErrorPage,
|
||||||
kNWBackChAndErrPage
|
kNWBackChAndErrPage
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Enable {
|
enum Enable {
|
||||||
kOn,
|
kOn,
|
||||||
kOff
|
kOff
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Boolean {
|
enum Boolean {
|
||||||
kFalse,
|
kFalse,
|
||||||
kTrue
|
kTrue
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ProtocolClass {
|
enum ProtocolClass {
|
||||||
kProtocolClass1_1,
|
kProtocolClass1_1,
|
||||||
kProtocolClass2_0,
|
kProtocolClass2_0,
|
||||||
kProtocolClass2_1,
|
kProtocolClass2_1,
|
||||||
kProtocolClass3_0,
|
kProtocolClass3_0,
|
||||||
};
|
};
|
||||||
|
|
||||||
PCL6Writer(PCL6WriterStream* stream, uint32 bufferSize = 16 * 1024);
|
PCL6Writer(PCL6WriterStream* stream,
|
||||||
virtual ~PCL6Writer();
|
uint32 bufferSize = 16 * 1024);
|
||||||
|
virtual ~PCL6Writer();
|
||||||
|
|
||||||
// these methods throw TransportException if data could not
|
// these methods throw TransportException if data could not
|
||||||
// be written
|
// be written
|
||||||
void Flush();
|
void Flush();
|
||||||
|
|
||||||
void PJLHeader(ProtocolClass protocolClass, int dpi, const char *comment = NULL);
|
void PJLHeader(ProtocolClass protocolClass, int dpi,
|
||||||
void PJLFooter();
|
const char* comment = NULL);
|
||||||
|
void PJLFooter();
|
||||||
|
|
||||||
void BeginSession(uint16 xres, uint16 yres, UnitOfMeasure unitOfMeasure, ErrorReporting errorReporting);
|
void BeginSession(uint16 xres, uint16 yres,
|
||||||
void EndSession();
|
UnitOfMeasure unitOfMeasure,
|
||||||
|
ErrorReporting errorReporting);
|
||||||
|
void EndSession();
|
||||||
|
|
||||||
void OpenDataSource();
|
void OpenDataSource();
|
||||||
void CloseDataSource();
|
void CloseDataSource();
|
||||||
|
|
||||||
void BeginPage(Orientation orientation, MediaSize mediaSize, MediaSource mediaSource);
|
void BeginPage(Orientation orientation, MediaSize mediaSize,
|
||||||
void BeginPage(Orientation orientation, MediaSize mediaSize, MediaSource mediaSource, DuplexPageMode duplexPageMode, MediaSide mediaSide);
|
MediaSource mediaSource);
|
||||||
void EndPage(uint16 copies);
|
void BeginPage(Orientation orientation, MediaSize mediaSize,
|
||||||
|
MediaSource mediaSource, DuplexPageMode duplexPageMode,
|
||||||
|
MediaSide mediaSide);
|
||||||
|
void EndPage(uint16 copies);
|
||||||
|
|
||||||
void SetPageOrigin(int16 x, int16 y);
|
void SetPageOrigin(int16 x, int16 y);
|
||||||
void SetColorSpace(ColorSpace colorSpace);
|
void SetColorSpace(ColorSpace colorSpace);
|
||||||
void SetPaintTxMode(Transparency transparency);
|
void SetPaintTxMode(Transparency transparency);
|
||||||
void SetSourceTxMode(Transparency transparency);
|
void SetSourceTxMode(Transparency transparency);
|
||||||
void SetROP(uint8 rop);
|
void SetROP(uint8 rop);
|
||||||
void SetCursor(int16 x, int16 y);
|
void SetCursor(int16 x, int16 y);
|
||||||
|
|
||||||
void BeginImage(ColorMapping colorMapping, ColorDepth colorDepth, uint16 sourceWidth, uint16 sourceHeight, uint16 destWidth, uint16 destHeight);
|
void BeginImage(ColorMapping colorMapping, ColorDepth colorDepth,
|
||||||
void ReadImage(Compression compression, uint16 startLine, uint16 blockHeight, uint8 padBytes = 4);
|
uint16 sourceWidth, uint16 sourceHeight,
|
||||||
void EndImage();
|
uint16 destWidth, uint16 destHeight);
|
||||||
void EmbeddedDataPrefix(uint32 size);
|
void ReadImage(Compression compression, uint16 startLine,
|
||||||
void EmbeddedDataPrefix32(uint32 size);
|
uint16 blockHeight, uint8 padBytes = 4);
|
||||||
|
void EndImage();
|
||||||
|
void EmbeddedDataPrefix(uint32 size);
|
||||||
|
void EmbeddedDataPrefix32(uint32 size);
|
||||||
|
|
||||||
void Append(uint8 value);
|
void Append(uint8 value);
|
||||||
void Append(int16 value);
|
void Append(int16 value);
|
||||||
void Append(uint16 value);
|
void Append(uint16 value);
|
||||||
void Append(int32 value);
|
void Append(int32 value);
|
||||||
void Append(uint32 value);
|
void Append(uint32 value);
|
||||||
void Append(float value);
|
void Append(float value);
|
||||||
void Append(const uint8* data, uint32 size);
|
void Append(const uint8* data, uint32 size);
|
||||||
|
|
||||||
void AppendData(uint8 value);
|
void AppendData(uint8 value);
|
||||||
void AppendData(int16 value);
|
void AppendData(int16 value);
|
||||||
void AppendData(uint16 value);
|
void AppendData(uint16 value);
|
||||||
void AppendData(int32 value);
|
void AppendData(int32 value);
|
||||||
void AppendData(uint32 value);
|
void AppendData(uint32 value);
|
||||||
void AppendData(float value);
|
void AppendData(float value);
|
||||||
|
|
||||||
void AppendDataXY(uint8 x, uint8 y);
|
void AppendDataXY(uint8 x, uint8 y);
|
||||||
void AppendDataXY(int16 x, int16 y);
|
void AppendDataXY(int16 x, int16 y);
|
||||||
void AppendDataXY(uint16 x, uint16 y);
|
void AppendDataXY(uint16 x, uint16 y);
|
||||||
void AppendDataXY(int32 x, int32 y);
|
void AppendDataXY(int32 x, int32 y);
|
||||||
void AppendDataXY(uint32 x, uint32 y);
|
void AppendDataXY(uint32 x, uint32 y);
|
||||||
void AppendDataXY(float x, float y);
|
void AppendDataXY(float x, float y);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum Operator {
|
enum Operator {
|
||||||
kBeginSession = 0x41,
|
kBeginSession = 0x41,
|
||||||
kEndSession,
|
kEndSession,
|
||||||
kBeginPage,
|
kBeginPage,
|
||||||
kEndPage,
|
kEndPage,
|
||||||
|
|
||||||
kVendorUnique = 0x46,
|
|
||||||
kComment,
|
|
||||||
kOpenDataSource,
|
|
||||||
kCloseDataSource,
|
|
||||||
kEchoComment,
|
|
||||||
kQuery,
|
|
||||||
kDiagnostic3,
|
|
||||||
|
|
||||||
kBeginStream = 0x5b,
|
|
||||||
kReadStream,
|
|
||||||
kEndStream,
|
|
||||||
|
|
||||||
kSetColorSpace = 0x6a,
|
|
||||||
kSetCursor,
|
|
||||||
|
|
||||||
kSetPageOrigin = 0x75,
|
|
||||||
kSetPageRotation,
|
|
||||||
kSetPageScale,
|
|
||||||
kSetPaintTxMode,
|
|
||||||
kSetPenSource,
|
|
||||||
kSetPenWidth,
|
|
||||||
kSetROP,
|
|
||||||
kSetSourceTxMode,
|
|
||||||
|
|
||||||
kBeginImage = 0xb0,
|
kVendorUnique = 0x46,
|
||||||
kReadImage,
|
kComment,
|
||||||
kEndImage,
|
kOpenDataSource,
|
||||||
};
|
kCloseDataSource,
|
||||||
|
kEchoComment,
|
||||||
|
kQuery,
|
||||||
|
kDiagnostic3,
|
||||||
|
|
||||||
|
kBeginStream = 0x5b,
|
||||||
|
kReadStream,
|
||||||
|
kEndStream,
|
||||||
|
|
||||||
|
kSetColorSpace = 0x6a,
|
||||||
|
kSetCursor,
|
||||||
|
|
||||||
|
kSetPageOrigin = 0x75,
|
||||||
|
kSetPageRotation,
|
||||||
|
kSetPageScale,
|
||||||
|
kSetPaintTxMode,
|
||||||
|
kSetPenSource,
|
||||||
|
kSetPenWidth,
|
||||||
|
kSetROP,
|
||||||
|
kSetSourceTxMode,
|
||||||
|
|
||||||
|
kBeginImage = 0xb0,
|
||||||
|
kReadImage,
|
||||||
|
kEndImage,
|
||||||
|
};
|
||||||
|
|
||||||
enum DataTag {
|
enum DataTag {
|
||||||
kUByteData = 0xc0,
|
kUByteData = 0xc0,
|
||||||
kUInt16Data,
|
kUInt16Data,
|
||||||
kUInt32Data,
|
kUInt32Data,
|
||||||
kSInt16Data,
|
kSInt16Data,
|
||||||
kSInt32Data,
|
kSInt32Data,
|
||||||
kReal32Data,
|
kReal32Data,
|
||||||
|
|
||||||
kString = 0xc7,
|
kString = 0xc7,
|
||||||
kUByteArray,
|
kUByteArray,
|
||||||
kUInt16Array,
|
kUInt16Array,
|
||||||
kUInt32Array,
|
kUInt32Array,
|
||||||
kSInt16Array,
|
kSInt16Array,
|
||||||
kSInt32Array,
|
kSInt32Array,
|
||||||
kReal32Array,
|
kReal32Array,
|
||||||
|
|
||||||
kUByteXY = 0xd0,
|
kUByteXY = 0xd0,
|
||||||
kUInt16XY,
|
kUInt16XY,
|
||||||
kUInt32XY,
|
kUInt32XY,
|
||||||
kSInt16XY,
|
kSInt16XY,
|
||||||
kSInt32XY,
|
kSInt32XY,
|
||||||
kReal32XY,
|
kReal32XY,
|
||||||
|
|
||||||
kUByteBox = 0xe0,
|
kUByteBox = 0xe0,
|
||||||
kUInt16Box,
|
kUInt16Box,
|
||||||
kUInt32Box,
|
kUInt32Box,
|
||||||
kSInt16Box,
|
kSInt16Box,
|
||||||
kSInt32Box,
|
kSInt32Box,
|
||||||
kReal32Box,
|
kReal32Box,
|
||||||
|
|
||||||
k8BitAttrId = 0xf8,
|
k8BitAttrId = 0xf8,
|
||||||
|
|
||||||
kEmbeddedData = 0xfa,
|
kEmbeddedData = 0xfa,
|
||||||
kEmbeddedDataByte,
|
kEmbeddedDataByte,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DataType {
|
enum DataType {
|
||||||
kUByte,
|
kUByte,
|
||||||
kSByte,
|
kSByte,
|
||||||
kUInt16,
|
kUInt16,
|
||||||
kSInt16,
|
kSInt16,
|
||||||
kReal32
|
kReal32
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Attribute {
|
enum Attribute {
|
||||||
kCMYColor = 1,
|
kCMYColor = 1,
|
||||||
kPaletteDepth,
|
kPaletteDepth,
|
||||||
kColorSpace,
|
kColorSpace,
|
||||||
|
|
||||||
kRGBColor = 11,
|
kRGBColor = 11,
|
||||||
|
|
||||||
kMediaDest = 36,
|
kMediaDest = 36,
|
||||||
kMediaSize,
|
kMediaSize,
|
||||||
kMediaSource,
|
kMediaSource,
|
||||||
kMediaType,
|
kMediaType,
|
||||||
kOrientation,
|
kOrientation,
|
||||||
kPageAngle,
|
kPageAngle,
|
||||||
kPageOrigin,
|
kPageOrigin,
|
||||||
kPageScale,
|
kPageScale,
|
||||||
kROP3,
|
kROP3,
|
||||||
kTxMode,
|
kTxMode,
|
||||||
|
|
||||||
kCustomMediaSize = 47,
|
kCustomMediaSize = 47,
|
||||||
kCustomMediaSizeUnits,
|
kCustomMediaSizeUnits,
|
||||||
kPageCopies,
|
kPageCopies,
|
||||||
kDitherMatrixSize,
|
kDitherMatrixSize,
|
||||||
kDitherMatrixDepth,
|
kDitherMatrixDepth,
|
||||||
kSimplexPageMode,
|
kSimplexPageMode,
|
||||||
kDuplexPageMode,
|
kDuplexPageMode,
|
||||||
kDuplexPageSide,
|
kDuplexPageSide,
|
||||||
|
|
||||||
kPoint = 76,
|
kPoint = 76,
|
||||||
|
|
||||||
kColorDepth = 98,
|
kColorDepth = 98,
|
||||||
kBlockHeight,
|
kBlockHeight,
|
||||||
kColorMapping,
|
kColorMapping,
|
||||||
kCompressMode,
|
kCompressMode,
|
||||||
kDestinationBox,
|
kDestinationBox,
|
||||||
kDestinationSize,
|
kDestinationSize,
|
||||||
|
|
||||||
kSourceHeight = 107,
|
kSourceHeight = 107,
|
||||||
kSourceWidth,
|
kSourceWidth,
|
||||||
kStartLine,
|
kStartLine,
|
||||||
kPadBytesMultiple,
|
kPadBytesMultiple,
|
||||||
kBlockByteLength,
|
kBlockByteLength,
|
||||||
|
|
||||||
kNumberOfScanLines = 115,
|
kNumberOfScanLines = 115,
|
||||||
|
|
||||||
kDataOrg = 130,
|
kDataOrg = 130,
|
||||||
kMeasure = 134,
|
kMeasure = 134,
|
||||||
|
|
||||||
kSourceType = 136,
|
kSourceType = 136,
|
||||||
kUnitsPerMeasure,
|
kUnitsPerMeasure,
|
||||||
kQueryKey,
|
kQueryKey,
|
||||||
kStreamName,
|
kStreamName,
|
||||||
kStreamDataLength,
|
kStreamDataLength,
|
||||||
|
|
||||||
kErrorReport = 143,
|
kErrorReport = 143,
|
||||||
kIOReadTimeOut,
|
kIOReadTimeOut,
|
||||||
|
|
||||||
kWritingMode = 173
|
kWritingMode = 173
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DataSource {
|
enum DataSource {
|
||||||
kDefaultDataSource
|
kDefaultDataSource
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DataOrganization {
|
enum DataOrganization {
|
||||||
kBinaryHighByteFirst,
|
kBinaryHighByteFirst,
|
||||||
kBinaryLowByteFirst
|
kBinaryLowByteFirst
|
||||||
};
|
};
|
||||||
|
|
||||||
void AppendString(const char* string);
|
void AppendString(const char* string);
|
||||||
void AppendOperator(Operator op);
|
void AppendOperator(Operator op);
|
||||||
void AppendAttribute(Attribute attr);
|
void AppendAttribute(Attribute attr);
|
||||||
void AppendDataTag(DataTag tag);
|
void AppendDataTag(DataTag tag);
|
||||||
|
|
||||||
PCL6WriterStream *fStream; // the stream used for writing the generated PCL6 data
|
PCL6WriterStream* fStream;
|
||||||
uint8 *fBuffer; // the buffer
|
// the stream used for writing the generated PCL6 data
|
||||||
uint32 fSize; // the size of the buffer
|
uint8* fBuffer; // the buffer
|
||||||
uint32 fIndex; // the index of the next byte to be written
|
uint32 fSize; // the size of the buffer
|
||||||
|
uint32 fIndex; // the index of the next byte to be written
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // _PCL6_WRITER_H
|
||||||
|
|
||||||
|
|||||||
@@ -2,28 +2,32 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
Rasterizer::Rasterizer(Halftone* halftone)
|
Rasterizer::Rasterizer(Halftone* halftone)
|
||||||
: fHalftone(halftone)
|
:
|
||||||
, fIndex(-1)
|
fHalftone(halftone),
|
||||||
|
fIndex(-1)
|
||||||
{
|
{
|
||||||
fBounds.bottom = -2;
|
fBounds.bottom = -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Rasterizer::~Rasterizer()
|
Rasterizer::~Rasterizer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Rasterizer::SetBitmap(int x, int y, BBitmap *bitmap, int pageHeight)
|
Rasterizer::SetBitmap(int x, int y, BBitmap* bitmap, int pageHeight)
|
||||||
{
|
{
|
||||||
fX = x;
|
fX = x;
|
||||||
fY = y;
|
fY = y;
|
||||||
|
|
||||||
BRect bounds = bitmap->Bounds();
|
BRect bounds = bitmap->Bounds();
|
||||||
|
|
||||||
fBounds.left = (int)bounds.left;
|
fBounds.left = (int)bounds.left;
|
||||||
fBounds.top = (int)bounds.top;
|
fBounds.top = (int)bounds.top;
|
||||||
fBounds.right = (int)bounds.right;
|
fBounds.right = (int)bounds.right;
|
||||||
fBounds.bottom = (int)bounds.bottom;
|
fBounds.bottom = (int)bounds.bottom;
|
||||||
|
|
||||||
int height = fBounds.bottom - fBounds.top + 1;
|
int height = fBounds.bottom - fBounds.top + 1;
|
||||||
@@ -33,9 +37,8 @@ Rasterizer::SetBitmap(int x, int y, BBitmap *bitmap, int pageHeight)
|
|||||||
fBounds.bottom = fBounds.top + height - 1;
|
fBounds.bottom = fBounds.top + height - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!get_valid_rect(bitmap, &fBounds)) {
|
if (!get_valid_rect(bitmap, &fBounds))
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
fWidth = fBounds.right - fBounds.left + 1;
|
fWidth = fBounds.right - fBounds.left + 1;
|
||||||
fHeight = fBounds.bottom - fBounds.top + 1;
|
fHeight = fBounds.bottom - fBounds.top + 1;
|
||||||
@@ -52,20 +55,21 @@ Rasterizer::SetBitmap(int x, int y, BBitmap *bitmap, int pageHeight)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Rasterizer::HasNextLine()
|
Rasterizer::HasNextLine()
|
||||||
{
|
{
|
||||||
return fIndex <= fBounds.bottom;
|
return fIndex <= fBounds.bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const void*
|
const void*
|
||||||
Rasterizer::RasterizeNextLine()
|
Rasterizer::RasterizeNextLine()
|
||||||
{
|
{
|
||||||
if (!HasNextLine()) {
|
if (!HasNextLine())
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
const void *result;
|
const void* result;
|
||||||
result = RasterizeLine(fX, fY, (const ColorRGB32Little*)fBits);
|
result = RasterizeLine(fX, fY, (const ColorRGB32Little*)fBits);
|
||||||
fBits += fBPR;
|
fBits += fBPR;
|
||||||
fY ++;
|
fY ++;
|
||||||
@@ -73,10 +77,10 @@ Rasterizer::RasterizeNextLine()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Rasterizer::RasterizeBitmap()
|
Rasterizer::RasterizeBitmap()
|
||||||
{
|
{
|
||||||
while (HasNextLine()) {
|
while (HasNextLine())
|
||||||
RasterizeNextLine();
|
RasterizeNextLine();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,74 +1,100 @@
|
|||||||
#ifndef _RASTERIZER_H
|
#ifndef _RASTERIZER_H
|
||||||
#define _RASTERIZER_H
|
#define _RASTERIZER_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <Bitmap.h>
|
||||||
|
|
||||||
#include "Halftone.h"
|
#include "Halftone.h"
|
||||||
#include "ValidRect.h"
|
#include "ValidRect.h"
|
||||||
|
|
||||||
#include <Bitmap.h>
|
|
||||||
|
|
||||||
//
|
|
||||||
class Rasterizer {
|
class Rasterizer {
|
||||||
public:
|
public:
|
||||||
Rasterizer(Halftone *halftone);
|
Rasterizer(Halftone* halftone);
|
||||||
virtual ~Rasterizer();
|
virtual ~Rasterizer();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the bitmap to be rasterized
|
* Sets the bitmap to be rasterized
|
||||||
* Either the iterator methods HasNextLine() and RasterizeNextLine()
|
* Either the iterator methods HasNextLine() and RasterizeNextLine()
|
||||||
* can be used to rasterize the bitmap line per line or the method RasterizeBitamp()
|
* can be used to rasterize the bitmap line per line or the method
|
||||||
|
* RasterizeBitamp()
|
||||||
* can be used to rasterize the entire bitmap at once.
|
* can be used to rasterize the entire bitmap at once.
|
||||||
* @param x the x position of the image on the page.
|
* @param x the x position of the image on the page.
|
||||||
* @param y the y position of the image on the page.
|
* @param y the y position of the image on the page.
|
||||||
* @param bitmap the bitamp to be rasterized.
|
* @param bitmap the bitamp to be rasterized.
|
||||||
* @param height the page height.
|
* @param height the page height.
|
||||||
* @return true if the bitmap is not empty and false if the bitmap is empty.
|
* @return true if the bitmap is not empty and false if the bitmap is
|
||||||
|
* empty.
|
||||||
*/
|
*/
|
||||||
bool SetBitmap(int x, int y, BBitmap *bitmap, int pageHeight);
|
bool SetBitmap(int x, int y, BBitmap* bitmap,
|
||||||
|
int pageHeight);
|
||||||
|
|
||||||
// Is there a next line?
|
// Is there a next line?
|
||||||
bool HasNextLine();
|
bool HasNextLine();
|
||||||
// Rasterizes the next line and returns the line.
|
// Rasterizes the next line and returns the line.
|
||||||
const void *RasterizeNextLine();
|
const void* RasterizeNextLine();
|
||||||
|
|
||||||
// Iterates over all lines.
|
// Iterates over all lines.
|
||||||
void RasterizeBitmap();
|
void RasterizeBitmap();
|
||||||
|
|
||||||
// Returns the Halftone object specified in the constructor
|
// Returns the Halftone object specified in the constructor
|
||||||
Halftone *GetHalftone() { return fHalftone; }
|
Halftone* GetHalftone()
|
||||||
|
{
|
||||||
|
return fHalftone;
|
||||||
|
}
|
||||||
// The bounds of the bitmap to be rasterized
|
// The bounds of the bitmap to be rasterized
|
||||||
RECT GetBounds() { return fBounds; }
|
RECT GetBounds()
|
||||||
|
{
|
||||||
|
return fBounds;
|
||||||
|
}
|
||||||
// The width (in pixels) of the bounds passed to Rasterized()
|
// The width (in pixels) of the bounds passed to Rasterized()
|
||||||
int GetWidth() { return fWidth; }
|
int GetWidth()
|
||||||
|
{
|
||||||
|
return fWidth;
|
||||||
|
}
|
||||||
// The height (in pixels) of the bounds passed to Rasterize()
|
// The height (in pixels) of the bounds passed to Rasterize()
|
||||||
int GetHeight() { return fHeight; }
|
int GetHeight()
|
||||||
|
{
|
||||||
|
return fHeight;
|
||||||
|
}
|
||||||
// Returns the current x position
|
// Returns the current x position
|
||||||
int GetX() { return fX; }
|
int GetX()
|
||||||
|
{
|
||||||
|
return fX;
|
||||||
|
}
|
||||||
// Returns the current y position
|
// Returns the current y position
|
||||||
int GetY() { return fY; }
|
int GetY()
|
||||||
|
{
|
||||||
|
return fY;
|
||||||
|
}
|
||||||
|
|
||||||
// The method is called for each line in the bitmap.
|
// The method is called for each line in the bitmap.
|
||||||
virtual const void *RasterizeLine(int x, int y, const ColorRGB32Little* source) = 0;
|
virtual const void* RasterizeLine(int x, int y,
|
||||||
|
const ColorRGB32Little* source) = 0;
|
||||||
|
|
||||||
// Returns the number of bytes to store widthInPixels pixels with BPP = bitsPerPixel
|
// Returns the number of bytes to store widthInPixels pixels with
|
||||||
// and padBytes number of pad bytes.
|
// BPP = bitsPerPixel and padBytes number of pad bytes.
|
||||||
static int RowBufferSize(int widthInPixels, int bitsPerPixel, int padBytes = 1) {
|
static int RowBufferSize(int widthInPixels, int bitsPerPixel,
|
||||||
int sizeInBytes = (widthInPixels * bitsPerPixel + 7) / 8;
|
int padBytes = 1)
|
||||||
return padBytes * ((sizeInBytes + padBytes - 1) / padBytes);
|
{
|
||||||
}
|
int sizeInBytes = (widthInPixels * bitsPerPixel + 7)
|
||||||
|
/ 8;
|
||||||
|
return padBytes * ((sizeInBytes + padBytes - 1)
|
||||||
|
/ padBytes);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Halftone *fHalftone;
|
Halftone* fHalftone;
|
||||||
|
|
||||||
RECT fBounds;
|
RECT fBounds;
|
||||||
int fWidth;
|
int fWidth;
|
||||||
int fHeight;
|
int fHeight;
|
||||||
int fX;
|
int fX;
|
||||||
int fY;
|
int fY;
|
||||||
|
|
||||||
const uchar *fBits;
|
const uchar* fBits;
|
||||||
int fBPR;
|
int fBPR;
|
||||||
int fIndex;
|
int fIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // _RASTERIZER_H
|
||||||
#endif
|
|
||||||
|
|||||||
Reference in New Issue
Block a user