Harlequin RIP SDK

PNG raster output file functions. More...

#include "hhrsdk.h"
#include "skintest.h"
#include "zlib.h"
#include "pngrast.h"
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>

Functions

 API_VERSIONED (sw_libpng_api, LIBPNG_API_VERSION)
 
static void * pngrast_alloc (size_t cbSize, HqBool fZero)
 Allocate memory using MemAlloc, falling back on malloc if necessary. More...
 
static void pngrast_free (void *pMem)
 Release memory allocated by pngrast_alloc(). More...
 
static void PNGCBAPI png_error_callback (png_structp png, png_const_charp error_msg)
 
static void PNGCBAPI png_warning_callback (png_structp png, png_const_charp warning_msg)
 
static void *PNGCBAPI png_malloc_callback (png_structp png, png_size_t size)
 
static void PNGCBAPI png_free_callback (png_structp png, png_voidp mem)
 
static void PNGCAPI png_longjmp_callback (jmp_buf jmpbuf, int val)
 
static RASTER_result PNG_RASTER_start (void *pJobContext, RasterDescription *rd, RASTER_handle *handlep)
 
static RASTER_result PNG_RASTER_write_data (void *pJobContext, RASTER_handle rh, RasterDescription *rd, void *data, int32 topline, int32 lines, int32 bytesperline, int32 channel)
 
static RASTER_result PNG_RASTER_finish (void *pJobContext, RASTER_handle *handlep, RasterDescription *rd, RASTER_result result)
 
HqBool PNG_RegisterHandlers (void)
 Register the raster backend and event handlers. More...
 

Detailed Description

PNG raster output file functions.

This file implements an example to output data from the core RIP as a PNG file.

Function Documentation

◆ API_VERSIONED()

API_VERSIONED ( sw_libpng_api  ,
LIBPNG_API_VERSION   
)

< The output device instance.

< File descriptor for output device.

< PS filename minus any device prefix.

< Exclusive-or for each channel for RGB

< Pixel-interleaved raster data

< W,H of raster data

< Output bytes per line in received raster.

< Number of channels

< Interleaving mode

◆ png_error_callback()

static void PNGCBAPI png_error_callback ( png_structp  png,
png_const_charp  error_msg 
)
static

Callback function to report libpng errors in assert builds.

Parameters
[in]pnghandle to PNG data
[in]error_msgstring containing error message

◆ png_free_callback()

static void PNGCBAPI png_free_callback ( png_structp  png,
png_voidp  mem 
)
static

Callback function to free libpng memory back.

Parameters
[in]pnghandle to PNG data
[in]memPointer to memory to be freed

◆ png_longjmp_callback()

static void PNGCAPI png_longjmp_callback ( jmp_buf  jmpbuf,
int  val 
)
static

Callback to override default longjmp to ensure jump buf is 16 byte aligned for Windows 64 (this is done by ensuring the struct malloc is 16-byte aligned).

Parameters
[in]jmpbufhandle to PNG jump buf
[in]valInteger argument to longjump

◆ png_malloc_callback()

static void* PNGCBAPI png_malloc_callback ( png_structp  png,
png_size_t  size 
)
static

Callback function to allocate libpng memory.

Parameters
[in]pnghandle to PNG data
[in]sizenumber of bytes to allocate
Returns
pointer to allocated memory

◆ PNG_RASTER_finish()

static RASTER_result PNG_RASTER_finish ( void *  pJobContext,
RASTER_handle handlep,
RasterDescription rd,
RASTER_result  result 
)
static

RASTER_finish callback

See also
RASTER_FINISH_EX in rasthand.h

◆ PNG_RASTER_start()

static RASTER_result PNG_RASTER_start ( void *  pJobContext,
RasterDescription rd,
RASTER_handle handlep 
)
static

RASTER_start callback

See also
RASTER_START_EX in rasthand.h

◆ PNG_RASTER_write_data()

static RASTER_result PNG_RASTER_write_data ( void *  pJobContext,
RASTER_handle  rh,
RasterDescription rd,
void *  data,
int32  topline,
int32  lines,
int32  bytesperline,
int32  channel 
)
static

RASTER_write_data callback

See also
RASTER_WRITE_DATA_EX in rasthand.h

◆ PNG_RegisterHandlers()

HqBool PNG_RegisterHandlers ( void  )

Register the raster backend and event handlers.

Return values
TRUEif successful;
FALSEotherwise.

◆ png_warning_callback()

static void PNGCBAPI png_warning_callback ( png_structp  png,
png_const_charp  warning_msg 
)
static

Callback function to report libpng warnings in assert builds.

Parameters
[in]pnghandle to PNG data
[in]warning_msgstring containing warning message

◆ pngrast_alloc()

static void* pngrast_alloc ( size_t  cbSize,
HqBool  fZero 
)
static

Allocate memory using MemAlloc, falling back on malloc if necessary.

This routine will attempt to allocate memory using a normal malloc() in the event of a failure when calling MemAlloc(). This behaviour is not generally desired, but is valid for the uses of this backend.

Align the memory allocation to 16 bytes, because Windows 64 requires the jmp_buf allocated in the PNG structure to be aligned. Extra space is allocated at the beginning of the memory block to hold header information (hidden to the caller) signifying which allocation method was used, and what the offset from the allocated pointer is.

Parameters
cbSizeThe number of bytes to allocate.
fZeroIf TRUE the memory is zeroed.
Returns
A pointer to the allocated memory, or NULL on failure.

◆ pngrast_free()

static void pngrast_free ( void *  pMem)
static

Release memory allocated by pngrast_alloc().

Parameters
pMemThe memory to release.