Implemented RLE compression
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11441 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
e2bfe39dea
commit
5fc71589cf
@ -9,14 +9,15 @@
|
||||
#include <File.h>
|
||||
#include <memory>
|
||||
|
||||
#include "PCL6.h"
|
||||
|
||||
#include "DbgMsg.h"
|
||||
#include "DeltaRowCompression.h"
|
||||
#include "Halftone.h"
|
||||
#include "JobData.h"
|
||||
#include "PackBits.h"
|
||||
#include "PCL6.h"
|
||||
#include "PCL6Cap.h"
|
||||
#include "PCL6Config.h"
|
||||
#include "PrinterData.h"
|
||||
#include "PCL6Rasterizer.h"
|
||||
#include "UIDriver.h"
|
||||
@ -28,23 +29,6 @@ using namespace std;
|
||||
#define std
|
||||
#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
|
||||
// in the contructor specified stream.
|
||||
class DeltaRowStreamCompressor : public AbstractDeltaRowCompressor
|
||||
@ -195,11 +179,10 @@ void PCL6Driver::writeBitmap(const uchar* buffer, int outSize, int rowSize, int
|
||||
#endif
|
||||
|
||||
#if ENABLE_RLE_COMPRESSION
|
||||
HP_UInt32 compressedSize = 0;
|
||||
HP_M2TIFF_CalcCompression((HP_pCharHuge)buffer, outSize, &compressedSize);
|
||||
if (compressedSize < (uint32)dataSize) {
|
||||
int rleSize = pack_bits_size(buffer, outSize);
|
||||
if (rleSize < dataSize) {
|
||||
compressionMethod = PCL6Writer::kRLECompression;
|
||||
dataSize = compressedSize;
|
||||
dataSize = rleSize;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -212,10 +195,10 @@ void PCL6Driver::writeBitmap(const uchar* buffer, int outSize, int rowSize, int
|
||||
|
||||
endRasterGraphics();
|
||||
|
||||
#if 0
|
||||
#if DISPLAY_COMPRESSION_STATISTICS
|
||||
fprintf(stderr, "Out Size %d %2.2f\n", (int)outSize, 100.0);
|
||||
#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
|
||||
#if ENABLE_DELTA_ROW_COMPRESSION
|
||||
fprintf(stderr, "Delta Row Size %d %2.2f\n", (int)deltaRowSize, 100.0 * deltaRowSize / outSize);
|
||||
@ -310,8 +293,10 @@ void PCL6Driver::rasterGraphics(
|
||||
// write data
|
||||
if (compressionMethod == PCL6Writer::kRLECompression) {
|
||||
// use RLE compression
|
||||
// uint32 compressedSize = 0;
|
||||
// HP_M2TIFF_Compress(fStream, 0, (HP_pCharHuge)buffer, bufferSize, &compressedSize);
|
||||
uchar *outBuffer = new uchar[dataSize];
|
||||
pack_bits(outBuffer, buffer, bufferSize);
|
||||
fWriter->Append(outBuffer, dataSize);
|
||||
delete outBuffer;
|
||||
return;
|
||||
} else if (compressionMethod == PCL6Writer::kDeltaRowCompression) {
|
||||
// use delta row compression
|
||||
|
@ -1,10 +1,12 @@
|
||||
/*
|
||||
* PCL6Cap.cpp
|
||||
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
||||
* COpyright 2003-2005 Michael Pfeiffer.
|
||||
*/
|
||||
|
||||
#include "PrinterData.h"
|
||||
#include "PCL6Cap.h"
|
||||
#include "PCL6Config.h"
|
||||
#include "PrinterData.h"
|
||||
|
||||
#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,
|
||||
"Protocol Class 1.1\n"
|
||||
"* No compression\n"
|
||||
"* RLE compression (not implemented yet)");
|
||||
"* No compression"
|
||||
#if ENABLE_RLE_COMPRESSION
|
||||
"\n* RLE compression"
|
||||
#endif
|
||||
);
|
||||
const ProtocolClassCap pc2_0("PCL 6 Protocol Class 2.0", false, kProtocolClass2_0,
|
||||
"Protocol Class 2.0\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,
|
||||
"Protocol Class 2.1\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,
|
||||
"Protocol Class 3.0");
|
||||
|
||||
|
28
src/add-ons/print/drivers/pcl6/PCL6Config.h
Normal file
28
src/add-ons/print/drivers/pcl6/PCL6Config.h
Normal file
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user