Patch for 542629, CMYK tiff driver
"Jeong Kim" <[email protected]>
| Newsgroups | gmane.comp.printing.ghostscript.patches |
|---|---|
| Message-ID | <[email protected]> |
This is a reminder.
Reviewers,
This is a patch for CMYK tiff driver.
As TIFF does not have CMYK photometric type, I set the 'Photometric' tag to
seperated and 'SamplesPerPixel' to 4.
Jeong
Log:
CMYK TIFF Driver. tiff32cmyk. Patch for 542629.
Index: src/gdevtfnx.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevtfnx.c,v
retrieving revision 1.7
diff -C2 -r1.7 gdevtfnx.c
*** src/gdevtfnx.c 21 Feb 2002 22:24:52 -0000 1.7
--- src/gdevtfnx.c 11 Jan 2004 23:41:05 -0000
***************
*** 16,20 ****
/* $Id: gdevtfnx.c,v 1.7 2002/02/21 22:24:52 giles Exp $ */
! /* 12-bit & 24-bit RGB uncompressed TIFF driver */
#include "gdevprn.h"
#include "gdevtifs.h"
--- 16,20 ----
/* $Id: gdevtfnx.c,v 1.7 2002/02/21 22:24:52 giles Exp $ */
! /* 12-bit, 24-bit RGB and 32-bit CMYK uncompressed TIFF driver */
#include "gdevprn.h"
#include "gdevtifs.h"
***************
*** 39,42 ****
--- 39,43 ----
private dev_proc_print_page(tiff12_print_page);
private dev_proc_print_page(tiff24_print_page);
+ private dev_proc_print_page(tiff32_print_page);
private const gx_device_procs tiff12_procs =
***************
*** 47,50 ****
--- 48,61 ----
gx_default_rgb_map_rgb_color, gx_default_rgb_map_color_rgb);
+ #define tiff_cmyk_procs(p_map_color_rgb, p_map_cmyk_color)\
+ gdev_prn_open, NULL, NULL, gdev_prn_output_page, gdev_prn_close,\
+ NULL, p_map_color_rgb, NULL, NULL, NULL, NULL, NULL, NULL,\
+ gdev_prn_get_params, gdev_prn_put_params,\
+ p_map_cmyk_color, NULL, NULL, NULL, gx_page_device_get_page_device
+
+ private const gx_device_procs tiff32_procs = {
+ tiff_cmyk_procs(cmyk_8bit_map_color_rgb,
gx_default_cmyk_map_cmyk_color)
+ };
+
const gx_device_printer gs_tiff12nc_device = {
prn_device_std_body(gx_device_tiff, tiff12_procs, "tiff12nc",
***************
*** 63,66 ****
--- 74,85 ----
};
+ const gx_device_printer gs_tiff32cmyk_device = {
+ prn_device_std_body(gx_device_tiff, tiff32_procs, "tiff32cmyk",
+ DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
+ X_DPI, Y_DPI,
+ 0, 0, 0, 0,
+ 32, tiff32_print_page)
+ };
+
/* ------ Private definitions ------ */
***************
*** 73,79 ****
--- 92,110 ----
TIFF_dir_entry SamplesPerPixel;
} tiff_rgb_directory;
+ typedef struct tiff_cmyk_directory_s {
+ TIFF_dir_entry BitsPerSample;
+ TIFF_dir_entry Compression;
+ TIFF_dir_entry Photometric;
+ TIFF_dir_entry FillOrder;
+ TIFF_dir_entry SamplesPerPixel;
+ TIFF_dir_entry InkSet;
+ TIFF_dir_entry NumberOfInks;
+ } tiff_cmyk_directory;
typedef struct tiff_rgb_values_s {
TIFF_ushort bps[3];
} tiff_rgb_values;
+ typedef struct tiff_cmyk_values_s {
+ TIFF_ushort bps[4];
+ } tiff_cmyk_values;
private const tiff_rgb_directory dir_rgb_template =
***************
*** 87,90 ****
--- 118,133 ----
};
+ private const tiff_cmyk_directory dir_cmyk_template =
+ {
+ /* C's ridiculous rules about & and arrays require bps[0] here: */
+ {TIFFTAG_BitsPerSample, TIFF_SHORT | TIFF_INDIRECT, 4,
offset_of(tiff_cmyk_values, bps[0])},
+ {TIFFTAG_Compression, TIFF_SHORT, 1, Compression_none},
+ {TIFFTAG_Photometric, TIFF_SHORT, 1, Photometric_separated},
+ {TIFFTAG_FillOrder, TIFF_SHORT, 1, FillOrder_MSB2LSB},
+ {TIFFTAG_SamplesPerPixel, TIFF_SHORT, 1, 4},
+ {TIFFTAG_InkSet, TIFF_SHORT, 1, InkSet_CMYK},
+ {TIFFTAG_NumberOfInks, TIFF_SHORT, 1, 4},
+ };
+
private const tiff_rgb_values val_12_template = {
{4, 4, 4}
***************
*** 95,98 ****
--- 138,145 ----
};
+ private const tiff_cmyk_values val_32_template = {
+ {8, 8, 8, 8}
+ };
+
/* ------ Private functions ------ */
***************
*** 186,187 ****
--- 233,272 ----
return code;
}
+
+ private int
+ tiff32_print_page(gx_device_printer * pdev, FILE * file)
+ {
+ gx_device_tiff *const tfdev = (gx_device_tiff *)pdev;
+ int code;
+
+ /* Write the page directory. */
+ code = gdev_tiff_begin_page(pdev, &tfdev->tiff, file,
+ (const TIFF_dir_entry *)&dir_cmyk_template,
+ sizeof(dir_cmyk_template) /
sizeof(TIFF_dir_entry),
+ (const byte *)&val_32_template,
+ sizeof(val_32_template), 0);
+ if (code < 0)
+ return code;
+
+ /* Write the page data. */
+ {
+ int y;
+ int raster = gdev_prn_raster(pdev);
+ byte *line = gs_alloc_bytes(pdev->memory, raster,
"tiff32_print_page");
+ byte *row;
+
+ if (line == 0)
+ return_error(gs_error_VMerror);
+ for (y = 0; y < pdev->height; ++y) {
+ code = gdev_prn_get_bits(pdev, y, line, &row);
+ if (code < 0)
+ break;
+ fwrite((char *)row, raster, 1, file);
+ }
+ gdev_tiff_end_strip(&tfdev->tiff, file);
+ gdev_tiff_end_page(&tfdev->tiff, file);
+ gs_free_object(pdev->memory, line, "tiff32_print_page");
+ }
+
+ return code;
+ }
Index: src/gdevtifs.h
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevtifs.h,v
retrieving revision 1.6
diff -C2 -r1.6 gdevtifs.h
*** src/gdevtifs.h 16 Jun 2002 07:25:26 -0000 1.6
--- src/gdevtifs.h 11 Jan 2004 23:41:06 -0000
***************
*** 173,180 ****
* TIFF-reading applications don't recognize it. Don't use it!
*/
! TIFFTAG_CleanFaxData = 327 /* regenerated line info */
#define CleanFaxData_clean 0 /* no errors
detected */
#define CleanFaxData_regenerated 1 /* receiver
regenerated lines */
#define CleanFaxData_unclean 2 /* uncorrected
errors exist */
} TIFF_tag;
--- 173,184 ----
* TIFF-reading applications don't recognize it. Don't use it!
*/
! TIFFTAG_CleanFaxData = 327, /* regenerated line info */
#define CleanFaxData_clean 0 /* no errors
detected */
#define CleanFaxData_regenerated 1 /* receiver
regenerated lines */
#define CleanFaxData_unclean 2 /* uncorrected
errors exist */
+ TIFFTAG_InkSet = 332, /* inks in separated image */
+ #define InkSet_CMYK 1 /*
cyan-magenta-yellow-black */
+ TIFFTAG_InkNames = 333, /* ascii names of inks */
+ TIFFTAG_NumberOfInks = 334 /* number of inks */
} TIFF_tag;
Index: src/devs.mak
===================================================================
RCS file: /cvs/ghostscript/gs/src/devs.mak,v
retrieving revision 1.102
diff -C2 -r1.102 devs.mak
*** src/devs.mak 9 Jan 2004 13:40:33 -0000 1.102
--- src/devs.mak 11 Jan 2004 23:41:07 -0000
***************
*** 179,182 ****
--- 179,183 ----
# tiff12nc TIFF 12-bit RGB, no compression
# tiff24nc TIFF 24-bit RGB, no compression (NeXT standard format)
+ # tiff32cmyk TIFF 32-bit CMYK, no compression
# tifflzw TIFF LZW (tag = 5) (monochrome)
# tiffpack TIFF PackBits (tag = 32773) (monochrome)
***************
*** 1472,1487 ****
$(SETDEV2) $(DD)tiffpack -include $(DD)tfax
! # RGB, no compression
! tiffrgb_=$(GLOBJ)gdevtfnx.$(OBJ)
! $(DD)tiff12nc.dev : $(DEVS_MAK) $(tiffrgb_) $(DD)tiffs.dev
! $(SETPDEV2) $(DD)tiff12nc $(tiffrgb_)
$(ADDMOD) $(DD)tiff12nc -include $(DD)tiffs
! $(DD)tiff24nc.dev : $(DEVS_MAK) $(tiffrgb_) $(DD)tiffs.dev
! $(SETPDEV2) $(DD)tiff24nc $(tiffrgb_)
$(ADDMOD) $(DD)tiff24nc -include $(DD)tiffs
$(GLOBJ)gdevtfnx.$(OBJ) : $(GLSRC)gdevtfnx.c $(PDEVH) $(gdevtifs_h)
$(GLCC) $(GLO_)gdevtfnx.$(OBJ) $(C_) $(GLSRC)gdevtfnx.c
--- 1473,1492 ----
$(SETDEV2) $(DD)tiffpack -include $(DD)tfax
! # RGB/CMYK, no compression
! tiffdrv_=$(GLOBJ)gdevtfnx.$(OBJ)
! $(DD)tiff12nc.dev : $(DEVS_MAK) $(tiffdrv_) $(DD)tiffs.dev
! $(SETPDEV2) $(DD)tiff12nc $(tiffdrv_)
$(ADDMOD) $(DD)tiff12nc -include $(DD)tiffs
! $(DD)tiff24nc.dev : $(DEVS_MAK) $(tiffdrv_) $(DD)tiffs.dev
! $(SETPDEV2) $(DD)tiff24nc $(tiffdrv_)
$(ADDMOD) $(DD)tiff24nc -include $(DD)tiffs
+ $(DD)tiff32cmyk.dev : $(DEVS_MAK) $(tiffdrv_) $(DD)tiffs.dev
+ $(SETPDEV2) $(DD)tiff32cmyk $(tiffdrv_)
+ $(ADDMOD) $(DD)tiff32cmyk -include $(DD)tiffs
+
$(GLOBJ)gdevtfnx.$(OBJ) : $(GLSRC)gdevtfnx.c $(PDEVH) $(gdevtifs_h)
$(GLCC) $(GLO_)gdevtfnx.$(OBJ) $(C_) $(GLSRC)gdevtfnx.c
Index: src/msvc32.mak
===================================================================
RCS file: /cvs/ghostscript/gs/src/msvc32.mak,v
retrieving revision 1.52
diff -C2 -r1.52 msvc32.mak
*** src/msvc32.mak 14 Dec 2003 01:07:17 -0000 1.52
--- src/msvc32.mak 11 Jan 2004 23:41:08 -0000
***************
*** 518,522 ****
DEVICE_DEVS9=$(DD)pbm.dev $(DD)pbmraw.dev $(DD)pgm.dev $(DD)pgmraw.dev
$(DD)pgnm.dev $(DD)pgnmraw.dev $(DD)pkmraw.dev
DEVICE_DEVS10=$(DD)tiffcrle.dev $(DD)tiffg3.dev $(DD)tiffg32d.dev
$(DD)tiffg4.dev $(DD)tifflzw.dev $(DD)tiffpack.dev
! DEVICE_DEVS11=$(DD)bmpmono.dev $(DD)bmpgray.dev $(DD)bmp16.dev
$(DD)bmp256.dev $(DD)bmp16m.dev $(DD)tiff12nc.dev $(DD)tiff24nc.dev
DEVICE_DEVS12=$(DD)psmono.dev $(DD)bit.dev $(DD)bitrgb.dev
$(DD)bitcmyk.dev
DEVICE_DEVS13=$(DD)pngmono.dev $(DD)pnggray.dev $(DD)png16.dev
$(DD)png256.dev $(DD)png16m.dev $(DD)pngalpha.dev
--- 518,522 ----
DEVICE_DEVS9=$(DD)pbm.dev $(DD)pbmraw.dev $(DD)pgm.dev $(DD)pgmraw.dev
$(DD)pgnm.dev $(DD)pgnmraw.dev $(DD)pkmraw.dev
DEVICE_DEVS10=$(DD)tiffcrle.dev $(DD)tiffg3.dev $(DD)tiffg32d.dev
$(DD)tiffg4.dev $(DD)tifflzw.dev $(DD)tiffpack.dev
! DEVICE_DEVS11=$(DD)bmpmono.dev $(DD)bmpgray.dev $(DD)bmp16.dev
$(DD)bmp256.dev $(DD)bmp16m.dev $(DD)tiff12nc.dev $(DD)tiff24nc.dev
$(DD)tiff32cmyk.dev
DEVICE_DEVS12=$(DD)psmono.dev $(DD)bit.dev $(DD)bitrgb.dev
$(DD)bitcmyk.dev
DEVICE_DEVS13=$(DD)pngmono.dev $(DD)pnggray.dev $(DD)png16.dev
$(DD)png256.dev $(DD)png16m.dev $(DD)pngalpha.dev