corona  1.0.2
Namespaces | Classes | Typedefs | Enumerations | Functions
corona Namespace Reference

Namespaces

namespace  hidden
 

PRIVATE API - for internal use only.


Classes

struct  FormatDesc
class  DLLInterface
class  DLLImplementation
class  Image
class  File
class  FileFormatDesc
 Describes a file format that Corona supports. More...
class  CFile
class  MemoryFile
struct  Header
struct  InternalStruct
struct  iwrite_mgr
class  SimpleImage
class  auto_array
struct  RGB
struct  RGBA
struct  BGR
struct  BGRA

Typedefs

typedef unsigned char byte
typedef unsigned short u16
typedef unsigned long u32

Enumerations

enum  FileFormat {
  FF_AUTODETECT = 0x0100, FF_PNG = 0x0101, FF_JPEG = 0x0102, FF_PCX = 0x0103,
  FF_BMP = 0x0104, FF_TGA = 0x0105, FF_GIF = 0x0106
}
enum  PixelFormat {
  PF_DONTCARE = 0x0200, PF_R8G8B8A8 = 0x0201, PF_R8G8B8 = 0x0202, PF_I8 = 0x0203,
  PF_B8G8R8A8 = 0x0204, PF_B8G8R8 = 0x0205
}
enum  CoordinateAxis { CA_X = 0x0001, CA_Y = 0x0002 }

Functions

ImageExpandPalette (Image *image)
FormatDescGetDescription (PixelFormat format)
bool ConvertPixels (byte *out, PixelFormat out_format, const byte *in, PixelFormat in_format, int pixel_count)
ImageDirectConversion (Image *image, PixelFormat target_format)
const char * GetVersion ()
FileFormatDesc ** GetSupportedReadFormats ()
FileFormatDesc ** GetSupportedWriteFormats ()
ImageCreateImage (int width, int height, PixelFormat format, void *pixels=0)
ImageCreateImage (int width, int height, PixelFormat format, int palette_size, PixelFormat palette_format)
ImageCloneImage (Image *source, PixelFormat format=PF_DONTCARE)
ImageOpenImage (const char *filename, PixelFormat pixel_format=PF_DONTCARE, FileFormat file_format=FF_AUTODETECT)
ImageOpenImage (const std::string &filename, PixelFormat pixel_format=PF_DONTCARE, FileFormat file_format=FF_AUTODETECT)
 For convenience. Accepts a std::string.
ImageOpenImage (File *file, PixelFormat pixel_format=PF_DONTCARE, FileFormat file_format=FF_AUTODETECT)
ImageOpenImage (const char *filename, FileFormat file_format, PixelFormat pixel_format=PF_DONTCARE)
 For compatibility. This function may be deprecated.
ImageOpenImage (File *file, FileFormat file_format, PixelFormat pixel_format=PF_DONTCARE)
 For compatibility. This function may be deprecated.
bool SaveImage (const char *filename, FileFormat file_format, Image *image)
bool SaveImage (const std::string &filename, FileFormat file_format, Image *image)
 For convenience. Accepts a std::string.
bool SaveImage (File *file, FileFormat file_format, Image *image)
ImageConvertImage (Image *source, PixelFormat format)
ImageConvertPalette (Image *source, PixelFormat palette_format)
ImageFlipImage (Image *source, int coordinate_axis)
FileOpenFile (const char *filename, bool writeable)
FileCreateMemoryFile (const void *buffer, int size)
int GetPixelSize (PixelFormat format)
bool IsDirect (PixelFormat format)
bool IsPalettized (PixelFormat format)
int GetPaletteSize (PixelFormat format)
int getNextPowerOfTwo (int value)
ImageOpenBMP (File *file)
ImageOpenJPEG (File *file)
ImageOpenPCX (File *file)
ImageOpenPNG (File *file)
ImageOpenTGA (File *file)
ImageOpenGIF (File *file)
bool ReadHeader (File *file, Header &h)
bool ReadInfoHeader (File *file, Header &h)
bool ReadPalette (File *file, Header &h)
ImageDecodeBitmap (File *file, const Header &h)
int count_right_zeroes (u32 n)
int count_ones (u32 n)
bool advance (int &x, int &y, const Header &h)
ImageReadBitmap1 (const byte *raster_data, const Header &h)
ImageReadBitmap4 (const byte *raster_data, const Header &h)
ImageReadBitmapRLE4 (const byte *raster_data, const Header &h)
ImageReadBitmap8 (const byte *raster_data, const Header &h)
ImageReadBitmapRLE8 (const byte *raster_data, const Header &h)
ImageReadBitmap16 (const byte *raster_data, const Header &h)
ImageReadBitmap24 (const byte *raster_data, const Header &h)
ImageReadBitmap32 (const byte *raster_data, const Header &h)
int InputFunc (GifFileType *gif, GifByteType *bytes, int size)
void JPEG_init_source (j_decompress_ptr cinfo)
boolean JPEG_fill_input_buffer (j_decompress_ptr cinfo)
void JPEG_skip_input_data (j_decompress_ptr cinfo, long num_bytes)
void JPEG_term_source (j_decompress_ptr cinfo)
void JPEG_error_exit (j_common_ptr cinfo)
void JPEG_emit_message (j_common_ptr cinfo, int msg_level)
bool ReadScanline (File *file, int scansize, byte *scanline)
void PNG_read_function (png_structp png_ptr, png_bytep data, png_size_t length)
void PNG_warning_function (png_structp png_ptr, png_const_charp error)
void PNG_error_function (png_structp png_ptr, png_const_charp warning)
void fill_palette (png_structp png, png_infop info, png_color palette[256])
bool SaveJPEG (File *file, Image *image)
bool SavePNG (File *file, Image *image)
bool SaveTGA (File *file, Image *image)
void JPEG_init_destination (j_compress_ptr cinfo)
boolean JPEG_empty_output_buffer (j_compress_ptr cinfo)
void JPEG_term_destination (j_compress_ptr cinfo)
void PNG_write (png_structp png_ptr, png_bytep data, png_size_t length)
void PNG_flush (png_structp png_ptr)
u16 read16_le (const byte *b)
void write16_le (byte *b, u16 value)
u16 read16_be (const byte *b)
void write16_be (byte *b, u16 value)
u32 read32_le (const byte *b)
u32 read32_be (const byte *b)

Detailed Description

Todo:
use our own longjmp instead of libpng's. this way we don't need to use PNG_SETJMP_SUPPORTED in Windows, and don't depend on png_ptr->jmpbuf in older versions of libpng.

Typedef Documentation

typedef unsigned char corona::byte

Definition at line 17 of file OpenPNG.cpp.

typedef unsigned short corona::u16

Definition at line 19 of file Types.h.

typedef unsigned long corona::u32

Definition at line 20 of file Types.h.


Enumeration Type Documentation

File formats supported for reading or writing.

Enumerator:
FF_AUTODETECT 
FF_PNG 
FF_JPEG 
FF_PCX 
FF_BMP 
FF_TGA 
FF_GIF 

Definition at line 69 of file corona.h.

Pixel format specifications. Pixel data can be packed in one of the following ways.

Enumerator:
PF_DONTCARE 

special format used when specifying a desired pixel format

PF_R8G8B8A8 

RGBA, channels have eight bits of precision

PF_R8G8B8 

RGB, channels have eight bits of precision

PF_I8 

Palettized, 8-bit indices into palette

PF_B8G8R8A8 

BGRA, channels have eight bits of precision

PF_B8G8R8 

BGR, channels have eight bits of precision

Definition at line 83 of file corona.h.

Axis specifications. The image can be flipped along the following axes.

Enumerator:
CA_X 
CA_Y 

Definition at line 97 of file corona.h.


Function Documentation

Image* corona::ExpandPalette ( Image *  image)

Definition at line 17 of file Convert.cpp.

FormatDesc* corona::GetDescription ( PixelFormat  format)

Definition at line 67 of file Convert.cpp.

bool corona::ConvertPixels ( byte out,
PixelFormat  out_format,
const byte in,
PixelFormat  in_format,
int  pixel_count 
)

Definition at line 80 of file Convert.cpp.

Image* corona::DirectConversion ( Image *  image,
PixelFormat  target_format 
)

Definition at line 114 of file Convert.cpp.

const char* corona::GetVersion ( ) [inline]

Return the Corona version string.

Returns:
Corona version information

Definition at line 392 of file corona.h.

Returns a null-terminated array of FileFormatDesc* pointers that describe the file formats Corona can read. The array is owned by Corona, so do not delete it when you are done using it.

Definition at line 402 of file corona.h.

Returns a null-terminated array of FileFormatDesc* pointers that describe the file formats Corona can write. The array is owned by Corona, so do not delete it when you are done using it.

Definition at line 411 of file corona.h.

Image* corona::CreateImage ( int  width,
int  height,
PixelFormat  format,
void *  pixels = 0 
) [inline]

Create a new, blank image with a specified width, height, and format. If pixels is specified, Corona uses them to initialize the contents of the image. Corona does *not* take ownership of the pixel memory, so the caller is responsible for cleaning up after itself. If pixels is not specified, the new image is filled with zeroes.

Parameters:
widthwidth of the new image
heightheight of the new image
formatformat the pixels are stored in, cannot be PF_DONTCARE
pixelspixel buffer used to initialize the new image
Returns:
newly created blank image

Definition at line 431 of file corona.h.

Image* corona::CreateImage ( int  width,
int  height,
PixelFormat  format,
int  palette_size,
PixelFormat  palette_format 
) [inline]

Create a new, blank image with a specified width, height, format, and palette.

Parameters:
widthwidth of image
heightheight of image
formatformat of palette indices, should be PF_I8
palette_sizenumber of colors in palette
palette_formatpixel format of palette entries

Definition at line 450 of file corona.h.

Image* corona::CloneImage ( Image *  source,
PixelFormat  format = PF_DONTCARE 
) [inline]

Create a new image from an old one. If format is specified, the new image is converted to that pixel format. If format is not specified, the new image simply uses the same format as the source. If the image could not be cloned or the pixel format is invalid, CloneImage returns 0.

Parameters:
sourceimage to clone
formatformat the new image is stored in, defaults to PF_DONTCARE
Returns:
new image cloned from the source, 0 if failure

Definition at line 474 of file corona.h.

Image* corona::OpenImage ( const char *  filename,
PixelFormat  pixel_format = PF_DONTCARE,
FileFormat  file_format = FF_AUTODETECT 
) [inline]

Opens an image from the default filesystem. This function simply forwards the call to OpenImage(file, file_format, pixel_format) with a standard C library file.

See OpenImage(fs, filename, file_format, pixel_format) for more information.

Parameters:
filenameimage filename to open
file_formatfile format the image is stored in, or FF_AUTODETECT to try all loaders
pixel_formatdesired pixel format, or PF_DONTCARE to use image's native format
Returns:
the image loaded from the disk, or 0 if it cannot be opened

Definition at line 497 of file corona.h.

Image* corona::OpenImage ( const std::string &  filename,
PixelFormat  pixel_format = PF_DONTCARE,
FileFormat  file_format = FF_AUTODETECT 
) [inline]

For convenience. Accepts a std::string.

Definition at line 508 of file corona.h.

Image* corona::OpenImage ( File *  file,
PixelFormat  pixel_format = PF_DONTCARE,
FileFormat  file_format = FF_AUTODETECT 
) [inline]

Opens an image from the specified file.

If file_format is FF_AUTODETECT, the loader tries to load each format until it finds one that succeeds. Otherwise, it tries the specific loader specified.

If pixel_format is PF_DONTCARE, the new image object has the pixel format closest to the image's format on disk. Otherwise, the pixels are converted to the specified format before the image is returned.

Parameters:
filename of the file that contains the image
file_formatfile format the image is stored in, or FF_AUTODETECT to try all loaders
pixel_formatdesired pixel format, or PF_DONTCARE to use image's native format
Returns:
the image loaded from the file, or 0 if it cannot be opened

Definition at line 536 of file corona.h.

Image* corona::OpenImage ( const char *  filename,
FileFormat  file_format,
PixelFormat  pixel_format = PF_DONTCARE 
) [inline]

For compatibility. This function may be deprecated.

Definition at line 547 of file corona.h.

Image* corona::OpenImage ( File *  file,
FileFormat  file_format,
PixelFormat  pixel_format = PF_DONTCARE 
) [inline]

For compatibility. This function may be deprecated.

Definition at line 556 of file corona.h.

bool corona::SaveImage ( const char *  filename,
FileFormat  file_format,
Image *  image 
) [inline]

Saves an image to a file in the default filesystem. This function simply calls SaveImage(file, file_format, image) with a standard C library file.

See SaveImage(fs, filename, file_format, image) for more information.

Parameters:
filenamename of the file to save the image to
file_formatfile format in which to save image. if FF_AUTODETECT, SaveImage guesses the type from the file extension
imageimage to save
Returns:
true if save succeeds, false otherwise

Definition at line 578 of file corona.h.

bool corona::SaveImage ( const std::string &  filename,
FileFormat  file_format,
Image *  image 
) [inline]

For convenience. Accepts a std::string.

Definition at line 587 of file corona.h.

bool corona::SaveImage ( File *  file,
FileFormat  file_format,
Image *  image 
) [inline]

Saves an image to the specified file. This function saves image to a file of type file_format. If file_format is not a supported output type, the function fails. As of now, Corona only supports saving images of type FF_PNG and FF_TGA.

Note:
This function may create the file even if the save does not succeed, so users of this library should remove the file after the call to SaveImage().
Parameters:
filefile in which to save the image
file_formatfile format in which to save image -- must not be FF_AUTODETECT
imageimage to save
Returns:
true if the save succeeds, false otherwise

Definition at line 612 of file corona.h.

Image* corona::ConvertImage ( Image *  source,
PixelFormat  format 
) [inline]

Converts an image from one format to another, destroying the old image. If source is 0, the function returns 0. If format is PF_DONTCARE or the source and target formats match, returns the unmodified source image. If a valid conversion is not found, ConvertImage destroys the old image and returns 0. For example, ConvertImage does not support creating a palettized image from a direct color image yet.

Parameters:
sourceimage to convert
formatdesired format -- can be PF_DONTCARE
Returns:
valid image object if conversion succeeds, 0 otherwise

Definition at line 634 of file corona.h.

Image* corona::ConvertPalette ( Image *  source,
PixelFormat  palette_format 
) [inline]

Converts the palette of a palettized image from one format to another, destroying the old image. If the source is 0, the palette_format is PF_DONTCARE, or the source and target formats match, the function returns the unmodified source image. If a valid conversion is not found or invalid inputs are given (such as a direct-color source image), this function destroys the old image and returns 0.

Parameters:
sourcepalettized image to convert
palette_formatdesired pixel format of palette
Returns:
valid image object if conversion succeeds, 0 otherwise

Definition at line 652 of file corona.h.

Image* corona::FlipImage ( Image *  source,
int  coordinate_axis 
) [inline]

Flips the pixels in the image around the given axis.

Parameters:
sourceimage to flip
coordinate_axisAxis around which to flip. Both CA_X and CA_Y can be specified by ORing them together.
Returns:
the image passed in

Definition at line 665 of file corona.h.

File* corona::OpenFile ( const char *  filename,
bool  writeable 
) [inline]

Returns a default File implementation.

Parameters:
filenamename of the file on local filesystem
writeablewhether the file can be written to

Definition at line 675 of file corona.h.

File* corona::CreateMemoryFile ( const void *  buffer,
int  size 
) [inline]

Creates a File implementation that reads from a buffer in memory. It stores a copy of the buffer that is passed in.

The File object does not take ownership of the memory buffer. When the file is destroyed, it will not free the memory.

Parameters:
bufferPointer to the beginning of the data.
sizeSize of the buffer in bytes.
Returns:
0 if size is non-zero and buffer is null. Otherwise, returns a valid File object.

Definition at line 692 of file corona.h.

int corona::GetPixelSize ( PixelFormat  format) [inline]

Returns the number of bytes needed to store a pixel of a gixen format.

Parameters:
formatThe format to query.
Returns:
Number of bytes each pixel takes, or 0 if the format is invalid.

Definition at line 703 of file corona.h.

bool corona::IsDirect ( PixelFormat  format) [inline]

Returns true if the pixel format does not require a palette; that is, if each pixel itself contains color data.

Parameters:
formatThe format to query.
Returns:
True if format is direct color, false otherwise.

Definition at line 715 of file corona.h.

bool corona::IsPalettized ( PixelFormat  format) [inline]

Returns true if the pixel format requires a palette; that is, if each pixel is an index into a separate palette.

Parameters:
formatThe format to query.
Returns:
True if format is palettized, false otherwise.

Definition at line 728 of file corona.h.

int corona::GetPaletteSize ( PixelFormat  format) [inline]

Returns the number of color entries in a palette for an image of the given format.

Parameters:
formatThe format to query.
Returns:
Number of color entries, or 0 if the format is not palettized.

Definition at line 740 of file corona.h.

int corona::getNextPowerOfTwo ( int  value)

Definition at line 23 of file MemoryFile.cpp.

Image * corona::OpenBMP ( File *  file)

Definition at line 47 of file OpenBMP.cpp.

Image * corona::OpenJPEG ( File *  file)

Definition at line 36 of file OpenJPEG.cpp.

Image * corona::OpenPCX ( File *  file)

Definition at line 69 of file OpenPCX.cpp.

Image * corona::OpenPNG ( File *  file)

Definition at line 94 of file OpenPNG.cpp.

Image * corona::OpenTGA ( File *  file)

Definition at line 11 of file OpenTGA.cpp.

Image * corona::OpenGIF ( File *  file)

Definition at line 19 of file OpenGIF.cpp.

bool corona::ReadHeader ( File *  file,
Header &  h 
)

Definition at line 63 of file OpenBMP.cpp.

bool corona::ReadInfoHeader ( File *  file,
Header &  h 
)

Definition at line 80 of file OpenBMP.cpp.

bool corona::ReadPalette ( File *  file,
Header &  h 
)

Definition at line 177 of file OpenBMP.cpp.

Image * corona::DecodeBitmap ( File *  file,
const Header &  h 
)

Definition at line 640 of file OpenBMP.cpp.

Definition at line 153 of file OpenBMP.cpp.

int corona::count_ones ( u32  n)

Definition at line 165 of file OpenBMP.cpp.

bool corona::advance ( int &  x,
int &  y,
const Header &  h 
)

Definition at line 269 of file OpenBMP.cpp.

Image* corona::ReadBitmap1 ( const byte raster_data,
const Header &  h 
)

Definition at line 279 of file OpenBMP.cpp.

Image* corona::ReadBitmap4 ( const byte raster_data,
const Header &  h 
)

Definition at line 306 of file OpenBMP.cpp.

Image* corona::ReadBitmapRLE4 ( const byte raster_data,
const Header &  h 
)

Definition at line 333 of file OpenBMP.cpp.

Image* corona::ReadBitmap8 ( const byte raster_data,
const Header &  h 
)

Definition at line 453 of file OpenBMP.cpp.

Image* corona::ReadBitmapRLE8 ( const byte raster_data,
const Header &  h 
)

Definition at line 473 of file OpenBMP.cpp.

Image* corona::ReadBitmap16 ( const byte raster_data,
const Header &  h 
)

Definition at line 574 of file OpenBMP.cpp.

Image* corona::ReadBitmap24 ( const byte raster_data,
const Header &  h 
)

Definition at line 600 of file OpenBMP.cpp.

Image* corona::ReadBitmap32 ( const byte raster_data,
const Header &  h 
)

Definition at line 619 of file OpenBMP.cpp.

int corona::InputFunc ( GifFileType *  gif,
GifByteType *  bytes,
int  size 
)

Definition at line 14 of file OpenGIF.cpp.

void corona::JPEG_init_source ( j_decompress_ptr  cinfo)

Definition at line 132 of file OpenJPEG.cpp.

boolean corona::JPEG_fill_input_buffer ( j_decompress_ptr  cinfo)

Definition at line 138 of file OpenJPEG.cpp.

void corona::JPEG_skip_input_data ( j_decompress_ptr  cinfo,
long  num_bytes 
)

Definition at line 158 of file OpenJPEG.cpp.

void corona::JPEG_term_source ( j_decompress_ptr  cinfo)

Definition at line 172 of file OpenJPEG.cpp.

void corona::JPEG_error_exit ( j_common_ptr  cinfo)

Definition at line 178 of file OpenJPEG.cpp.

void corona::JPEG_emit_message ( j_common_ptr  cinfo,
int  msg_level 
)

Definition at line 185 of file OpenJPEG.cpp.

bool corona::ReadScanline ( File *  file,
int  scansize,
byte scanline 
)

Definition at line 37 of file OpenPCX.cpp.

void corona::PNG_read_function ( png_structp  png_ptr,
png_bytep  data,
png_size_t  length 
)

Definition at line 22 of file OpenPNG.cpp.

void corona::PNG_warning_function ( png_structp  png_ptr,
png_const_charp  error 
)

Definition at line 33 of file OpenPNG.cpp.

void corona::PNG_error_function ( png_structp  png_ptr,
png_const_charp  warning 
)

Definition at line 39 of file OpenPNG.cpp.

void corona::fill_palette ( png_structp  png,
png_infop  info,
png_color  palette[256] 
)

Definition at line 51 of file OpenPNG.cpp.

bool corona::SaveJPEG ( File *  file,
Image *  image 
)

Definition at line 38 of file SaveJPEG.cpp.

bool corona::SavePNG ( File *  file,
Image *  image 
)

Definition at line 20 of file SavePNG.cpp.

bool corona::SaveTGA ( File *  file,
Image *  image 
)

Definition at line 15 of file SaveTGA.cpp.

void corona::JPEG_init_destination ( j_compress_ptr  cinfo)

Definition at line 109 of file SaveJPEG.cpp.

boolean corona::JPEG_empty_output_buffer ( j_compress_ptr  cinfo)

Definition at line 121 of file SaveJPEG.cpp.

void corona::JPEG_term_destination ( j_compress_ptr  cinfo)

Definition at line 134 of file SaveJPEG.cpp.

void corona::PNG_write ( png_structp  png_ptr,
png_bytep  data,
png_size_t  length 
)

Definition at line 9 of file SavePNG.cpp.

void corona::PNG_flush ( png_structp  png_ptr)

Definition at line 16 of file SavePNG.cpp.

u16 corona::read16_le ( const byte b) [inline]

Definition at line 71 of file Utility.h.

void corona::write16_le ( byte b,
u16  value 
) [inline]

Definition at line 75 of file Utility.h.

u16 corona::read16_be ( const byte b) [inline]

Definition at line 80 of file Utility.h.

void corona::write16_be ( byte b,
u16  value 
) [inline]

Definition at line 84 of file Utility.h.

u32 corona::read32_le ( const byte b) [inline]

Definition at line 89 of file Utility.h.

u32 corona::read32_be ( const byte b) [inline]

Definition at line 93 of file Utility.h.