Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

vuPPM Class Reference

This class will read/write PPM P6 files into/from a vuImage so that the Key Framer (and possibly others as needed) will be able to read/write Images to disk. More...

#include <vuPPMReader.h>

Collaboration diagram for vuPPM:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 vuPPM ()
 default constructor
virtual ~vuPPM ()
 destructor
bool SaveImage (char *fname, vuImage &img)
 This function will write the image stored in img to the file named fname (it will also overwrite anything in that file, so watch out).
bool SaveCompressedImage (char *fname, vuImage &img)
bool ReadImage (char *fname, vuImage &img, int readtype=0)
 This funcion will read the image stored in file fname and store it in img.
bool ReadImageFromBuffer (char *buf, vuImage &img, int readtype=0)
 To use this function, you simply have to do the following load the file into the buffer buf, then call this function, and this will set img correctly, basically, it preloads to allow for asynchronous loads in the vuKeyFrameBuffer if readtype = 1, then this will read only headers of type P6?XXXX?YYYY?ZZZZ which is mush faster than reading standard headers.
bool SaveImage (char *fname)
 This will save an image opened through OpenImage (...) which you may have edited.
bool ReadImage (char *fname)
 This will read an image opened through open image into the image stored here.
bool OpenImage (char *fname, vuImage &img)
 This will open the image located at file fname and read it into the buffer pointed to by img.
unsigned int Readnext64KB (vuImage &img)
 This will read a 64KiloByte buffer from the file and update img's buffer accordingly...
bool CloseImage ()
 This will close and save the opened image.
bool set_xy (int x, int y)
 This will set the maximum x and y values for the image stored by this object.
int get_x ()
 This will return the size of the current image in the x direction.
int get_y ()
 This will return the size of the current image in the y direction.

Private Member Functions

int ReadHeader (vuImage &img, int readtype=0)
 This function will read a header from the currently opened file and will set the vuImage img to have the correct dimensions if it is a valid header.
bool ReadCompressedImage (char *fname, vuImage &img, int readtype)
int ReadHeader (vuImage &img, char *buf, int readtype=0)
 This will read a header from buf and set the dimensions of img corresponding to what it reads.
bool WriteHeader (vuImage &img)
 This will write a header corresponding to a P6 with header information corresponding to the information required to reconstruct the image img.
bool WriteCompressedHeader (vuImage &img)
int CompressToBuffer (vuImage &img)

Private Attributes

vuImage m_Image
 This is just an image...
FILE * fp
 This is a pointer to the file that the reader has opened and is currently reading from, or writing to as the case may be.
int m_x
 This is the width of the image in pixels.
int m_y
 This is the height of the image in pixels.
int m_z
 This is the size of the file for C1 compressiones.
unsigned char * m_buf
int m_buf_size
unsigned int counter
 A stock counter to keep track of the current position this is in during a file read.

Detailed Description

This class will read/write PPM P6 files into/from a vuImage so that the Key Framer (and possibly others as needed) will be able to read/write Images to disk.

This was originally written for the vuKeyFramer so that it could precompute the images and play them back later for an animation.

Todo:
add other file type to save to which allow compression

add more suitable movie type files.

add the ability to interpret from preloaded memory buffers (so async file reads can occur and other stuff can happen before then without multiple threads).

Note that this has the code to read any P6 file, but the code to read any header has been commented out and this uses a much faster version of read where it will only read headers of the form

"P6?XXXX?YYYY?ZZZZ"

and will exhibit incorrect behaviour on other styles of headers

Definition at line 49 of file vuPPMReader.h.


Constructor & Destructor Documentation

vuPPM::vuPPM  ) 
 

default constructor

Definition at line 3 of file vuPPMReader.cpp.

References fp, m_buf, and m_buf_size.

vuPPM::~vuPPM  )  [virtual]
 

destructor

Definition at line 11 of file vuPPMReader.cpp.

References m_buf.


Member Function Documentation

bool vuPPM::CloseImage  ) 
 

This will close and save the opened image.

Definition at line 508 of file vuPPMReader.cpp.

int vuPPM::CompressToBuffer vuImage img  )  [private]
 

Definition at line 102 of file vuPPMReader.cpp.

References counter, vuImage::get_rgb(), m_buf, m_buf_size, m_x, m_y, and m_z.

Referenced by SaveCompressedImage().

Here is the call graph for this function:

int vuPPM::get_x  ) 
 

This will return the size of the current image in the x direction.

It will also return the size in the x-direction of the last image header that was successfully read in.

Definition at line 523 of file vuPPMReader.cpp.

int vuPPM::get_y  ) 
 

This will return the size of the current image in the y direction.

It will also return the size in the y-direction of the last image header that was successfully read in.

Definition at line 529 of file vuPPMReader.cpp.

bool vuPPM::OpenImage char *  fname,
vuImage img
 

This will open the image located at file fname and read it into the buffer pointed to by img.

Not working yet since it wasn't necessary to my task at hand...

Definition at line 462 of file vuPPMReader.cpp.

References counter, fp, vuImage::init(), m_x, m_y, and ReadHeader().

Here is the call graph for this function:

bool vuPPM::ReadCompressedImage char *  fname,
vuImage img,
int  readtype
[private]
 

Definition at line 217 of file vuPPMReader.cpp.

References c_64k_, counter, fp, vuImage::get_extents(), vuImage::get_rgb(), vuImage::init(), m_buf, m_buf_size, m_x, and m_y.

Referenced by ReadImage().

Here is the call graph for this function:

int vuPPM::ReadHeader vuImage img,
char *  buf,
int  readtype = 0
[private]
 

This will read a header from buf and set the dimensions of img corresponding to what it reads.

This was done so that the PPM reader could read from a buffer instead of opening the file (so that some async stuff could happen earlier).

if readtype = 1, then this will read only headers of type P6?XXXX?YYYY?ZZZZ which is mush faster than reading standard headers.

Definition at line 597 of file vuPPMReader.cpp.

References counter, IsNotNext(), IsNumber(), m_x, m_y, and m_z.

Here is the call graph for this function:

int vuPPM::ReadHeader vuImage img,
int  readtype = 0
[private]
 

This function will read a header from the currently opened file and will set the vuImage img to have the correct dimensions if it is a valid header.

This will return true if the header is valid, and false if the header is not of valid format.

Note that this contains the code to recognize all P6 files, but for speed, that code has been commented out and instead this only accepts headers of the format

P6?XXXX?YYYY?ZZZZ?

where XXXX is a 4 digit number containing the number of pixels in the image in the x direction, YYYY is similar, and ZZZZ is any four digits. Question marks simple denote any character (they should be spaces or tabs ideally, but this one doesn't care).

if readtype = 1, then this will read only headers of type P6?XXXX?YYYY?ZZZZ which is mush faster than reading standard headers.

Definition at line 703 of file vuPPMReader.cpp.

References counter, fp, IsNotNext(), IsNumber(), m_x, m_y, and m_z.

Referenced by OpenImage(), ReadImage(), and ReadImageFromBuffer().

Here is the call graph for this function:

bool vuPPM::ReadImage char *  fname  ) 
 

This will read an image opened through open image into the image stored here.

Definition at line 456 of file vuPPMReader.cpp.

bool vuPPM::ReadImage char *  fname,
vuImage img,
int  readtype = 0
 

This funcion will read the image stored in file fname and store it in img.

if readtype = 1, then this will read only headers of type P6?XXXX?YYYY?ZZZZ which is mush faster than reading standard headers.

Definition at line 339 of file vuPPMReader.cpp.

References c_64k_, counter, fp, vuImage::get_extents(), vuImage::get_rgb(), vuImage::init(), m_x, m_y, ReadCompressedImage(), and ReadHeader().

Referenced by vuKeyFramerDialog::PlayNextImage().

Here is the call graph for this function:

bool vuPPM::ReadImageFromBuffer char *  buf,
vuImage img,
int  readtype = 0
 

To use this function, you simply have to do the following load the file into the buffer buf, then call this function, and this will set img correctly, basically, it preloads to allow for asynchronous loads in the vuKeyFrameBuffer if readtype = 1, then this will read only headers of type P6?XXXX?YYYY?ZZZZ which is mush faster than reading standard headers.

Definition at line 422 of file vuPPMReader.cpp.

References byte, vuImage::get_extents(), vuImage::init(), m_x, m_y, ReadHeader(), and vuImage::set_data().

Referenced by vuKeyFramerDialog::PlayNextImage().

Here is the call graph for this function:

unsigned int vuPPM::Readnext64KB vuImage img  ) 
 

This will read a 64KiloByte buffer from the file and update img's buffer accordingly...

Definition at line 490 of file vuPPMReader.cpp.

References byte, fp, and vuImage::set_rgb().

Here is the call graph for this function:

bool vuPPM::SaveCompressedImage char *  fname,
vuImage img
 

Definition at line 18 of file vuPPMReader.cpp.

References CompressToBuffer(), fp, vuImage::get_extents(), m_x, m_y, m_z, and WriteCompressedHeader().

Here is the call graph for this function:

bool vuPPM::SaveImage char *  fname  ) 
 

This will save an image opened through OpenImage (...) which you may have edited.

Definition at line 450 of file vuPPMReader.cpp.

bool vuPPM::SaveImage char *  fname,
vuImage img
 

This function will write the image stored in img to the file named fname (it will also overwrite anything in that file, so watch out).

Definition at line 164 of file vuPPMReader.cpp.

References fp, vuImage::get_extents(), vuImage::get_rgb(), m_x, m_y, and WriteHeader().

Referenced by vuKeyFramerDialog::BurstPlayGI().

Here is the call graph for this function:

bool vuPPM::set_xy int  x,
int  y
 

This will set the maximum x and y values for the image stored by this object.

Definition at line 514 of file vuPPMReader.cpp.

References vuImage::init(), m_Image, m_x, and m_y.

Here is the call graph for this function:

bool vuPPM::WriteCompressedHeader vuImage img  )  [private]
 

Definition at line 32 of file vuPPMReader.cpp.

References fp, m_x, and m_y.

Referenced by SaveCompressedImage().

bool vuPPM::WriteHeader vuImage img  )  [private]
 

This will write a header corresponding to a P6 with header information corresponding to the information required to reconstruct the image img.

This will return true if the operation was successful, and it will return false otehrwise.

Definition at line 553 of file vuPPMReader.cpp.

References fp, m_x, and m_y.

Referenced by SaveImage().


Member Data Documentation

unsigned int vuPPM::counter [private]
 

A stock counter to keep track of the current position this is in during a file read.

Definition at line 197 of file vuPPMReader.h.

Referenced by CompressToBuffer(), OpenImage(), ReadCompressedImage(), ReadHeader(), and ReadImage().

FILE* vuPPM::fp [private]
 

This is a pointer to the file that the reader has opened and is currently reading from, or writing to as the case may be.

Definition at line 181 of file vuPPMReader.h.

Referenced by OpenImage(), ReadCompressedImage(), ReadHeader(), ReadImage(), Readnext64KB(), SaveCompressedImage(), SaveImage(), vuPPM(), WriteCompressedHeader(), and WriteHeader().

unsigned char* vuPPM::m_buf [private]
 

Definition at line 192 of file vuPPMReader.h.

Referenced by CompressToBuffer(), ReadCompressedImage(), vuPPM(), and ~vuPPM().

int vuPPM::m_buf_size [private]
 

Definition at line 193 of file vuPPMReader.h.

Referenced by CompressToBuffer(), ReadCompressedImage(), and vuPPM().

vuImage vuPPM::m_Image [private]
 

This is just an image...

should probably be removed from this...

Definition at line 177 of file vuPPMReader.h.

Referenced by set_xy().

int vuPPM::m_x [private]
 

This is the width of the image in pixels.

Definition at line 184 of file vuPPMReader.h.

Referenced by CompressToBuffer(), OpenImage(), ReadCompressedImage(), ReadHeader(), ReadImage(), ReadImageFromBuffer(), SaveCompressedImage(), SaveImage(), set_xy(), WriteCompressedHeader(), and WriteHeader().

int vuPPM::m_y [private]
 

This is the height of the image in pixels.

Definition at line 187 of file vuPPMReader.h.

Referenced by CompressToBuffer(), OpenImage(), ReadCompressedImage(), ReadHeader(), ReadImage(), ReadImageFromBuffer(), SaveCompressedImage(), SaveImage(), set_xy(), WriteCompressedHeader(), and WriteHeader().

int vuPPM::m_z [private]
 

This is the size of the file for C1 compressiones.

Definition at line 190 of file vuPPMReader.h.

Referenced by CompressToBuffer(), ReadHeader(), and SaveCompressedImage().


The documentation for this class was generated from the following files:
Generated on Wed Dec 15 21:22:01 2004 for vuVolume by  doxygen 1.3.9.1