Tizen 2.1 base
[platform/upstream/hplip.git] / prnt / hpcups / HPCupsFilter.h
1 /*****************************************************************************\\r
2   HPCupsFilter.h : Interface for HPCupsFilter class\r
3 \r
4   Copyright (c) 1996 - 2009, Hewlett-Packard Co.\r
5   All rights reserved.\r
6 \r
7   Redistribution and use in source and binary forms, with or without\r
8   modification, are permitted provided that the following conditions\r
9   are met:\r
10   1. Redistributions of source code must retain the above copyright\r
11      notice, this list of conditions and the following disclaimer.\r
12   2. Redistributions in binary form must reproduce the above copyright\r
13      notice, this list of conditions and the following disclaimer in the\r
14      documentation and/or other materials provided with the distribution.\r
15   3. Neither the name of Hewlett-Packard nor the names of its\r
16      contributors may be used to endorse or promote products derived\r
17      from this software without specific prior written permission.\r
18 \r
19   THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED\r
20   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
21   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN\r
22   NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
23   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
24   TO, PATENT INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS\r
25   OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r
26   ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
27   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\r
28   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
29 \*****************************************************************************/\r
30 \r
31 #ifndef HP_CUPSFILTER_H\r
32 #define HP_CUPSFILTER_H\r
33 \r
34 #include "CommonDefinitions.h"\r
35 #include "SystemServices.h"\r
36 #include "Compressor.h"\r
37 #include "Job.h"\r
38 \r
39 #include "dbuscomm.h"\r
40 \r
41 #define         DBITMAPFILEHEADER               14\r
42 #define         DBITMAPINFOHEADER               40\r
43 \r
44 enum eRasterType\r
45 {\r
46     BLACK_RASTER,\r
47     COLOR_RASTER\r
48 };\r
49 \r
50 typedef struct\r
51 {\r
52     short    bfType;\r
53     int      bfSize;\r
54     short    bfReserved1;\r
55     short    bfReserved2;\r
56     int      bfOffBits;\r
57 } BITMAPFILEHEADER;\r
58 \r
59 typedef struct\r
60 {\r
61     int     biSize;\r
62     int     biWidth;\r
63     int     biHeight;\r
64     short   biPlanes;\r
65     short   biBitCount;\r
66     int     biCompression;\r
67     int     biSizeImage;\r
68     int     biXPelsPerMeter;\r
69     int     biYPelsPerMeter;\r
70     int     biClrUsed;\r
71     int     biClrImportant;\r
72 } BITMAPINFOHEADER;\r
73 \r
74 class HPCupsFilter\r
75 {\r
76 public:\r
77 \r
78     HPCupsFilter();\r
79     ~HPCupsFilter();    \r
80     int     StartPrintJob(int  argc, char *argv[]);\r
81     void    CancelJob();\r
82     void    RemoveStatus();\r
83 \r
84     void WriteBMPHeader (FILE *fp, int width, int height, eRasterType raster_type);\r
85     void WriteBMPRaster (FILE *fp, BYTE *raster, int width, eRasterType raster_type);\r
86 \r
87 private:\r
88 \r
89     BYTE            *m_pPrinterBuffer;        \r
90     Job            m_Job;\r
91     SystemServices         *m_pSys;\r
92     int             child_pid;\r
93     char            **m_argv;\r
94     JobAttributes   m_JA;\r
95     ppd_file_t      *m_ppd;\r
96     DBusCommunicator m_DBusComm;\r
97         \r
98 private:\r
99 \r
100     void            closeFilter();\r
101     void            cleanup();\r
102     void            getLogLevel();\r
103     DRIVER_ERROR    startPage (cups_page_header2_t *header);\r
104     int             processRasterData(cups_raster_t *cups_raster);\r
105     void            extractBlackPixels(cups_page_header2_t *cups_header,\r
106                                        BYTE *kRaster, BYTE *rgbRaster);\r
107     void            printCupsHeaderInfo(cups_page_header2_t *header);\r
108     bool            isBlankRaster(BYTE *input_raster, cups_page_header2_t *header);\r
109         int             m_iLogLevel;\r
110 \r
111     void CreateBMPHeader(int width, int height, int planes, int bpp);\r
112     void WriteCBMPHeader (FILE *fp, int width, int height);\r
113     void WriteKBMPHeader (FILE *fp, int width, int height);\r
114     void WriteCBMPRaster (FILE *fp, BYTE *rgb_raster, int width);\r
115     void WriteKBMPRaster (FILE *fp, BYTE *k_raster, int width);\r
116     int    adj_c_width;\r
117     int    adj_k_width;\r
118     BYTE   *black_raster;\r
119     BYTE   *color_raster;\r
120     BITMAPFILEHEADER    bmfh;\r
121     BITMAPINFOHEADER    bmih;\r
122 };\r
123 \r
124 #endif  // HP_CUPSFILTER_H\r
125 \r