Image Demosaicking with Contour Stencils
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Macros | Functions
psio.c File Reference

Postscript level-2.0 file writing. More...

#include "psio.h"
Include dependency graph for psio.c:

Go to the source code of this file.

Macros

#define FILE_BUFFER_CAPACITY   (1024*4)
 Buffer size to use for PS file I/O. More...
 

Functions

FILE * PsOpen (const char *FileName, int XMin, int YMin, int XMax, int YMax)
 Start writing a new PS level-2 file. More...
 
int PsClose (FILE *File)
 Finish writing a PS file. More...
 
int PsSetDistillerParams (FILE *File, const char *Params)
 Set distiller parameters for PDF conversion. More...
 
int PsWriteGrayImage (FILE *File, const uint8_t *Image, int Width, int Height)
 Writes a grayscale image to a PS file. More...
 
int PsWriteColorImage (FILE *File, const uint8_t *Image, int Width, int Height)
 Writes an RGB color image to a PS file. More...
 

Detailed Description

Postscript level-2.0 file writing.

Author
Pascal Getreuer getre.nosp@m.uer@.nosp@m.gmail.nosp@m..com

Copyright (c) 2010-2011, Pascal Getreuer All rights reserved.

This program is free software: you can use, modify and/or redistribute it under the terms of the simplified BSD License. You should have received a copy of this license along this program. If not, see http://www.opensource.org/licenses/bsd-license.html.

Definition in file psio.c.

Macro Definition Documentation

#define FILE_BUFFER_CAPACITY   (1024*4)

Buffer size to use for PS file I/O.

Definition at line 19 of file psio.c.

Function Documentation

int PsClose ( FILE *  File)

Finish writing a PS file.

Parameters
Filethe stdio file handle
Returns
1 on success, 0 on failure

Issues the "showpage" command and closes the file.

Definition at line 70 of file psio.c.

Here is the caller graph for this function:

FILE* PsOpen ( const char *  FileName,
int  XMin,
int  YMin,
int  XMax,
int  YMax 
)

Start writing a new PS level-2 file.

Parameters
FileNamethe PS file name
XMin,YMin,XMax,YMaxthe viewport
Returns
FILE* stdio file handle on success, NULL on failure

Creates file FileName and writes a PS level 2 header with bounding box (0, 0, XMax-Xmin, YMax-YMin). The canvas is translated if XMin or YMin is nonzero.

Definition at line 32 of file psio.c.

Here is the caller graph for this function:

int PsSetDistillerParams ( FILE *  File,
const char *  Params 
)

Set distiller parameters for PDF conversion.

Parameters
Filethe stdio file handle
Paramdistiller parameters string
Returns
1 on success, 0 on failure

If the PS file is converted to PDF, the distiller parameters can be used for example to specifiy the image compression. The parameters

"/AutoFilterColorImages false /ColorImageFilter /FlateEncode"

instruct that color images are to be losslessly compressed with deflate. That is, the color image data in the PS will be preserved exactly in the conversion to PDF. The analogous parameters for grayscale images are

"/AutoFilterGrayImages false /GrayImageFilter /FlateEncode"

Alternatively, the quality with lossy DCT compression can be controlled as

"/ColorACSImageDict << /QFactor 0.15 /Blend 1 /ColorTransform 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >>"

where a smaller quantization factor ("QFactor") implies higher quality and larger file size. The QFactor value 0.15 above is equivalent to "Maximum Quality" in Adobe Distiller.

This function should be called immediately after PsOpen.

Definition at line 110 of file psio.c.

Here is the caller graph for this function:

int PsWriteColorImage ( FILE *  File,
const uint8_t *  Image,
int  Width,
int  Height 
)

Writes an RGB color image to a PS file.

Parameters
Filethe stdio file handle to write to
Imageinterleaved RGB color image data
Width,Heightthe image dimensions
Returns
1 on success, 0 on failure

The image is plotted on the canvas in the rectangle [0,Width] x [0,Height] where the lower-left corner is at the origin. This routine only writes the image data. PsOpen should be called first, then this routine and other drawing commands, and finally PsClose. If the PS file will be converted to PDF, use PsSetDistillerParams to control how the image will be recompressed.

For relative simplicity, the image data is written uncompressed in ASCII85 encoding. The file size is approximately 25% larger than in the PPM file format.

Definition at line 260 of file psio.c.

Here is the caller graph for this function:

int PsWriteGrayImage ( FILE *  File,
const uint8_t *  Image,
int  Width,
int  Height 
)

Writes a grayscale image to a PS file.

Parameters
Filethe PS file handle to write to
Imagegrayscale image data
Width,Heightthe image dimensions
Returns
1 on success, 0 on failure

The image is plotted on the canvas in the rectangle [0,Width] x [0,Height] where the lower-left corner is at the origin. This routine only writes the image data. PsOpen should be called first, then this routine and other drawing commands, and finally PsClose. If the PS file will be converted to PDF, use PsSetDistillerParams to control how the image will be recompressed.

For relative simplicity, the image data is written uncompressed in ASCII85 encoding. The file size is approximately 25% larger than in the PGM file format.

Definition at line 215 of file psio.c.