Harlequin RIP SDK

JPEG raster output file functions. More...

#include "hhrsdk.h"
#include "skintest.h"
#include "jpegrast.h"
#include <stdio.h>
#include <setjmp.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>

Functions

static void * jpegrast_alloc (size_t cbSize, HqBool fZero)
 Allocate memory using MemAlloc, falling back on malloc if necessary. More...
 
static void jpegrast_free (void *pMem)
 Release memory allocated by jpegrast_alloc(). More...
 
static void set_output_colorspace (RasterDescription *rd, JPEG_RASTER_colorspace *pColorspace, HqBool *pScreened)
 
static RASTER_result JPEG_RASTER_start (void *pJobContext, RasterDescription *rd, RASTER_handle *handlep)
 
static RASTER_result JPEG_RASTER_write_data (void *pJobContext, RASTER_handle rh, RasterDescription *rd, void *data, int32 topline, int32 lines, int32 bytesperline, int32 channel)
 
static RASTER_result JPEG_RASTER_finish (void *pJobContext, RASTER_handle *handlep, RasterDescription *rd, RASTER_result result)
 
static RASTER_result JPEG_RASTER_job_end (void *pJobContext, RASTER_handle *handlep)
 
void JPEG_SetImageQuality (int32 quality)
 Set the quality of the JPEG image produced. More...
 
HqBool JPEG_RegisterHandlers (void)
 Register the raster backend and event handlers. More...
 

Detailed Description

JPEG raster output file functions.

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

Function Documentation

◆ JPEG_RASTER_finish()

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

RASTER_finish callback

See also
RASTER_FINISH_EX in rasthand.h

◆ JPEG_RASTER_job_end()

static RASTER_result JPEG_RASTER_job_end ( void *  pJobContext,
RASTER_handle handlep 
)
static

RASTER_job_end callback

See also
RASTER_JOB_END_EX in rasthand.h

◆ JPEG_RASTER_start()

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

RASTER_start callback

See also
RASTER_START_EX in rasthand.h

◆ JPEG_RASTER_write_data()

static RASTER_result JPEG_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

◆ JPEG_RegisterHandlers()

HqBool JPEG_RegisterHandlers ( void  )

Register the raster backend and event handlers.

Return values
TRUEif successful;
FALSEotherwise.

◆ JPEG_SetImageQuality()

void JPEG_SetImageQuality ( int32  quality)

Set the quality of the JPEG image produced.

Scale quantization tables to adjust image quality. Quality is 0 (worst) to 100 (best); default is 75 if this function is not called.

The quality value lets you trade off compressed file size against quality of the reconstructed image: the higher the quality setting, the larger the JPEG file, and the closer the output image will be to the original input. Normally you want to use the lowest quality setting (smallest file) that decompresses into something visually indistinguishable from the original image. For this purpose the quality setting should be between 50 and 95; the default of 75 is often about right. If you see defects at 75, then go up 5 or 10 counts at a time until you are happy with the output image. (The optimal setting will vary from one image to another.) A quality value of 100 will generate a quantization table of all 1's, minimizing loss in the quantization step (but there is still information loss in subsampling, as well as roundoff error). This setting is mainly of interest for experimental purposes. Quality values above about 95 are not recommended for normal use; the compressed file size goes up dramatically for hardly any gain in output image quality.

In the other direction, quality values below 50 will produce very small files of low image quality. Settings around 5 to 10 might be useful in preparing an index of a large image library, for example. Try quality 2 (or so) for some amusing Cubist effects. (Note: quality values below about 25 generate 2-byte quantization tables, which are considered optional in the JPEG standard.

Values outside the range 0-100 will be ignored and the default of 75 will be used.

◆ jpegrast_alloc()

static void* jpegrast_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.

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.

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

◆ jpegrast_free()

static void jpegrast_free ( void *  pMem)
static

Release memory allocated by jpegrast_alloc().

Parameters
pMemThe memory to release.

◆ set_output_colorspace()

static void set_output_colorspace ( RasterDescription rd,
JPEG_RASTER_colorspace *  pColorspace,
HqBool pScreened 
)
static

Set the output colorspace and clear value based on the input process space, and the colorants present in the output RasterDescription.