JWS C Library
C language utility library
jiff.c File Reference

JWS image file format. More...

#include <jwsc/config.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <inttypes.h>
#include "jwsc/base/bits.h"
#include "jwsc/image/jiff.h"
Include dependency graph for jiff.c:

Go to the source code of this file.

Defines

#define HEADER_SIZE   64
 Size (in 4-byte words) of the JIFF header.
#define DEFAULT_JIFF_COLORSPACE   JIFF_RGB
 Default colorspace.
#define DEFAULT_JIFF_DEPTH   JIFF_8_BIT
 Default channel depth.
#define DEFAULT_JIFF_TYPE   JIFF_INTEGER
 Default channel type.
#define DEFAULT_JIFF_RED_W   0.3f
 Default red channel averaging weight for grayscale conversion.
#define DEFAULT_JIFF_GREEN_W   0.59f
 Default green channel averaging weight for grayscale conversion.
#define DEFAULT_JIFF_BLUE_W   0.11f
 Default blue channel averaging weight for grayscale conversion.

Functions

void init_jiff_attributes (JIFF_attributes *attrs)
 Initializes a JIFF_attributes with defaults values.
read_image_as_jiff

Reads a JIFF image from a file.

Errorread_image_as_jiff_f (Image_f **img_out, const char *fname)
 Reads an Image_f from a JIFF image file.
write_image_as_jiff

Writes a JIFF image to a file.

Errorwrite_image_as_jiff_f (const Image_f *img, const char *fname, const JIFF_attributes *attrs)
 Writes an Image_f to a JIFF image file.

Detailed Description

JWS image file format.

Author:
Joseph Schlecht
License:
Creative Commons BY-NC-SA 3.0

Specifies an integer or floating point image with grayscale or RGB channels.

Definition in file jiff.c.


Define Documentation

#define HEADER_SIZE   64

Size (in 4-byte words) of the JIFF header.

Definition at line 65 of file jiff.c.

#define DEFAULT_JIFF_COLORSPACE   JIFF_RGB

Default colorspace.

Definition at line 68 of file jiff.c.

#define DEFAULT_JIFF_DEPTH   JIFF_8_BIT

Default channel depth.

Definition at line 71 of file jiff.c.

#define DEFAULT_JIFF_TYPE   JIFF_INTEGER

Default channel type.

Definition at line 74 of file jiff.c.

#define DEFAULT_JIFF_RED_W   0.3f

Default red channel averaging weight for grayscale conversion.

Definition at line 77 of file jiff.c.

#define DEFAULT_JIFF_GREEN_W   0.59f

Default green channel averaging weight for grayscale conversion.

Definition at line 80 of file jiff.c.

#define DEFAULT_JIFF_BLUE_W   0.11f

Default blue channel averaging weight for grayscale conversion.

Definition at line 83 of file jiff.c.


Function Documentation

void init_jiff_attributes ( JIFF_attributes attrs)

Initializes a JIFF_attributes with defaults values.

Parameters:
attrsAttributes to initialize.

Definition at line 87 of file jiff.c.

Error* read_image_as_jiff_f ( Image_f **  img_out,
const char *  fname 
)

Reads an Image_f from a JIFF image file.

Parameters:
img_outResult parameter. If *img_out is NULL, an image is allocated; otherwise its space is re-used.
fnameName of the image file to read.
Returns:
On success, NULL is returned. On error, an Error is returned and *img_out is freed and set to NULL.
  • ERROR_IO Could not read jiff image from fname.

Definition at line 117 of file jiff.c.

Error* write_image_as_jiff_f ( const Image_f img,
const char *  fname,
const JIFF_attributes attrs 
)

Writes an Image_f to a JIFF image file.

Parameters:
imgImage to write.
fnameName of the image file to write to.
attrsJIFF file attributes.
Returns:
On success, NULL is returned. On error, an Error is returned.
  • ERROR_IO Could not write an image to fname.

Definition at line 359 of file jiff.c.