xref: /haiku/src/add-ons/print/drivers/pcl6/PCL6Rasterizer.h (revision e081b9cd7ef168847177a491da56ccb1c69d57cb)
12e86189fSMichael Pfeiffer /*
22e86189fSMichael Pfeiffer ** PCL6Rasterizer.h
3568716beSWim van der Meer ** Copyright 2005, Michael Pfeiffer, laplace@users.sourceforge.net.
4568716beSWim van der Meer ** All rights reserved.
5b6f76ebeSAugustin Cavalier ** Distributed under the terms of the MIT License.
62e86189fSMichael Pfeiffer */
72e86189fSMichael Pfeiffer #ifndef _PCL6_RASTERIZER_H
82e86189fSMichael Pfeiffer #define _PCL6_RASTERIZER_H
9568716beSWim van der Meer 
10568716beSWim van der Meer 
112e86189fSMichael Pfeiffer #include "Rasterizer.h"
122e86189fSMichael Pfeiffer 
13568716beSWim van der Meer 
142e86189fSMichael Pfeiffer class PCL6Rasterizer : public Rasterizer
152e86189fSMichael Pfeiffer {
162e86189fSMichael Pfeiffer public:
PCL6Rasterizer(Halftone * halftone)172e86189fSMichael Pfeiffer 						PCL6Rasterizer(Halftone* halftone)
18568716beSWim van der Meer 						:
19568716beSWim van der Meer 						Rasterizer(halftone),
20568716beSWim van der Meer 						fOutBuffer(NULL),
21568716beSWim van der Meer 						fOutBufferSize(0)
22568716beSWim van der Meer 						{}
232e86189fSMichael Pfeiffer 
~PCL6Rasterizer()242e86189fSMichael Pfeiffer 						~PCL6Rasterizer()
252e86189fSMichael Pfeiffer 						{
26*e081b9cdSMurai Takashi 							delete[] fOutBuffer;
272e86189fSMichael Pfeiffer 							fOutBuffer = NULL;
282e86189fSMichael Pfeiffer 						}
292e86189fSMichael Pfeiffer 
SetOutBufferSize(int size)30568716beSWim van der Meer 			void		SetOutBufferSize(int size)
31568716beSWim van der Meer 						{
32568716beSWim van der Meer 							fOutBufferSize = size;
33568716beSWim van der Meer 						}
GetOutBufferSize()34568716beSWim van der Meer 			int			GetOutBufferSize()
35568716beSWim van der Meer 						{
36568716beSWim van der Meer 							return fOutBufferSize;
37568716beSWim van der Meer 						}
GetOutBuffer()38568716beSWim van der Meer 			uchar*		GetOutBuffer()
39568716beSWim van der Meer 						{
40568716beSWim van der Meer 							return fOutBuffer;
41568716beSWim van der Meer 						}
422e86189fSMichael Pfeiffer 
InitializeBuffer()43568716beSWim van der Meer 	virtual	void		InitializeBuffer()
44568716beSWim van der Meer 						{
452e86189fSMichael Pfeiffer 							fOutBuffer = new uchar[fOutBufferSize];
462e86189fSMichael Pfeiffer 						}
472e86189fSMichael Pfeiffer 
482e86189fSMichael Pfeiffer 	virtual	int			GetOutRowSize() = 0;
492e86189fSMichael Pfeiffer 
502e86189fSMichael Pfeiffer private:
512e86189fSMichael Pfeiffer 			uchar*		fOutBuffer;
522e86189fSMichael Pfeiffer 			int			fOutBufferSize;
532e86189fSMichael Pfeiffer };
542e86189fSMichael Pfeiffer 
55568716beSWim van der Meer 
562e86189fSMichael Pfeiffer class MonochromeRasterizer : public PCL6Rasterizer
572e86189fSMichael Pfeiffer {
582e86189fSMichael Pfeiffer public:
592e86189fSMichael Pfeiffer 						MonochromeRasterizer(Halftone* halftone);
602e86189fSMichael Pfeiffer 
612e86189fSMichael Pfeiffer 			void		InitializeBuffer();
622e86189fSMichael Pfeiffer 
GetOutRowSize()63568716beSWim van der Meer 			int			GetOutRowSize()
64568716beSWim van der Meer 						{
65568716beSWim van der Meer 							return fOutRowSize;
66568716beSWim van der Meer 						}
672e86189fSMichael Pfeiffer 
68568716beSWim van der Meer 			const void*	RasterizeLine(int x, int y,
69568716beSWim van der Meer 							const ColorRGB32Little* source);
702e86189fSMichael Pfeiffer 
712e86189fSMichael Pfeiffer private:
722e86189fSMichael Pfeiffer 			int			fWidthByte;
732e86189fSMichael Pfeiffer 			int			fOutRowSize;
742e86189fSMichael Pfeiffer 			int			fPadBytes;
752e86189fSMichael Pfeiffer 			int			fOutSize;
762e86189fSMichael Pfeiffer 			uchar*		fOutBuffer;
772e86189fSMichael Pfeiffer 			uchar*		fCurrentLine;
782e86189fSMichael Pfeiffer };
792e86189fSMichael Pfeiffer 
80568716beSWim van der Meer 
812e86189fSMichael Pfeiffer // Output format RGB 8bit per channel
822e86189fSMichael Pfeiffer class ColorRGBRasterizer : public PCL6Rasterizer
832e86189fSMichael Pfeiffer {
842e86189fSMichael Pfeiffer public:
852e86189fSMichael Pfeiffer 						ColorRGBRasterizer(Halftone* halftone);
862e86189fSMichael Pfeiffer 
872e86189fSMichael Pfeiffer 			void		InitializeBuffer();
882e86189fSMichael Pfeiffer 
GetOutRowSize()89568716beSWim van der Meer 			int			GetOutRowSize()
90568716beSWim van der Meer 						{
91568716beSWim van der Meer 							return fOutRowSize;
92568716beSWim van der Meer 						}
932e86189fSMichael Pfeiffer 
94568716beSWim van der Meer 			const void*	RasterizeLine(int x, int y,
95568716beSWim van der Meer 							const ColorRGB32Little* source);
962e86189fSMichael Pfeiffer 
972e86189fSMichael Pfeiffer private:
982e86189fSMichael Pfeiffer 			int			fWidthByte;
992e86189fSMichael Pfeiffer 			int			fOutRowSize;
1002e86189fSMichael Pfeiffer 			int			fPadBytes;
1012e86189fSMichael Pfeiffer 			uchar*		fCurrentLine;
1022e86189fSMichael Pfeiffer };
1032e86189fSMichael Pfeiffer 
104568716beSWim van der Meer 
1052e86189fSMichael Pfeiffer typedef uchar* PlaneBuffer;
1062e86189fSMichael Pfeiffer 
107568716beSWim van der Meer 
1082e86189fSMichael Pfeiffer // Output format: RGB 1bit per channel
1092e86189fSMichael Pfeiffer // Class Halftone is used for dithering
1102e86189fSMichael Pfeiffer class ColorRasterizer : public PCL6Rasterizer
1112e86189fSMichael Pfeiffer {
1122e86189fSMichael Pfeiffer public:
1132e86189fSMichael Pfeiffer 						ColorRasterizer(Halftone* halftone);
1142e86189fSMichael Pfeiffer 
1152e86189fSMichael Pfeiffer 						~ColorRasterizer();
1162e86189fSMichael Pfeiffer 
1172e86189fSMichael Pfeiffer 			void		InitializeBuffer();
1182e86189fSMichael Pfeiffer 
GetOutRowSize()119568716beSWim van der Meer 			int			GetOutRowSize()
120568716beSWim van der Meer 						{
121568716beSWim van der Meer 							return fOutRowSize;
122568716beSWim van der Meer 						}
1232e86189fSMichael Pfeiffer 
124568716beSWim van der Meer 			const void*	RasterizeLine(int x, int y,
125568716beSWim van der Meer 							const ColorRGB32Little* source);
1262e86189fSMichael Pfeiffer 
1272e86189fSMichael Pfeiffer private:
1282e86189fSMichael Pfeiffer 			void		MergePlaneBuffersToCurrentLine();
1292e86189fSMichael Pfeiffer 
1302e86189fSMichael Pfeiffer 			int			fWidthByte;
1312e86189fSMichael Pfeiffer 			int			fOutRowSize;
1322e86189fSMichael Pfeiffer 			int			fPadBytes;
1332e86189fSMichael Pfeiffer 			uchar*		fCurrentLine;
1342e86189fSMichael Pfeiffer 
1352e86189fSMichael Pfeiffer 			int			fPlaneBufferSize;
1362e86189fSMichael Pfeiffer 			PlaneBuffer	fPlaneBuffers[3];
1372e86189fSMichael Pfeiffer };
1382e86189fSMichael Pfeiffer 
139568716beSWim van der Meer #endif // _PCL6_RASTERIZER_H
140