Debian Codegraph @

src/common/Halftoning.h

raw
1 // -*- C++ -*-
2 // $Id: Halftoning.h 15960 2011-09-02 14:42:28Z pineichen $
3
4 // DYMO LabelWriter Drivers
5 // Copyright (C) 2008 Sanford L.P.
6
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
21
22 #ifndef h4D098F6A_47C6_4e9d_BD74_2DC6034F8EEF
23 #define h4D098F6A_47C6_4e9d_BD74_2DC6034F8EEF
24
25 #include <stdlib.h>
26 #include "CommonTypedefs.h"
27
28 //namespace dymo
29 namespace DymoPrinterDriver
30 {
31
32 class CHalftoneFilter
33 {
34 public:
35 // image format
36 typedef enum
37 {
38 itBW, // Black and White
39 itXRGB, // four bytes per pixel, 8 bits per color, msb is not used (default on MacOSX)
40 itRGB, // three bytes per pixel, 8 bits per color (default on CUPS)
41 } image_t;
42
43 typedef std::vector<buffer_t> image_buffer_t;
44
45 CHalftoneFilter(image_t InputImageType, image_t OutputImageType);
46 virtual ~CHalftoneFilter();
47
48
49 // line-by-line interface
50 virtual bool IsProcessLineSupported() = 0;
51 virtual void ProcessLine(const buffer_t& InputLine, buffer_t& OutputLine) = 0;
52
53 // full-image-at-once interface
54 virtual void ProcessImage(const void* ImageData, size_t ImageWidth, size_t ImageHeight, size_t LineDelta, std::vector<buffer_t>& OutputImage) = 0;
55 virtual void ProcessImage(const image_buffer_t& InputImage, image_buffer_t& OutputImage) = 0;
56
57 image_t GetInputImageType();
58 image_t GetOutputImageType();
59
60 // convert RGB value to Gray Scale
61 byte RGBToGrayScale(byte R, byte G, byte B);
62
63 // pixelValue (0 - white, 1 - black)
64 void SetPixelBW(buffer_t& buf, int pixelNo, int pixelValue);
65
66 // based on inputImageType extract color component of current pixel
67 void ExtractRGB(const buffer_t& InputLine, int PixelNo, byte& R, byte& G, byte& B);
68 // same as previous but return colors as packed integer value
69 int ExtractRGB(const buffer_t& InputLine, int PixelNo);
70
71 // return imageWidth based on inputImageType and input line data
72 size_t CalcImageWidth(const buffer_t& InputLine);
73 // return buffer size needed to store an input line based on inputImageType
74 size_t CalcBufferSize(size_t ImageWidth);
75 // calc output buffer size
76 size_t CalcOutputBufferSize(size_t ImageWidth);
77
78 private:
79 image_t InputImageType_;
80 image_t OutputImageType_;
81 };
82
83
84 class EHalftoneError
85 {
86 public:
87 typedef enum
88 {
89 heUnsupportedImageType = 1,
90 } error_t;
91
92 EHalftoneError(error_t ErrorCode);
93
94 error_t GetErrorCode();
95
96 private:
97 error_t ErrorCode_;
98 };
99
100 }
101
102 #endif
103
104 /*
105 * End of "$Id: Halftoning.h 15960 2011-09-02 14:42:28Z pineichen $".
106 */