Implemented basic color printing support.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6408 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -142,26 +142,58 @@ bool PCL5Driver::nextBand(BBitmap *bitmap, BPoint *offset)
|
|||||||
DBGMSG(("move\n"));
|
DBGMSG(("move\n"));
|
||||||
|
|
||||||
move(x, y);
|
move(x, y);
|
||||||
startRasterGraphics();
|
startRasterGraphics(width, height);
|
||||||
|
|
||||||
|
const bool color = getJobData()->getColor() == JobData::kCOLOR;
|
||||||
|
const int num_planes = color ? 3 : 1;
|
||||||
|
const int fill_bits = in_size * 8 - width;
|
||||||
|
const uchar fill_mask = 0xff >> (8 - fill_bits);
|
||||||
|
// ASSERT(0 <= fill_bits && fill_bits < 8);
|
||||||
|
|
||||||
for (int i = rc.top; i <= rc.bottom; i++) {
|
for (int i = rc.top; i <= rc.bottom; i++) {
|
||||||
__halftone->dither(in_buffer, ptr, x, y, width);
|
|
||||||
|
for (int plane = 0; plane < num_planes; plane ++) {
|
||||||
compressed_size = pack_bits(out_buffer, in_buffer, in_size);
|
|
||||||
|
if (color) {
|
||||||
|
switch (plane) {
|
||||||
|
// XXX maybe order should be red, green, blue. This could be
|
||||||
|
// a bug in __halftone dither where it passes rgb_color to
|
||||||
|
// a gray function in wrong order!
|
||||||
|
case 0: __halftone->setGrayFunction(Halftone::kBlueChannel);
|
||||||
|
break;
|
||||||
|
case 1: __halftone->setGrayFunction(Halftone::kGreenChannel);
|
||||||
|
break;
|
||||||
|
case 2: __halftone->setGrayFunction(Halftone::kRedChannel);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
__halftone->dither(in_buffer, ptr, x, y, width);
|
||||||
|
|
||||||
|
if (color) {
|
||||||
|
// in color mode a value of 1 in all three planes means white
|
||||||
|
// fill the remaining bits to the bytes boundary with 1s
|
||||||
|
in_buffer[in_size - 1] |= fill_mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
compressed_size = pack_bits(out_buffer, in_buffer, in_size);
|
||||||
|
|
||||||
|
if (compressed_size + bytesToEnterCompressionMethod(2) < in_size + bytesToEnterCompressionMethod(0)) {
|
||||||
|
compression_method = 2; // back bits
|
||||||
|
buffer = out_buffer;
|
||||||
|
} else {
|
||||||
|
compression_method = 0; // uncompressed
|
||||||
|
buffer = in_buffer;
|
||||||
|
compressed_size = in_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
rasterGraphics(
|
||||||
|
compression_method,
|
||||||
|
buffer,
|
||||||
|
compressed_size,
|
||||||
|
plane == num_planes - 1);
|
||||||
|
|
||||||
if (compressed_size < in_size) {
|
|
||||||
compression_method = 2; // back bits
|
|
||||||
buffer = out_buffer;
|
|
||||||
} else {
|
|
||||||
compression_method = 0; // uncompressed
|
|
||||||
buffer = in_buffer;
|
|
||||||
compressed_size = in_size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rasterGraphics(
|
|
||||||
compression_method,
|
|
||||||
buffer,
|
|
||||||
compressed_size);
|
|
||||||
|
|
||||||
ptr += delta;
|
ptr += delta;
|
||||||
y++;
|
y++;
|
||||||
@@ -192,6 +224,7 @@ bool PCL5Driver::nextBand(BBitmap *bitmap, BPoint *offset)
|
|||||||
|
|
||||||
void PCL5Driver::jobStart()
|
void PCL5Driver::jobStart()
|
||||||
{
|
{
|
||||||
|
const bool color = getJobData()->getColor() == JobData::kCOLOR;
|
||||||
// enter PCL5
|
// enter PCL5
|
||||||
writeSpoolString("\033%%-12345X@PJL ENTER LANGUAGE=PCL\n");
|
writeSpoolString("\033%%-12345X@PJL ENTER LANGUAGE=PCL\n");
|
||||||
// reset
|
// reset
|
||||||
@@ -204,6 +237,10 @@ void PCL5Driver::jobStart()
|
|||||||
writeSpoolString("\033&l0A");
|
writeSpoolString("\033&l0A");
|
||||||
// page orientation
|
// page orientation
|
||||||
writeSpoolString("\033&l0O");
|
writeSpoolString("\033&l0O");
|
||||||
|
if (color) {
|
||||||
|
// 3 color planes (red, green, blue)
|
||||||
|
writeSpoolString("\033*r3U");
|
||||||
|
}
|
||||||
// raster presentation
|
// raster presentation
|
||||||
writeSpoolString("\033*r0F");
|
writeSpoolString("\033*r0F");
|
||||||
// top maring and perforation skip
|
// top maring and perforation skip
|
||||||
@@ -214,8 +251,13 @@ void PCL5Driver::jobStart()
|
|||||||
// writeSpoolString("\033&l%ldL", getJobData()->getCopies());
|
// writeSpoolString("\033&l%ldL", getJobData()->getCopies());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCL5Driver::startRasterGraphics()
|
void PCL5Driver::startRasterGraphics(int width, int height)
|
||||||
{
|
{
|
||||||
|
// width
|
||||||
|
writeSpoolString("\033*r%dS", width);
|
||||||
|
// height
|
||||||
|
writeSpoolString("\033*r%dT", height);
|
||||||
|
// start raster graphics
|
||||||
writeSpoolString("\033*r1A");
|
writeSpoolString("\033*r1A");
|
||||||
__compression_method = -1;
|
__compression_method = -1;
|
||||||
}
|
}
|
||||||
@@ -228,13 +270,19 @@ void PCL5Driver::endRasterGraphics()
|
|||||||
void PCL5Driver::rasterGraphics(
|
void PCL5Driver::rasterGraphics(
|
||||||
int compression_method,
|
int compression_method,
|
||||||
const uchar *buffer,
|
const uchar *buffer,
|
||||||
int size)
|
int size,
|
||||||
|
bool lastPlane)
|
||||||
{
|
{
|
||||||
if (__compression_method != compression_method) {
|
if (__compression_method != compression_method) {
|
||||||
writeSpoolString("\033*b%dM", compression_method);
|
writeSpoolString("\033*b%dM", compression_method);
|
||||||
__compression_method = compression_method;
|
__compression_method = compression_method;
|
||||||
}
|
}
|
||||||
writeSpoolString("\033*b%dW", size);
|
writeSpoolString("\033*b%d", size);
|
||||||
|
if (lastPlane) {
|
||||||
|
writeSpoolString("W");
|
||||||
|
} else {
|
||||||
|
writeSpoolString("V");
|
||||||
|
}
|
||||||
writeSpoolData(buffer, size);
|
writeSpoolData(buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,3 +296,13 @@ void PCL5Driver::move(int x, int y)
|
|||||||
{
|
{
|
||||||
writeSpoolString("\033*p%dx%dY", x, y+75);
|
writeSpoolString("\033*p%dx%dY", x, y+75);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PCL5Driver::bytesToEnterCompressionMethod(int compression_method)
|
||||||
|
{
|
||||||
|
if (__compression_method == compression_method) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,13 +24,15 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void move(int x, int y);
|
void move(int x, int y);
|
||||||
void jobStart();
|
void jobStart();
|
||||||
void startRasterGraphics();
|
void startRasterGraphics(int width, int height);
|
||||||
void endRasterGraphics();
|
void endRasterGraphics();
|
||||||
void rasterGraphics(
|
void rasterGraphics(
|
||||||
int compression_method,
|
int compression_method,
|
||||||
const uchar *buffer,
|
const uchar *buffer,
|
||||||
int size);
|
int size,
|
||||||
|
bool lastPlane);
|
||||||
void jobEnd();
|
void jobEnd();
|
||||||
|
int bytesToEnterCompressionMethod(int compression_method);
|
||||||
|
|
||||||
int __compression_method;
|
int __compression_method;
|
||||||
Halftone *__halftone;
|
Halftone *__halftone;
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ const ColorCap color("Color", false, JobData::kCOLOR);
|
|||||||
const ColorCap monochrome("Monochrome", true, JobData::kMONOCHROME);
|
const ColorCap monochrome("Monochrome", true, JobData::kMONOCHROME);
|
||||||
|
|
||||||
const ColorCap *colors[] = {
|
const ColorCap *colors[] = {
|
||||||
// &color,
|
&color,
|
||||||
&monochrome
|
&monochrome
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user