1 #ifndef MUPDF_FITZ_WRITE_PIXMAP_H 2 #define MUPDF_FITZ_WRITE_PIXMAP_H 3 4 #include "mupdf/fitz/system.h" 5 #include "mupdf/fitz/context.h" 6 #include "mupdf/fitz/output.h" 7 #include "mupdf/fitz/band-writer.h" 8 #include "mupdf/fitz/pixmap.h" 9 #include "mupdf/fitz/bitmap.h" 10 #include "mupdf/fitz/buffer.h" 11 #include "mupdf/fitz/image.h" 12 13 /** 14 PCL output 15 */ 16 typedef struct 17 { 18 /* Features of a particular printer */ 19 int features; 20 const char *odd_page_init; 21 const char *even_page_init; 22 23 /* Options for this job */ 24 int tumble; 25 int duplex_set; 26 int duplex; 27 int paper_size; 28 int manual_feed_set; 29 int manual_feed; 30 int media_position_set; 31 int media_position; 32 int orientation; 33 34 /* Updated as we move through the job */ 35 int page_count; 36 } fz_pcl_options; 37 38 /** 39 Initialize PCL option struct for a given preset. 40 41 Currently defined presets include: 42 43 generic Generic PCL printer 44 ljet4 HP DeskJet 45 dj500 HP DeskJet 500 46 fs600 Kyocera FS-600 47 lj HP LaserJet, HP LaserJet Plus 48 lj2 HP LaserJet IIp, HP LaserJet IId 49 lj3 HP LaserJet III 50 lj3d HP LaserJet IIId 51 lj4 HP LaserJet 4 52 lj4pl HP LaserJet 4 PL 53 lj4d HP LaserJet 4d 54 lp2563b HP 2563B line printer 55 oce9050 Oce 9050 Line printer 56 */ 57 void fz_pcl_preset(fz_context *ctx, fz_pcl_options *opts, const char *preset); 58 59 /** 60 Parse PCL options. 61 62 Currently defined options and values are as follows: 63 64 preset=X Either "generic" or one of the presets as for fz_pcl_preset. 65 spacing=0 No vertical spacing capability 66 spacing=1 PCL 3 spacing (<ESC>*p+<n>Y) 67 spacing=2 PCL 4 spacing (<ESC>*b<n>Y) 68 spacing=3 PCL 5 spacing (<ESC>*b<n>Y and clear seed row) 69 mode2 Disable/Enable mode 2 graphics compression 70 mode3 Disable/Enable mode 3 graphics compression 71 eog_reset End of graphics (<ESC>*rB) resets all parameters 72 has_duplex Duplex supported (<ESC>&l<duplex>S) 73 has_papersize Papersize setting supported (<ESC>&l<sizecode>A) 74 has_copies Number of copies supported (<ESC>&l<copies>X) 75 is_ljet4pjl Disable/Enable HP 4PJL model-specific output 76 is_oce9050 Disable/Enable Oce 9050 model-specific output 77 */ 78 fz_pcl_options *fz_parse_pcl_options(fz_context *ctx, fz_pcl_options *opts, const char *args); 79 80 /** 81 Create a new band writer, outputing monochrome pcl. 82 */ 83 fz_band_writer *fz_new_mono_pcl_band_writer(fz_context *ctx, fz_output *out, const fz_pcl_options *options); 84 85 /** 86 Write a bitmap as mono PCL. 87 */ 88 void fz_write_bitmap_as_pcl(fz_context *ctx, fz_output *out, const fz_bitmap *bitmap, const fz_pcl_options *pcl); 89 90 /** 91 Save a bitmap as mono PCL. 92 */ 93 void fz_save_bitmap_as_pcl(fz_context *ctx, fz_bitmap *bitmap, char *filename, int append, const fz_pcl_options *pcl); 94 95 /** 96 Create a new band writer, outputing color pcl. 97 */ 98 fz_band_writer *fz_new_color_pcl_band_writer(fz_context *ctx, fz_output *out, const fz_pcl_options *options); 99 100 /** 101 Write an (RGB) pixmap as color PCL. 102 */ 103 void fz_write_pixmap_as_pcl(fz_context *ctx, fz_output *out, const fz_pixmap *pixmap, const fz_pcl_options *pcl); 104 105 /** 106 Save an (RGB) pixmap as color PCL. 107 */ 108 void fz_save_pixmap_as_pcl(fz_context *ctx, fz_pixmap *pixmap, char *filename, int append, const fz_pcl_options *pcl); 109 110 /** 111 PCLm output 112 */ 113 typedef struct 114 { 115 int compress; 116 int strip_height; 117 118 /* Updated as we move through the job */ 119 int page_count; 120 } fz_pclm_options; 121 122 /** 123 Parse PCLm options. 124 125 Currently defined options and values are as follows: 126 127 compression=none: No compression 128 compression=flate: Flate compression 129 strip-height=n: Strip height (default 16) 130 */ 131 fz_pclm_options *fz_parse_pclm_options(fz_context *ctx, fz_pclm_options *opts, const char *args); 132 133 /** 134 Create a new band writer, outputing pclm 135 */ 136 fz_band_writer *fz_new_pclm_band_writer(fz_context *ctx, fz_output *out, const fz_pclm_options *options); 137 138 /** 139 Write a (Greyscale or RGB) pixmap as pclm. 140 */ 141 void fz_write_pixmap_as_pclm(fz_context *ctx, fz_output *out, const fz_pixmap *pixmap, const fz_pclm_options *options); 142 143 /** 144 Save a (Greyscale or RGB) pixmap as pclm. 145 */ 146 void fz_save_pixmap_as_pclm(fz_context *ctx, fz_pixmap *pixmap, char *filename, int append, const fz_pclm_options *options); 147 148 /** 149 PDFOCR output 150 */ 151 typedef struct 152 { 153 int compress; 154 int strip_height; 155 char language[256]; 156 157 /* Updated as we move through the job */ 158 int page_count; 159 } fz_pdfocr_options; 160 161 /** 162 Parse PDFOCR options. 163 164 Currently defined options and values are as follows: 165 166 compression=none: No compression 167 compression=flate: Flate compression 168 strip-height=n: Strip height (default 16) 169 ocr-language=<lang>: OCR Language (default eng) 170 */ 171 fz_pdfocr_options *fz_parse_pdfocr_options(fz_context *ctx, fz_pdfocr_options *opts, const char *args); 172 173 /** 174 Create a new band writer, outputing pdfocr 175 */ 176 fz_band_writer *fz_new_pdfocr_band_writer(fz_context *ctx, fz_output *out, const fz_pdfocr_options *options); 177 178 /** 179 Write a (Greyscale or RGB) pixmap as pdfocr. 180 */ 181 void fz_write_pixmap_as_pdfocr(fz_context *ctx, fz_output *out, const fz_pixmap *pixmap, const fz_pdfocr_options *options); 182 183 /** 184 Save a (Greyscale or RGB) pixmap as pdfocr. 185 */ 186 void fz_save_pixmap_as_pdfocr(fz_context *ctx, fz_pixmap *pixmap, char *filename, int append, const fz_pdfocr_options *options); 187 188 /** 189 Save a (Greyscale or RGB) pixmap as a png. 190 */ 191 void fz_save_pixmap_as_png(fz_context *ctx, fz_pixmap *pixmap, const char *filename); 192 193 /** 194 Write a (Greyscale or RGB) pixmap as a png. 195 */ 196 void fz_write_pixmap_as_png(fz_context *ctx, fz_output *out, const fz_pixmap *pixmap); 197 198 /** 199 Create a new png band writer (greyscale or RGB, with or without 200 alpha). 201 */ 202 fz_band_writer *fz_new_png_band_writer(fz_context *ctx, fz_output *out); 203 204 /** 205 Reencode a given image as a PNG into a buffer. 206 207 Ownership of the buffer is returned. 208 */ 209 fz_buffer *fz_new_buffer_from_image_as_png(fz_context *ctx, fz_image *image, fz_color_params color_params); 210 211 /** 212 Reencode a given pixmap as a PNG into a buffer. 213 214 Ownership of the buffer is returned. 215 */ 216 fz_buffer *fz_new_buffer_from_pixmap_as_png(fz_context *ctx, fz_pixmap *pixmap, fz_color_params color_params); 217 218 /** 219 Save a pixmap as a pnm (greyscale or rgb, no alpha). 220 */ 221 void fz_save_pixmap_as_pnm(fz_context *ctx, fz_pixmap *pixmap, const char *filename); 222 223 /** 224 Write a pixmap as a pnm (greyscale or rgb, no alpha). 225 */ 226 void fz_write_pixmap_as_pnm(fz_context *ctx, fz_output *out, fz_pixmap *pixmap); 227 228 /** 229 Create a band writer targetting pnm (greyscale or rgb, no 230 alpha). 231 */ 232 fz_band_writer *fz_new_pnm_band_writer(fz_context *ctx, fz_output *out); 233 234 /** 235 Save a pixmap as a pnm (greyscale, rgb or cmyk, with or without 236 alpha). 237 */ 238 void fz_save_pixmap_as_pam(fz_context *ctx, fz_pixmap *pixmap, const char *filename); 239 240 /** 241 Write a pixmap as a pnm (greyscale, rgb or cmyk, with or without 242 alpha). 243 */ 244 void fz_write_pixmap_as_pam(fz_context *ctx, fz_output *out, fz_pixmap *pixmap); 245 246 /** 247 Create a band writer targetting pnm (greyscale, rgb or cmyk, 248 with or without alpha). 249 */ 250 fz_band_writer *fz_new_pam_band_writer(fz_context *ctx, fz_output *out); 251 252 /** 253 Save a bitmap as a pbm. 254 */ 255 void fz_save_bitmap_as_pbm(fz_context *ctx, fz_bitmap *bitmap, const char *filename); 256 257 /** 258 Write a bitmap as a pbm. 259 */ 260 void fz_write_bitmap_as_pbm(fz_context *ctx, fz_output *out, fz_bitmap *bitmap); 261 262 /** 263 Create a new band writer, targetting pbm. 264 */ 265 fz_band_writer *fz_new_pbm_band_writer(fz_context *ctx, fz_output *out); 266 267 /** 268 Save a pixmap as a pbm. (Performing halftoning). 269 */ 270 void fz_save_pixmap_as_pbm(fz_context *ctx, fz_pixmap *pixmap, const char *filename); 271 272 /** 273 Save a CMYK bitmap as a pkm. 274 */ 275 void fz_save_bitmap_as_pkm(fz_context *ctx, fz_bitmap *bitmap, const char *filename); 276 277 /** 278 Write a CMYK bitmap as a pkm. 279 */ 280 void fz_write_bitmap_as_pkm(fz_context *ctx, fz_output *out, fz_bitmap *bitmap); 281 282 /** 283 Create a new pkm band writer for CMYK pixmaps. 284 */ 285 fz_band_writer *fz_new_pkm_band_writer(fz_context *ctx, fz_output *out); 286 287 /** 288 Save a CMYK pixmap as a pkm. (Performing halftoning). 289 */ 290 void fz_save_pixmap_as_pkm(fz_context *ctx, fz_pixmap *pixmap, const char *filename); 291 292 /** 293 Write a (gray, rgb, or cmyk, no alpha) pixmap out as postscript. 294 */ 295 void fz_write_pixmap_as_ps(fz_context *ctx, fz_output *out, const fz_pixmap *pixmap); 296 297 /** 298 Save a (gray, rgb, or cmyk, no alpha) pixmap out as postscript. 299 */ 300 void fz_save_pixmap_as_ps(fz_context *ctx, fz_pixmap *pixmap, char *filename, int append); 301 302 /** 303 Create a postscript band writer for gray, rgb, or cmyk, no 304 alpha. 305 */ 306 fz_band_writer *fz_new_ps_band_writer(fz_context *ctx, fz_output *out); 307 308 /** 309 Write the file level header for ps band writer output. 310 */ 311 void fz_write_ps_file_header(fz_context *ctx, fz_output *out); 312 313 /** 314 Write the file level trailer for ps band writer output. 315 */ 316 void fz_write_ps_file_trailer(fz_context *ctx, fz_output *out, int pages); 317 318 /** 319 Save a pixmap as a PSD file. 320 */ 321 void fz_save_pixmap_as_psd(fz_context *ctx, fz_pixmap *pixmap, const char *filename); 322 323 /** 324 Write a pixmap as a PSD file. 325 */ 326 void fz_write_pixmap_as_psd(fz_context *ctx, fz_output *out, const fz_pixmap *pixmap); 327 328 /** 329 Open a PSD band writer. 330 */ 331 fz_band_writer *fz_new_psd_band_writer(fz_context *ctx, fz_output *out); 332 333 typedef struct 334 { 335 /* These are not interpreted as CStrings by the writing code, 336 * but are rather copied directly out. */ 337 char media_class[64]; 338 char media_color[64]; 339 char media_type[64]; 340 char output_type[64]; 341 342 unsigned int advance_distance; 343 int advance_media; 344 int collate; 345 int cut_media; 346 int duplex; 347 int insert_sheet; 348 int jog; 349 int leading_edge; 350 int manual_feed; 351 unsigned int media_position; 352 unsigned int media_weight; 353 int mirror_print; 354 int negative_print; 355 unsigned int num_copies; 356 int orientation; 357 int output_face_up; 358 unsigned int PageSize[2]; 359 int separations; 360 int tray_switch; 361 int tumble; 362 363 int media_type_num; 364 int compression; 365 unsigned int row_count; 366 unsigned int row_feed; 367 unsigned int row_step; 368 369 /* These are not interpreted as CStrings by the writing code, but 370 * are rather copied directly out. */ 371 char rendering_intent[64]; 372 char page_size_name[64]; 373 } fz_pwg_options; 374 375 /** 376 Save a pixmap as a PWG. 377 */ 378 void fz_save_pixmap_as_pwg(fz_context *ctx, fz_pixmap *pixmap, char *filename, int append, const fz_pwg_options *pwg); 379 380 /** 381 Save a bitmap as a PWG. 382 */ 383 void fz_save_bitmap_as_pwg(fz_context *ctx, fz_bitmap *bitmap, char *filename, int append, const fz_pwg_options *pwg); 384 385 /** 386 Write a pixmap as a PWG. 387 */ 388 void fz_write_pixmap_as_pwg(fz_context *ctx, fz_output *out, const fz_pixmap *pixmap, const fz_pwg_options *pwg); 389 390 /** 391 Write a bitmap as a PWG. 392 */ 393 void fz_write_bitmap_as_pwg(fz_context *ctx, fz_output *out, const fz_bitmap *bitmap, const fz_pwg_options *pwg); 394 395 /** 396 Write a pixmap as a PWG page. 397 398 Caller should provide a file header by calling 399 fz_write_pwg_file_header, but can then write several pages to 400 the same file. 401 */ 402 void fz_write_pixmap_as_pwg_page(fz_context *ctx, fz_output *out, const fz_pixmap *pixmap, const fz_pwg_options *pwg); 403 404 /** 405 Write a bitmap as a PWG page. 406 407 Caller should provide a file header by calling 408 fz_write_pwg_file_header, but can then write several pages to 409 the same file. 410 */ 411 void fz_write_bitmap_as_pwg_page(fz_context *ctx, fz_output *out, const fz_bitmap *bitmap, const fz_pwg_options *pwg); 412 413 /** 414 Create a new monochrome pwg band writer. 415 */ 416 fz_band_writer *fz_new_mono_pwg_band_writer(fz_context *ctx, fz_output *out, const fz_pwg_options *pwg); 417 418 /** 419 Create a new color pwg band writer. 420 */ 421 fz_band_writer *fz_new_pwg_band_writer(fz_context *ctx, fz_output *out, const fz_pwg_options *pwg); 422 423 /** 424 Output the file header to a pwg stream, ready for pages to follow it. 425 */ 426 void fz_write_pwg_file_header(fz_context *ctx, fz_output *out); /* for use by mudraw.c */ 427 428 #endif 429