Implemented RLE compression
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11441 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -9,14 +9,15 @@
|
|||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "PCL6.h"
|
|
||||||
|
|
||||||
#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 "PrinterData.h"
|
#include "PrinterData.h"
|
||||||
#include "PCL6Rasterizer.h"
|
#include "PCL6Rasterizer.h"
|
||||||
#include "UIDriver.h"
|
#include "UIDriver.h"
|
||||||
@@ -28,23 +29,6 @@ using namespace std;
|
|||||||
#define std
|
#define std
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Compression method configuration
|
|
||||||
// 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!
|
|
||||||
|
|
||||||
// Run-Length-Encoding Compression
|
|
||||||
// DO NOT ENABLE HP_M2TIFF_Compress seems to be broken!!!
|
|
||||||
#define ENABLE_RLE_COMPRESSION 0
|
|
||||||
|
|
||||||
// Delta Row Compression
|
|
||||||
#define ENABLE_DELTA_ROW_COMPRESSION 1
|
|
||||||
|
|
||||||
// Color depth for color printing.
|
|
||||||
// Use either 1 or 8.
|
|
||||||
// If 1 bit depth is used, the class Halftone is used for dithering
|
|
||||||
// otherwise dithering is not performed.
|
|
||||||
#define COLOR_DEPTH 1
|
|
||||||
|
|
||||||
// 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
|
||||||
@@ -195,11 +179,10 @@ void PCL6Driver::writeBitmap(const uchar* buffer, int outSize, int rowSize, int
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLE_RLE_COMPRESSION
|
#if ENABLE_RLE_COMPRESSION
|
||||||
HP_UInt32 compressedSize = 0;
|
int rleSize = pack_bits_size(buffer, outSize);
|
||||||
HP_M2TIFF_CalcCompression((HP_pCharHuge)buffer, outSize, &compressedSize);
|
if (rleSize < dataSize) {
|
||||||
if (compressedSize < (uint32)dataSize) {
|
|
||||||
compressionMethod = PCL6Writer::kRLECompression;
|
compressionMethod = PCL6Writer::kRLECompression;
|
||||||
dataSize = compressedSize;
|
dataSize = rleSize;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -212,10 +195,10 @@ void PCL6Driver::writeBitmap(const uchar* buffer, int outSize, int rowSize, int
|
|||||||
|
|
||||||
endRasterGraphics();
|
endRasterGraphics();
|
||||||
|
|
||||||
#if 0
|
#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)compressedSize, 100.0 * compressedSize / 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);
|
||||||
@@ -310,8 +293,10 @@ void PCL6Driver::rasterGraphics(
|
|||||||
// write data
|
// write data
|
||||||
if (compressionMethod == PCL6Writer::kRLECompression) {
|
if (compressionMethod == PCL6Writer::kRLECompression) {
|
||||||
// use RLE compression
|
// use RLE compression
|
||||||
// uint32 compressedSize = 0;
|
uchar *outBuffer = new uchar[dataSize];
|
||||||
// HP_M2TIFF_Compress(fStream, 0, (HP_pCharHuge)buffer, bufferSize, &compressedSize);
|
pack_bits(outBuffer, buffer, bufferSize);
|
||||||
|
fWriter->Append(outBuffer, dataSize);
|
||||||
|
delete outBuffer;
|
||||||
return;
|
return;
|
||||||
} else if (compressionMethod == PCL6Writer::kDeltaRowCompression) {
|
} else if (compressionMethod == PCL6Writer::kDeltaRowCompression) {
|
||||||
// use delta row compression
|
// use delta row compression
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* PCL6Cap.cpp
|
* PCL6Cap.cpp
|
||||||
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
||||||
|
* COpyright 2003-2005 Michael Pfeiffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "PrinterData.h"
|
|
||||||
#include "PCL6Cap.h"
|
#include "PCL6Cap.h"
|
||||||
|
#include "PCL6Config.h"
|
||||||
|
#include "PrinterData.h"
|
||||||
|
|
||||||
#define TO72DPI(a) (a * 72.0f / 600.0f)
|
#define TO72DPI(a) (a * 72.0f / 600.0f)
|
||||||
|
|
||||||
@@ -150,8 +152,11 @@ const PrintStyleCap duplex("Duplex", false, JobData::kDuplex);
|
|||||||
|
|
||||||
const ProtocolClassCap pc1_1("PCL 6 Protocol Class 1.1", true, kProtocolClass1_1,
|
const ProtocolClassCap pc1_1("PCL 6 Protocol Class 1.1", true, kProtocolClass1_1,
|
||||||
"Protocol Class 1.1\n"
|
"Protocol Class 1.1\n"
|
||||||
"* No compression\n"
|
"* No compression"
|
||||||
"* RLE compression (not implemented yet)");
|
#if ENABLE_RLE_COMPRESSION
|
||||||
|
"\n* RLE compression"
|
||||||
|
#endif
|
||||||
|
);
|
||||||
const ProtocolClassCap pc2_0("PCL 6 Protocol Class 2.0", false, kProtocolClass2_0,
|
const ProtocolClassCap pc2_0("PCL 6 Protocol Class 2.0", false, kProtocolClass2_0,
|
||||||
"Protocol Class 2.0\n"
|
"Protocol Class 2.0\n"
|
||||||
"* Additonal Paper Source: Third Cassette\n"
|
"* Additonal Paper Source: Third Cassette\n"
|
||||||
@@ -159,7 +164,10 @@ const ProtocolClassCap pc2_0("PCL 6 Protocol Class 2.0", false, kProtocolClass2_
|
|||||||
const ProtocolClassCap pc2_1("PCL 6 Protocol Class 2.1", false, kProtocolClass2_1,
|
const ProtocolClassCap pc2_1("PCL 6 Protocol Class 2.1", false, kProtocolClass2_1,
|
||||||
"Protocol Class 2.1\n"
|
"Protocol Class 2.1\n"
|
||||||
"* Additional Paper Format: B5\n"
|
"* Additional Paper Format: B5\n"
|
||||||
"* Delta Row Compression");
|
#if ENABLE_DELTA_ROW_COMPRESSION
|
||||||
|
"* Delta Row Compression"
|
||||||
|
#endif
|
||||||
|
);
|
||||||
const ProtocolClassCap pc3_0("PCL 6 Protocol Class 3.0", false, kProtocolClass3_0,
|
const ProtocolClassCap pc3_0("PCL 6 Protocol Class 3.0", false, kProtocolClass3_0,
|
||||||
"Protocol Class 3.0");
|
"Protocol Class 3.0");
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* PCL6Config.cpp
|
||||||
|
* Copyright 2005 Michael Pfeiffer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _PCL6_CONFIG
|
||||||
|
#define _PCL6_CONFIG
|
||||||
|
|
||||||
|
// Compression method configuration
|
||||||
|
// 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!
|
||||||
|
|
||||||
|
// Run-Length-Encoding Compression
|
||||||
|
#define ENABLE_RLE_COMPRESSION 1
|
||||||
|
|
||||||
|
// Delta Row Compression
|
||||||
|
#define ENABLE_DELTA_ROW_COMPRESSION 1
|
||||||
|
|
||||||
|
// Color depth for color printing.
|
||||||
|
// Use either 1 or 8.
|
||||||
|
// If 1 bit depth is used, the class Halftone is used for dithering
|
||||||
|
// otherwise dithering is not performed.
|
||||||
|
#define COLOR_DEPTH 1
|
||||||
|
|
||||||
|
#define DISPLAY_COMPRESSION_STATISTICS 0
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
Reference in New Issue
Block a user