Signal/Geometry Processing Library (SPL)  2.0.8
pnmCodec.hpp File Reference

This file contains a PNM codec. More...

#include <SPL/config.hpp>
#include <iostream>
#include <sstream>
#include <cassert>
#include <cstdlib>

Go to the source code of this file.

Classes

struct  SPL::PnmHeader
 The header information for PNM data. More...
 

Enumerations

enum  SPL::PnmMagic
 The signature values that can appear at the start of the header. More...
 
enum  SPL::PnmType
 The type of the PNM data. More...
 
enum  SPL::PnmFmt
 The format of the PNM data (i.e., binary or text). More...
 

Functions

PnmType SPL::pnmGetType (PnmMagic magic)
 Determine the type (i.e., PGM or PPM) from the magic number. More...
 
PnmFmt SPL::pnmGetFmt (PnmMagic magic)
 Determine the format (i.e., text or binary) from magic number. More...
 
int SPL::pnmMaxValToPrec (int maxVal)
 Determine the precision from the maximum value. More...
 
int SPL::pnmGetNumComps (PnmType type)
 Get the number of components from the PNM type. More...
 
long SPL::pnmOnes (int n)
 Get an integer whose representation in binary consists of the specified number of ones. More...
 
int SPL::pnmGetHeader (std::istream &in, PnmHeader &header)
 Read a PNM header from the specified stream. More...
 
int SPL::pnmPutHeader (std::ostream &out, PnmHeader &header)
 Write a PNM header to the specified stream. More...
 
int SPL::pnmGetChar (std::istream &in)
 Read a character from the specified stream. More...
 
int SPL::pnmGetTxtBit (std::istream &in)
 Read a bit from the specified stream. More...
 
long SPL::pnmGetTxtInt (std::istream &in, bool sgnd, int &status)
 Read an integer from the specified stream. More...
 
long SPL::pnmGetBinInt (std::istream &in, int wordSize, bool sgnd, int &status)
 Read an integer from the specified stream. More...
 
int SPL::pnmPutBinInt (std::ostream &out, int wordSize, bool sgnd, long val)
 Write an integer from the specified stream. More...
 
template<class GetData >
int SPL::pnmEncode (std::ostream &outStream, int width, int height, int numComps, int maxVal, bool sgnd, GetData &getData, bool binaryFormat)
 Write data encoded in the PNM format to the specified stream. More...
 
template<class GetData >
int SPL::putData (std::ostream &out, PnmHeader &header, GetData &getData)
 Write the actual image data to a stream. More...
 
template<class Initialize >
int SPL::pnmDecode (std::istream &inStream, Initialize &initialize)
 Read data encoded in the PNM format from the specified stream. More...
 
template<class PutData >
int SPL::getData (std::istream &in, PnmHeader &header, PutData &putData)
 Read the actual image data from the specified stream. More...
 

Variables

const int SPL::pnmMaxLineLen = 80
 The maximum line length to be produced when encoding in text format. More...
 

Detailed Description

This file contains a PNM codec.

Enumeration Type Documentation

◆ PnmFmt

The format of the PNM data (i.e., binary or text).

◆ PnmMagic

The signature values that can appear at the start of the header.

◆ PnmType

The type of the PNM data.

Function Documentation

◆ getData()

template<class PutData >
int SPL::getData ( std::istream &  in,
PnmHeader header,
PutData &  putData 
)

Read the actual image data from the specified stream.

◆ pnmDecode()

template<class Initialize >
int SPL::pnmDecode ( std::istream &  inStream,
Initialize &  initialize 
)

Read data encoded in the PNM format from the specified stream.

◆ pnmEncode()

template<class GetData >
int SPL::pnmEncode ( std::ostream &  outStream,
int  width,
int  height,
int  numComps,
int  maxVal,
bool  sgnd,
GetData &  getData,
bool  binaryFormat 
)

Write data encoded in the PNM format to the specified stream.

◆ pnmGetBinInt()

long SPL::pnmGetBinInt ( std::istream &  in,
int  wordSize,
bool  sgnd,
int &  status 
)

Read an integer from the specified stream.

◆ pnmGetChar()

int SPL::pnmGetChar ( std::istream &  in)

Read a character from the specified stream.

◆ pnmGetFmt()

PnmFmt SPL::pnmGetFmt ( PnmMagic  magic)

Determine the format (i.e., text or binary) from magic number.

◆ pnmGetHeader()

int SPL::pnmGetHeader ( std::istream &  in,
PnmHeader header 
)

Read a PNM header from the specified stream.

◆ pnmGetNumComps()

int SPL::pnmGetNumComps ( PnmType  type)

Get the number of components from the PNM type.

◆ pnmGetTxtBit()

int SPL::pnmGetTxtBit ( std::istream &  in)

Read a bit from the specified stream.

◆ pnmGetTxtInt()

long SPL::pnmGetTxtInt ( std::istream &  in,
bool  sgnd,
int &  status 
)

Read an integer from the specified stream.

◆ pnmGetType()

PnmType SPL::pnmGetType ( PnmMagic  magic)

Determine the type (i.e., PGM or PPM) from the magic number.

◆ pnmMaxValToPrec()

int SPL::pnmMaxValToPrec ( int  maxVal)

Determine the precision from the maximum value.

◆ pnmOnes()

long SPL::pnmOnes ( int  n)
inline

Get an integer whose representation in binary consists of the specified number of ones.

◆ pnmPutBinInt()

int SPL::pnmPutBinInt ( std::ostream &  out,
int  wordSize,
bool  sgnd,
long  val 
)

Write an integer from the specified stream.

◆ pnmPutHeader()

int SPL::pnmPutHeader ( std::ostream &  out,
PnmHeader header 
)

Write a PNM header to the specified stream.

◆ putData()

template<class GetData >
int SPL::putData ( std::ostream &  out,
PnmHeader header,
GetData &  getData 
)

Write the actual image data to a stream.

Variable Documentation

◆ pnmMaxLineLen

const int SPL::pnmMaxLineLen = 80

The maximum line length to be produced when encoding in text format.