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