xref: /haiku/src/add-ons/print/drivers/pcl6/PCL6Rasterizer.h (revision 2f470aec1c92ce6917b8a903e343795dc77af41f)
1 /*
2 ** PCL6Rasterizer.h
3 ** Copyright 2005, Michael Pfeiffer, laplace@users.sourceforge.net. All rights reserved.
4 ** Distributed under the terms of the OpenBeOS License.
5 */
6 #ifndef _PCL6_RASTERIZER_H
7 #define _PCL6_RASTERIZER_H
8 #include "Rasterizer.h"
9 
10 class PCL6Rasterizer : public Rasterizer
11 {
12 public:
13 	PCL6Rasterizer(Halftone *halftone)
14 		: Rasterizer(halftone)
15 		, fOutBuffer(NULL)
16 		, fOutBufferSize(0)
17 	{
18 	}
19 
20 	~PCL6Rasterizer()
21 	{
22 		delete fOutBuffer;
23 		fOutBuffer = NULL;
24 	}
25 
26 	void SetOutBufferSize(int size) { fOutBufferSize = size; }
27 	int GetOutBufferSize() { return fOutBufferSize; }
28 
29 	uchar *GetOutBuffer() { return fOutBuffer; }
30 
31 	virtual void InitializeBuffer() {
32 		fOutBuffer = new uchar[fOutBufferSize];
33 	}
34 
35 	virtual int GetOutRowSize() = 0;
36 
37 
38 private:
39 	uchar       *fOutBuffer;
40 	int          fOutBufferSize;
41 };
42 
43 class MonochromeRasterizer : public PCL6Rasterizer
44 {
45 public:
46 	MonochromeRasterizer(Halftone *halftone);
47 
48 	void InitializeBuffer();
49 
50 	int GetOutRowSize() { return fOutRowSize; }
51 
52 	const void *RasterizeLine(int x, int y, const ColorRGB32Little* source);
53 
54 private:
55 	int fWidthByte;
56 	int fOutRowSize;
57 	int fPadBytes;
58 	int fOutSize;
59 	uchar *fOutBuffer;
60 	uchar *fCurrentLine;
61 };
62 
63 // Output format RGB 8bit per channel
64 class ColorRGBRasterizer : public PCL6Rasterizer
65 {
66 public:
67 	ColorRGBRasterizer(Halftone *halftone) ;
68 
69 	void InitializeBuffer();
70 
71 	int GetOutRowSize() { return fOutRowSize; }
72 
73 	const void *RasterizeLine(int x, int y, const ColorRGB32Little* source);
74 
75 private:
76 	int fWidthByte;
77 	int fOutRowSize;
78 	int fPadBytes;
79 	uchar *fCurrentLine;
80 };
81 
82 typedef uchar *PlaneBuffer;
83 
84 // Output format: RGB 1bit per channel
85 // Class Halftone is used for dithering
86 class ColorRasterizer : public PCL6Rasterizer
87 {
88 public:
89 	ColorRasterizer(Halftone *halftone);
90 
91 	~ColorRasterizer();
92 
93 	void InitializeBuffer();
94 
95 	int GetOutRowSize() { return fOutRowSize; }
96 
97 	const void *RasterizeLine(int x, int y, const ColorRGB32Little* source);
98 
99 private:
100 	void MergePlaneBuffersToCurrentLine();
101 
102 	int fWidthByte;
103 	int fOutRowSize;
104 	int fPadBytes;
105 	uchar *fCurrentLine;
106 
107 	int fPlaneBufferSize;
108 	PlaneBuffer fPlaneBuffers[3];
109 };
110 
111 #endif
112