This file implements a TIFF writer for the LE product, using Sam Leffler's libtiff for output. Some attempt is made to re-map channels onto well-supported TIFF modes, but the support for more esoteric TIFF options is poor at best, so files generated may not load in viewers. More...
#include "hhrsdk.h"
#include "skintest.h"
#include "debugpage.h"
#include "rmreport.h"
#include "hvdreport.h"
#include "libtiffrast.h"
#include <string.h>
#include "tiffio.h"
Data Structures | |
struct | LIBTIFF_RASTER_handle |
Holds all of the state required to output a page of raster with libtiff. More... | |
struct | ImageResource |
Image resource structure for use in Photoshop tag. More... | |
struct | DisplayInfo |
DisplayInfo structure used in Image resource 0x3ff. More... | |
Macros | |
#define | LIBTIFF_FILEFORMAT "%f-%p%?-N%?-S%?-T.tif" |
The default file name format for files produced by the libtiff output back end. | |
#define | LIBTIFF_ELEMENT_FILEFORMAT "%i%?-N%?-S%?-03r.tif" |
The file name format for all eHVD element output files produced by the libtiff output back end. More... | |
#define | INKSET_INKNAMES 2 |
Typedefs | |
typedef struct LIBTIFF_RASTER_handle | LIBTIFF_RASTER_handle |
Holds all of the state required to output a page of raster with libtiff. More... | |
typedef struct ImageResource | ImageResource |
Image resource structure for use in Photoshop tag. | |
typedef struct DisplayInfo | DisplayInfo |
DisplayInfo structure used in Image resource 0x3ff. More... | |
Functions | |
static tmsize_t | libtiff_read (thandle_t thandle, tdata_t data, tmsize_t size) |
Adapts reading functionality from the Core Device Interface to the libtiff interface. | |
static tmsize_t | libtiff_write (thandle_t thandle, tdata_t data, tmsize_t size) |
Adapts writing functionality from the Core Device Interface to the libtiff interface. | |
static toff_t | libtiff_seek (thandle_t thandle, toff_t where, int whence) |
Adapts seeking functionality from the Core Device Interface to the libtiff interface. | |
static int | libtiff_close (thandle_t thandle) |
Adapts closing functionality from the Core Device Interface to the libtiff interface. More... | |
static toff_t | libtiff_size (thandle_t thandle) |
Adapts the size query function from the Core Device Interface to the libtiff interface. | |
static int32 | mapChannels (const char *channelnames[], uint32 nchannelnames, LIBTIFF_RASTER_handle *handle, RasterDescription *rd) |
Check mapping of RIP channels to TIFF channels. More... | |
static int32 | mapIdentity (LIBTIFF_RASTER_handle *handle, RasterDescription *rd) |
Map RIP channels directly to TIFF channels. | |
static HqBool | flushScanlines (LIBTIFF_RASTER_handle *handle) |
Flush any data buffered before writing a whole strip at a time. | |
static HqBool | writeScratchLines (LIBTIFF_RASTER_handle *handle, RasterDescription *rd, int32 topline, int32 limitline, int32 channel, uint8 polarity) |
Write strips or scanlines from the scratch buffer, with the selected polarity, optimising re-use of compressed strip data if possible. | |
static HqBool | writeBackgroundForUnmappedChannels (LIBTIFF_RASTER_handle *handle, RasterDescription *rd, uint8 polarity) |
Writes data for every TIFF output channel that doesn't have a corresponding channel in the raster generated by the RIP. More... | |
static void | setupImageResource (ImageResource *ir, uint16 id, size_t length) |
Set up an Image Resource header. | |
static HqBool | setupScratchStrip (LIBTIFF_RASTER_handle *handle, RasterDescription *rd, int32 nBitsPerSample, int32 nchannels) |
Set up a scratch strip buffer for use by channel shuffling, expansion, inversion, TrimPage and unmapped channels. | |
static HqBool | setupIFD (LIBTIFF_RASTER_handle *handle, RasterDescription *rd) |
Set up an IFD (image file directory) for TIFF. This is a separate function, so that multiple TIFFWriteDirectory calls can be made for frame-interleaved output. After each call, setupIFD() will be called for the next frame. More... | |
RASTER_result | LIBTIFF_COMMON_RASTER_start (void *pJobContext, uint8 *filename, RasterDescription *rd, RASTER_handle *handlep, HqBool compress, HqBool fAllowExpandNTo8, HqBool fPhotoshopFriendly, HVD_monitor *monitor) |
static HVD_result | libtiff_hvd_output_page (HVD_page_output *page) |
Callback function for libHVD to output an HVD page. More... | |
This file implements a TIFF writer for the LE product, using Sam Leffler's libtiff for output. Some attempt is made to re-map channels onto well-supported TIFF modes, but the support for more esoteric TIFF options is poor at best, so files generated may not load in viewers.
The TIFF writer supports the following parameters for configuration:
The value of DEMOTIFF
is supported for PageBufferType
and -o
for backwards compatibility. Its use is deprecated. It uses the LIBTIFF
raster backend, but CompressionType
defaults to (None)
and ExpandTo8Bit
defaults to false
.
Similarly the value of LIBTIFFPS
is supported for PageBufferType
and -o
for backwards compatibility. Its use is deprecated. It uses the LIBTIFF
raster backend, but PhotoshopFriendly
defaults to true
.
#define INKSET_INKNAMES 2 |
tiff.h doesn't define this
#define LIBTIFF_ELEMENT_FILEFORMAT "%i%?-N%?-S%?-03r.tif" |
The file name format for all eHVD element output files produced by the libtiff output back end.
This file name format cannot be overridden from the command line.
typedef struct DisplayInfo DisplayInfo |
DisplayInfo structure used in Image resource 0x3ff.
See Appendix A of Photoshop API Guide.pdf
typedef struct LIBTIFF_RASTER_handle LIBTIFF_RASTER_handle |
Holds all of the state required to output a page of raster with libtiff.
An instance of this structure is created by LIBTIFF_RASTER_start(), and then passed back as an opaque RASTER_handle pointer. It is subsequently passed back into each LIBTIFF_RASTER_write_data() call, and finally to LIBTIFF_RASTER_finish(). Both of those functions cast the opaque pointer back to LIBTIFF_RASTER_handle, and LIBTIFF_RASTER_finish() will end by freeing the structure. In a multi-page job, no state is remembered between pages. The output of each page is a completely separate activity, implemented as a separate set of calls to the libtiff library.
Like most raster handling functions, the libtiff back-end makes use of the Core RIP Device Interface (see swdevice.h), so that the bytes of output data can be sent to any destination. The DEVICELIST and DEVICE_FILEDESCRIPTOR members refer to the output destination.
|
static |
Adapts closing functionality from the Core Device Interface to the libtiff interface.
Nothing is actually done by this function, because the output device file descriptor is actually closed by LIBTIFF_RASTER_finish().
RASTER_result LIBTIFF_COMMON_RASTER_start | ( | void * | pJobContext, |
uint8 * | filename, | ||
RasterDescription * | rd, | ||
RASTER_handle * | handlep, | ||
HqBool | compress, | ||
HqBool | fAllowExpandNTo8, | ||
HqBool | fPhotoshopFriendly, | ||
struct HVD_monitor * | hvdMonitor | ||
) |
Common raster start function called from LIBTIFF, LIBTIFFPS, DEMOTIFF, FRAMETIFF, and ASYNCTIFF.
|
static |
Callback function for libHVD to output an HVD page.
[in] | page | The output page description from libHVD. |
HVD_SUCCESS | The page was output successfully |
|
static |
Check mapping of RIP channels to TIFF channels.
Contone CMYK and RGB device spaces are mapped to multiple colorants, but keeping CMYK/RGB in the first 4/3 channels of the TIFF, to make viewing easy. Other channels are mapped to Extrasamples. This routine sets up a channel map and the Extrasamples array in the raster handle, and returns the total number of channels required. It also sets the "shuffle" field in the raster handle, which indicates if pixels need shuffling.
|
static |
Set up an IFD (image file directory) for TIFF. This is a separate function, so that multiple TIFFWriteDirectory calls can be made for frame-interleaved output. After each call, setupIFD() will be called for the next frame.
< tiff.h doesn't define this
< tiff.h doesn't define this
< tiff.h doesn't define this
< tiff.h doesn't define this
< tiff.h doesn't define this
|
static |
Writes data for every TIFF output channel that doesn't have a corresponding channel in the raster generated by the RIP.
Called from setupIFD() for frame-interleaved and band-interleaved cases.
handle | The TIFF output descriptor. |
rd | The RIP's raster descriptor. |
polarity | The data to write in the unmapped channels (0 or 0xff) |
TRUE
if the function succeeds, otherwise FALSE
.