forked from danieloneill/SeikoSLPLinuxDriver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSIISLPProcessBitmap.h
110 lines (89 loc) · 3.36 KB
/
SIISLPProcessBitmap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* "$Id: SIISLPProcessBitmap.h,v 1.6 Selznick$"
*
* This file contains a class to optimize a raster images.
*
* Copyright 1997-2007 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
* property of Easy Software Products and are protected by Federal
* copyright law. Distribution and use rights are outlined in the file
* "LICENSE.txt" which should have been included with this file. If this
* file is missing or damaged please contact Easy Software Products
* at:
*
* Attn: CUPS Licensing Information
* Easy Software Products
* 44141 Airport View Drive, Suite 204
* Hollywood, Maryland 20636-3142 USA
*
* Voice: (301) 373-9600
* EMail: [email protected]
* WWW: http://www.cups.org
*/
#if !TARGET_API_MAC_OSX
/* We should probably make some sort of types header, but there aren't that many so... */
typedef unsigned short UInt16;
typedef unsigned long UInt32;
typedef long SInt32;
typedef unsigned char Byte;
typedef unsigned char *BytePtr;
typedef SInt32 OSStatus; /* Might not be a perfect mapping, but it works since I'm dealing with COM errors. */
typedef long SInt32;
#endif
/* Error Codes */
#define SIISLPNoError 0
#if TARGET_API_MAC_OSX
#define kSIISLPUnknownUSBPIDError kUSBUnknownDeviceErr
#define kSIISLPMemFullError memFullErr
#define kSIISLPImplementationError unimpErr
#else
#define kSIISLPUnknownUSBPIDError 1
#define kSIISLPMemFullError 2
#define kSIISLPImplementationError 3
#endif
#define kMaxBytesPerLine 128
class SIISLPProcessBitmap
{
public:
SIISLPProcessBitmap(UInt16 usbPID);
virtual ~SIISLPProcessBitmap();
long ProcessBitmap( long height,
long width,
long rowBytes,
Byte * bytes);
Byte * GetProcessedBytes();
size_t GetProcessedBytesSize();
/* Compression defaults to on. This allows you to turn it off */
void SetCompression( bool bUsePrintCompression);
private:
long GetMaxDotsPerLine( long & maxDotsPerLine);
Byte GetBitMask( size_t bitCount);
long PrintPrepare( long width);
long AdvanceLines( UInt16 linesToAdvance);
void CompressRun( Byte bufferCompressed[],
int runCount,
bool runIsBlack,
Byte * bytes,
int & byteIndex,
int & bitIndex,
size_t byteCount,
unsigned int & bufferIndex,
int & lengthIndex,
bool & firstRun);
long ProcessLine( Byte * bytes,
size_t byteCount);
long AppendBytes( Byte * bytes,
size_t bufferSize);
private:
bool mUsePrintCompression;
UInt16 mUSBPID;
Byte * mProcessedBytes;
size_t mProcessedBytesSize;
size_t mProcessedBytesAllocSize;
Byte mLastPrintCommand[kMaxBytesPerLine];
int mLastPrintCommandSize;
};
/*
* End of "$Id: SIISLPProcessBitmap.h,v 1.6 Selznick$"
*/