view release on metacpan or search on metacpan
src/Source/FreeImage.h view on Meta::CPAN
FI_STRUCT (FITAG) { void *data; };
// File IO routines ---------------------------------------------------------
#ifndef FREEIMAGE_IO
#define FREEIMAGE_IO
typedef void* fi_handle;
typedef unsigned (DLL_CALLCONV *FI_ReadProc) (void *buffer, unsigned size, unsigned count, fi_handle handle);
typedef unsigned (DLL_CALLCONV *FI_WriteProc) (void *buffer, unsigned size, unsigned count, fi_handle handle);
typedef int (DLL_CALLCONV *FI_SeekProc) (fi_handle handle, long offset, int origin);
typedef long (DLL_CALLCONV *FI_TellProc) (fi_handle handle);
#if (defined(_WIN32) || defined(__WIN32__))
#pragma pack(push, 1)
#else
#pragma pack(1)
#endif // WIN32
FI_STRUCT(FreeImageIO) {
FI_ReadProc read_proc; //! pointer to the function used to read data
src/Source/FreeImage.h view on Meta::CPAN
DLL_API BOOL DLL_CALLCONV FreeImage_SaveU(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, const wchar_t *filename, int flags FI_DEFAULT(0));
DLL_API BOOL DLL_CALLCONV FreeImage_SaveToHandle(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0));
// Memory I/O stream routines -----------------------------------------------
DLL_API FIMEMORY *DLL_CALLCONV FreeImage_OpenMemory(BYTE *data FI_DEFAULT(0), DWORD size_in_bytes FI_DEFAULT(0));
DLL_API void DLL_CALLCONV FreeImage_CloseMemory(FIMEMORY *stream);
DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY *stream, int flags FI_DEFAULT(0));
DLL_API BOOL DLL_CALLCONV FreeImage_SaveToMemory(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FIMEMORY *stream, int flags FI_DEFAULT(0));
DLL_API long DLL_CALLCONV FreeImage_TellMemory(FIMEMORY *stream);
DLL_API BOOL DLL_CALLCONV FreeImage_SeekMemory(FIMEMORY *stream, long offset, int origin);
DLL_API BOOL DLL_CALLCONV FreeImage_AcquireMemory(FIMEMORY *stream, BYTE **data, DWORD *size_in_bytes);
DLL_API unsigned DLL_CALLCONV FreeImage_ReadMemory(void *buffer, unsigned size, unsigned count, FIMEMORY *stream);
DLL_API unsigned DLL_CALLCONV FreeImage_WriteMemory(const void *buffer, unsigned size, unsigned count, FIMEMORY *stream);
DLL_API FIMULTIBITMAP *DLL_CALLCONV FreeImage_LoadMultiBitmapFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY *stream, int flags FI_DEFAULT(0));
DLL_API BOOL DLL_CALLCONV FreeImage_SaveMultiBitmapToMemory(FREE_IMAGE_FORMAT fif, FIMULTIBITMAP *bitmap, FIMEMORY *stream, int flags);
// Plugin Interface ---------------------------------------------------------
DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_RegisterLocalPlugin(FI_InitProc proc_address, const char *format FI_DEFAULT(0), const char *description FI_DEFAULT(0), const char *extension FI_DEFAULT(0), const char *regexpr FI_DEFAULT(0));
src/Source/FreeImage.h view on Meta::CPAN
// --------------------------------------------------------------------------
// Image manipulation toolkit
// --------------------------------------------------------------------------
// rotation and flipping
/// @deprecated see FreeImage_Rotate
DLL_API FIBITMAP *DLL_CALLCONV FreeImage_RotateClassic(FIBITMAP *dib, double angle);
DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Rotate(FIBITMAP *dib, double angle, const void *bkcolor FI_DEFAULT(NULL));
DLL_API FIBITMAP *DLL_CALLCONV FreeImage_RotateEx(FIBITMAP *dib, double angle, double x_shift, double y_shift, double x_origin, double y_origin, BOOL use_mask);
DLL_API BOOL DLL_CALLCONV FreeImage_FlipHorizontal(FIBITMAP *dib);
DLL_API BOOL DLL_CALLCONV FreeImage_FlipVertical(FIBITMAP *dib);
// upsampling / downsampling
DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Rescale(FIBITMAP *dib, int dst_width, int dst_height, FREE_IMAGE_FILTER filter FI_DEFAULT(FILTER_CATMULLROM));
DLL_API FIBITMAP *DLL_CALLCONV FreeImage_MakeThumbnail(FIBITMAP *dib, int max_pixel_size, BOOL convert FI_DEFAULT(TRUE));
DLL_API FIBITMAP *DLL_CALLCONV FreeImage_RescaleRect(FIBITMAP *dib, int dst_width, int dst_height, int left, int top, int right, int bottom, FREE_IMAGE_FILTER filter FI_DEFAULT(FILTER_CATMULLROM), unsigned flags FI_DEFAULT(0));
// color manipulation routines (point operations)
DLL_API BOOL DLL_CALLCONV FreeImage_AdjustCurve(FIBITMAP *dib, BYTE *LUT, FREE_IMAGE_COLOR_CHANNEL channel);
src/Source/FreeImage/FreeImageIO.cpp view on Meta::CPAN
_ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle) {
return (unsigned)fread(buffer, size, count, (FILE *)handle);
}
unsigned DLL_CALLCONV
_WriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle) {
return (unsigned)fwrite(buffer, size, count, (FILE *)handle);
}
int DLL_CALLCONV
_SeekProc(fi_handle handle, long offset, int origin) {
return fseek((FILE *)handle, offset, origin);
}
long DLL_CALLCONV
_TellProc(fi_handle handle) {
return ftell((FILE *)handle);
}
// ----------------------------------------------------------
void
src/Source/FreeImage/FreeImageIO.cpp view on Meta::CPAN
}
memcpy( (char *)mem_header->data + mem_header->current_position, buffer, size * count );
mem_header->current_position += size * count;
if( mem_header->current_position > mem_header->file_length ) {
mem_header->file_length = mem_header->current_position;
}
return count;
}
int DLL_CALLCONV
_MemorySeekProc(fi_handle handle, long offset, int origin) {
FIMEMORYHEADER *mem_header = (FIMEMORYHEADER*)(((FIMEMORY*)handle)->data);
// you can use _MemorySeekProc to reposition the pointer anywhere in a file
// the pointer can also be positioned beyond the end of the file
switch(origin) { //0 to filelen-1 are 'inside' the file
default:
case SEEK_SET: //can fseek() to 0-7FFFFFFF always
if( offset >= 0 ) {
mem_header->current_position = offset;
return 0;
}
break;
case SEEK_CUR:
if( mem_header->current_position + offset >= 0 ) {
src/Source/FreeImage/MNGHelper.cpp view on Meta::CPAN
mChunk = (BYTE*)realloc(mChunk, m_TotalBytesOfChunks);
if(!mChunk) {
FreeImage_OutputMessageProc(format_id, "Error while parsing %s chunk: out of memory", mChunkName);
throw (const char*)NULL;
}
// on calling CountPNGChunks earlier, we were in Offset pos,
// go back there
io->seek_proc(handle, Offset, SEEK_SET);
io->read_proc(mChunk, 1, m_TotalBytesOfChunks, handle);
// Put back to original pos
io->seek_proc(handle, mOrigPos, SEEK_SET);
// write the PNG chunks
FreeImage_WriteMemory(mChunk, 1, m_TotalBytesOfChunks, hPngMemory);
// plug in global PLTE if local PLTE exists
if(m_HasGlobalPalette) {
// ensure we remove some local chunks, so that global
// "PLTE" can be inserted right before "IDAT".
mng_RemoveChunk(hPngMemory, mng_PLTE);
mng_RemoveChunk(hPngMemory, mng_tRNS);
src/Source/FreeImage/MemoryIO.cpp view on Meta::CPAN
return FIF_UNKNOWN;
}
// =====================================================================
// Seeking in Memory stream
// =====================================================================
/**
Moves the memory pointer to a specified location
@param stream Pointer to FIMEMORY structure
@param offset Number of bytes from origin
@param origin Initial position
@return Returns TRUE if successful, returns FALSE otherwise
*/
BOOL DLL_CALLCONV
FreeImage_SeekMemory(FIMEMORY *stream, long offset, int origin) {
FreeImageIO io;
SetMemoryIO(&io);
if (stream != NULL) {
int success = io.seek_proc((fi_handle)stream, offset, origin);
return (success == 0) ? TRUE : FALSE;
}
return FALSE;
}
/**
Gets the current position of a memory pointer
@param stream Target FIMEMORY structure
@return Returns the current file position if successful, -1 otherwise
src/Source/FreeImage/MultiPage.cpp view on Meta::CPAN
for (BlockListIterator i = header->m_blocks.begin(); i != header->m_blocks.end(); i++) {
if (success) {
switch((*i)->m_type) {
case BLOCK_CONTINUEUS:
{
BlockContinueus *block = (BlockContinueus *)(*i);
for (int j = block->m_start; j <= block->m_end; j++) {
// load the original source data
FIBITMAP *dib = header->node->m_plugin->load_proc(header->io, header->handle, j, header->load_flags, data_read);
// save the data
success = node->m_plugin->save_proc(io, dib, handle, count, flags, data);
count++;
FreeImage_Unload(dib);
}
break;
src/Source/FreeImage/PluginJPEG.cpp view on Meta::CPAN
// write Adobe XMP profile
jpeg_write_xmp_profile(cinfo, dib);
// write Exif raw data
jpeg_write_exif_profile_raw(cinfo, dib);
return TRUE;
}
// ------------------------------------------------------------
// Keep original size info when using scale option on loading
// ------------------------------------------------------------
static void
store_size_info(FIBITMAP *dib, JDIMENSION width, JDIMENSION height) {
char buffer[256];
// create a tag
FITAG *tag = FreeImage_CreateTag();
if(tag) {
size_t length = 0;
// set the original width
sprintf(buffer, "%d", (int)width);
length = strlen(buffer) + 1; // include the NULL/0 value
FreeImage_SetTagKey(tag, "OriginalJPEGWidth");
FreeImage_SetTagLength(tag, (DWORD)length);
FreeImage_SetTagCount(tag, (DWORD)length);
FreeImage_SetTagType(tag, FIDT_ASCII);
FreeImage_SetTagValue(tag, buffer);
FreeImage_SetMetadata(FIMD_COMMENTS, dib, FreeImage_GetTagKey(tag), tag);
// set the original height
sprintf(buffer, "%d", (int)height);
length = strlen(buffer) + 1; // include the NULL/0 value
FreeImage_SetTagKey(tag, "OriginalJPEGHeight");
FreeImage_SetTagLength(tag, (DWORD)length);
FreeImage_SetTagCount(tag, (DWORD)length);
FreeImage_SetTagType(tag, FIDT_ASCII);
FreeImage_SetTagValue(tag, buffer);
FreeImage_SetMetadata(FIMD_COMMENTS, dib, FreeImage_GetTagKey(tag), tag);
// destroy the tag
FreeImage_DeleteTag(tag);
src/Source/FreeImage/PluginJPEG.cpp view on Meta::CPAN
RGBQUAD *colors = FreeImage_GetPalette(dib);
for (int i = 0; i < 256; i++) {
colors[i].rgbRed = (BYTE)i;
colors[i].rgbGreen = (BYTE)i;
colors[i].rgbBlue = (BYTE)i;
}
}
}
if(scale_denom != 1) {
// store original size info if a scaling was requested
store_size_info(dib, cinfo.image_width, cinfo.image_height);
}
// step 5c: handle metrices
if (cinfo.density_unit == 1) {
// dots/inch
FreeImage_SetDotsPerMeterX(dib, (unsigned) (((float)cinfo.X_density) / 0.0254000 + 0.5));
FreeImage_SetDotsPerMeterY(dib, (unsigned) (((float)cinfo.Y_density) / 0.0254000 + 0.5));
} else if (cinfo.density_unit == 2) {
src/Source/FreeImage/PluginPCX.cpp view on Meta::CPAN
return "image/x-pcx";
}
/*!
Validates a bitmap by reading the first few bytes
and comparing them with a known bitmap signature.
TRUE is returned if the bytes match the signature, FALSE otherwise.
The Validate function is used by using FreeImage_GetFileType.
Note: a plugin can safely read data any data from the bitmap without seeking back
to the original entry point; the entry point is stored prior to calling this
function and restored after.
Note: because of FreeImage's io redirection support, the header for the bitmap
must be on the start of the bitmap or at least on a known part in the bitmap. It is
forbidden to seek to the end of the bitmap or to a point relative to the end of a bitmap,
because the end of the bitmap is not always known.
*/
static BOOL DLL_CALLCONV
Validate(FreeImageIO *io, fi_handle handle) {
src/Source/FreeImage/PluginPICT.cpp view on Meta::CPAN
// contributors disclaim all warranties, expressed or implied, including, without
// limitation, the warranties of merchantability and of fitness for any purpose.
// The authors assume no liability for direct, indirect, incidental, special,
// exemplary, or consequential damages, which may result from the use of paintlib,
// even if advised of the possibility of such damage.
//
// Permission is hereby granted to use, copy, modify, and distribute this source
// code, or portions hereof, for any purpose, without fee, subject to the following
// restrictions:
//
// 1. The origin of this source code must not be misrepresented.
// 2. Altered versions must be plainly marked as such and must not be misrepresented
// as being the original source.
// 3. This Copyright notice may not be removed or altered from any source or altered
// source distribution.
// 4. Executables containing paintlib or parts of it must state that the software
// "contains paintlib code. paintlib is copyright (c) 1996-2002 Ulrich von Zadow
// and other contributors.". This notice must be displayed in at least one place
// where the copyright for the software itself is displayed. The documentation must
// also contain this notice.
//
// Bug fixes were made to the original code to support version 2 PICT files
// properly.
//
// Additional resources:
// http://developer.apple.com/documentation/mac/QuickDraw/QuickDraw-458.html
// http://www.fileformat.info/format/macpict/egff.htm
//
// Notes (http://lists.apple.com/archives/java-dev/2006/Apr/msg00588.html):
// There are three main types of PICT files:
// - Version 1
// - Version 2
src/Source/FreeImage/PluginPICT.cpp view on Meta::CPAN
} else {
io->seek_proc(handle, optable[opcode].len, SEEK_CUR);
}
break;
}
}
else if (opcode == 0xc00) {
// version 2 header (26 bytes)
WORD minorVersion = Read16( io, handle ); // always FFFE (-2) for extended version 2
Read16( io, handle ); // reserved
hRes = Read32( io, handle ); // original horizontal resolution in pixels/inch
vRes = Read32( io, handle ); // original horizontal resolution in pixels/inch
MacRect dummy;
ReadRect( io, handle, &dummy ); // frame bounds at original resolution
Read32( io, handle ); // reserved
}
else if (opcode == 0x8200) {
// jpeg
long opLen = Read32( io, handle );
BOOL found = FALSE;
int i = 0;
// skip to JPEG header.
while ( !found && i < opLen ) {
src/Source/FreeImage/PluginPNG.cpp view on Meta::CPAN
Set conversion instructions as needed.
@param png_ptr PNG handle
@param info_ptr PNG info handle
@param flags Decoder flags
@param output_image_type Returned FreeImage converted image type
@return Returns TRUE if successful, returns FALSE otherwise
@see png_read_update_info
*/
static BOOL
ConfigureDecoder(png_structp png_ptr, png_infop info_ptr, int flags, FREE_IMAGE_TYPE *output_image_type) {
// get original image info
const int color_type = png_get_color_type(png_ptr, info_ptr);
const int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
const int pixel_depth = bit_depth * png_get_channels(png_ptr, info_ptr);
FREE_IMAGE_TYPE image_type = FIT_BITMAP; // assume standard image type
// check for transparency table or single transparent color
BOOL bIsTransparent = png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) == PNG_INFO_tRNS ? TRUE : FALSE;
// check allowed combinations of colour type and bit depth
src/Source/FreeImage/PluginRAS.cpp view on Meta::CPAN
// Check the file format
rle = FALSE;
isRGB = FALSE;
switch(header.type) {
case RT_OLD:
case RT_STANDARD:
case RT_FORMAT_TIFF: // I don't even know what these format are...
case RT_FORMAT_IFF: //The TIFF and IFF format types indicate that the raster
//file was originally converted from either of these file formats.
//so lets at least try to process them as RT_STANDARD
break;
case RT_BYTE_ENCODED:
rle = TRUE;
break;
case RT_FORMAT_RGB:
isRGB = TRUE;
break;
src/Source/FreeImage/PluginRAW.cpp view on Meta::CPAN
int valid() {
return (_io && _handle);
}
int read(void *buffer, size_t size, size_t count) {
if(substream) return substream->read(buffer, size, count);
return _io->read_proc(buffer, (unsigned)size, (unsigned)count, _handle);
}
int seek(INT64 offset, int origin) {
if(substream) return substream->seek(offset, origin);
return _io->seek_proc(_handle, (long)offset, origin);
}
INT64 tell() {
if(substream) return substream->tell();
return _io->tell_proc(_handle);
}
INT64 size() {
return _fsize;
}
src/Source/FreeImage/PluginTARGA.cpp view on Meta::CPAN
typedef struct tagTGAHEADER {
BYTE id_length; //! length of the image ID field
BYTE color_map_type; //! whether a color map is included
BYTE image_type; //! compression and color types
WORD cm_first_entry; //! first entry index (offset into the color map table)
WORD cm_length; //! color map length (number of entries)
BYTE cm_size; //! color map entry size, in bits (number of bits per pixel)
WORD is_xorigin; //! X-origin of image (absolute coordinate of lower-left corner for displays where origin is at the lower left)
WORD is_yorigin; //! Y-origin of image (as for X-origin)
WORD is_width; //! image width
WORD is_height; //! image height
BYTE is_pixel_depth; //! bits per pixel
BYTE is_image_descriptor; //! image descriptor, bits 3-0 give the alpha channel depth, bits 5-4 give direction
} TGAHEADER;
typedef struct tagTGAEXTENSIONAREA {
WORD extension_size; // Size in bytes of the extension area, always 495
char author_name[41]; // Name of the author. If not used, bytes should be set to NULL (\0) or spaces
char author_comments[324]; // A comment, organized as four lines, each consisting of 80 characters plus a NULL
src/Source/FreeImage/PluginTARGA.cpp view on Meta::CPAN
const size_t _size;
const FreeImageIO *_io;
const fi_handle _handle;
};
#ifdef FREEIMAGE_BIGENDIAN
static void
SwapHeader(TGAHEADER *header) {
SwapShort(&header->cm_first_entry);
SwapShort(&header->cm_length);
SwapShort(&header->is_xorigin);
SwapShort(&header->is_yorigin);
SwapShort(&header->is_width);
SwapShort(&header->is_height);
}
static void
SwapExtensionArea(TGAEXTENSIONAREA *ex) {
SwapShort(&ex->extension_size);
SwapShort(&ex->datetime_stamp[0]);
SwapShort(&ex->datetime_stamp[1]);
SwapShort(&ex->datetime_stamp[2]);
src/Source/FreeImage/PluginTARGA.cpp view on Meta::CPAN
RGBQUAD *palette = FreeImage_GetPalette(dib);
const unsigned bpp = FreeImage_GetBPP(dib);
// write the file header
TGAHEADER header;
header.id_length = 0;
header.cm_first_entry = 0;
header.is_xorigin = 0;
header.is_yorigin = 0;
header.is_width = (WORD)FreeImage_GetWidth(dib);
header.is_height = (WORD)FreeImage_GetHeight(dib);
header.is_pixel_depth = (BYTE)bpp;
header.is_image_descriptor = (bpp == 32 ? 8 : 0);
if (palette) {
header.color_map_type = 1;
header.image_type = (TARGA_SAVE_RLE & flags) ? TGA_RLECMAP : TGA_CMAP;
header.cm_length = (WORD)(1 << bpp);
src/Source/FreeImage/PluginTIFF.cpp view on Meta::CPAN
case PHOTOMETRIC_CIELAB:
case PHOTOMETRIC_ICCLAB:
case PHOTOMETRIC_ITULAB:
loadMethod = LoadAsRBGA;
break;
case PHOTOMETRIC_LOGLUV:
loadMethod = LoadAsLogLuv;
break;
case PHOTOMETRIC_SEPARATED:
// if image is PHOTOMETRIC_SEPARATED _and_ comes with an ICC profile,
// then the image should preserve its original (CMYK) colour model and
// should be read as CMYK (to keep the match of pixel and profile and
// to avoid multiple conversions. Conversion can be done by changing
// the profile from it's original CMYK to an RGB profile with an
// apropriate color management system. Works with non-tiled TIFFs.
if(!bIsTiled) {
loadMethod = LoadAsCMYK;
}
break;
case PHOTOMETRIC_MINISWHITE:
case PHOTOMETRIC_MINISBLACK:
case PHOTOMETRIC_PALETTE:
// When samplesperpixel = 2 and bitspersample = 8, set the image as a
// 8-bit indexed image + 8-bit alpha layer image
src/Source/FreeImage/PluginTIFF.cpp view on Meta::CPAN
ReadResolution(tif, dib);
// set up the colormap based on photometric
ReadPalette(tif, photometric, bitspersample, dib);
// calculate the line + pitch (separate for scr & dest)
const tmsize_t src_line = TIFFScanlineSize(tif);
// here, the pitch is 2x less than the original as we only keep the first layer
int dst_pitch = FreeImage_GetPitch(dib);
// transparency table for 8-bit + 8-bit alpha images
BYTE trns[256];
// clear the transparency table
memset(trns, 0xFF, 256 * sizeof(BYTE));
// In the tiff file the lines are saved from up to down
// In a DIB the lines must be saved from down to up
src/Source/FreeImage/ZLibInterface.cpp view on Meta::CPAN
if (get_byte(stream) != Z_DEFLATED || ((flags = get_byte(stream)) & 0xE0) != 0)
return Z_DATA_ERROR;
for (len = 0; len < 6; len++) (void)get_byte(stream);
if ((flags & 0x04) != 0) { /* skip the extra field */
len = (DWORD)get_byte(stream);
len += ((DWORD)get_byte(stream)) << 8;
/* len is garbage if EOF but the loop below will quit anyway */
while (len-- != 0 && get_byte(stream) != EOF) ;
}
if ((flags & 0x08) != 0) { /* skip the original file name */
while ((c = get_byte(stream)) != 0 && c != EOF) ;
}
if ((flags & 0x10) != 0) { /* skip the .gz file comment */
while ((c = get_byte(stream)) != 0 && c != EOF) ;
}
if ((flags & 0x02) != 0) { /* skip the header crc */
for (len = 0; len < 2; len++) (void)get_byte(stream);
}
return Z_OK;
}
src/Source/FreeImage/tmoDrago03.cpp view on Meta::CPAN
return TRUE;
}
// ----------------------------------------------------------
// Main algorithm
// ----------------------------------------------------------
/**
Apply the Adaptive Logarithmic Mapping operator to a HDR image and convert to 24-bit RGB
@param src Input RGB16 or RGB[A]F image
@param gamma Gamma correction (gamma > 0). 1 means no correction, 2.2 in the original paper.
@param exposure Exposure parameter (0 means no correction, 0 in the original paper)
@return Returns a 24-bit RGB image if successful, returns NULL otherwise
*/
FIBITMAP* DLL_CALLCONV
FreeImage_TmoDrago03(FIBITMAP *src, double gamma, double exposure) {
float maxLum, minLum, avgLum;
if(!FreeImage_HasPixels(src)) return NULL;
// working RGBF variable
FIBITMAP *dib = NULL;
src/Source/FreeImage/tmoFattal02.cpp view on Meta::CPAN
/**
Compute a Gaussian pyramid using the specified number of levels.
@param H Original bitmap
@param pyramid Resulting pyramid array
@param nlevels Number of resolution levels
@return Returns TRUE if successful, returns FALSE otherwise
*/
static BOOL GaussianPyramid(FIBITMAP *H, FIBITMAP **pyramid, int nlevels) {
try {
// first level is the original image
pyramid[0] = FreeImage_Clone(H);
if(pyramid[0] == NULL) throw(1);
// compute next levels
for(int k = 1; k < nlevels; k++) {
pyramid[k] = GaussianLevel5x5(pyramid[k-1]);
if(pyramid[k] == NULL) throw(1);
}
return TRUE;
} catch(int) {
for(int k = 0; k < nlevels; k++) {
src/Source/FreeImage/tmoFattal02.cpp view on Meta::CPAN
FIBITMAP *Gk = gradients[k];
const unsigned width = FreeImage_GetWidth(Gk);
const unsigned height = FreeImage_GetHeight(Gk);
const unsigned pitch = FreeImage_GetPitch(Gk) / sizeof(float);
// parameter alpha is 0.1 times the average gradient magnitude
// also, note the factor of 2**k in the denominator;
// that is there to correct for the fact that an average gradient avgGrad(H) over 2**k pixels
// in the original image will appear as a gradient grad(Hk) = 2**k*avgGrad(H) over a single pixel in Hk.
float ALPHA = alpha * avgGrad[k] * (float)((int)1 << k);
if(ALPHA == 0) ALPHA = EPSILON;
phi[k] = FreeImage_AllocateT(FIT_FLOAT, width, height);
if(!phi[k]) throw(1);
src_pixel = (float*)FreeImage_GetBits(Gk);
dst_pixel = (float*)FreeImage_GetBits(phi[k]);
for(unsigned y = 0; y < height; y++) {
for(unsigned x = 0; x < width; x++) {
src/Source/FreeImageToolkit/BSplineRotate.cpp view on Meta::CPAN
static void ConvertToInterpolationCoefficients(double *c, long DataLength, double *z, long NbPoles, double Tolerance);
static double InitialCausalCoefficient(double *c, long DataLength, double z, double Tolerance);
static void GetColumn(double *Image, long Width, long x, double *Line, long Height);
static void GetRow(double *Image, long y, double *Line, long Width);
static double InitialAntiCausalCoefficient(double *c, long DataLength, double z);
static void PutColumn(double *Image, long Width, long x, double *Line, long Height);
static void PutRow(double *Image, long y, double *Line, long Width);
static bool SamplesToCoefficients(double *Image, long Width, long Height, long spline_degree);
static double InterpolatedValue(double *Bcoeff, long Width, long Height, double x, double y, long spline_degree);
static FIBITMAP * Rotate8Bit(FIBITMAP *dib, double angle, double x_shift, double y_shift, double x_origin, double y_origin, long spline_degree, BOOL use_mask);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Coefficients routines
/**
ConvertToInterpolationCoefficients
@param c Input samples --> output coefficients
@param DataLength Number of samples or coefficients
@param z Poles
src/Source/FreeImageToolkit/BSplineRotate.cpp view on Meta::CPAN
// FreeImage implementation
/**
Image translation and rotation using B-Splines.
@param dib Input 8-bit greyscale image
@param angle Output image rotation in degree
@param x_shift Output image horizontal shift
@param y_shift Output image vertical shift
@param x_origin Output origin of the x-axis
@param y_origin Output origin of the y-axis
@param spline_degree Output degree of the B-spline model
@param use_mask Whether or not to mask the image
@return Returns the translated & rotated dib if successful, returns NULL otherwise
*/
static FIBITMAP *
Rotate8Bit(FIBITMAP *dib, double angle, double x_shift, double y_shift, double x_origin, double y_origin, long spline_degree, BOOL use_mask) {
double *ImageRasterArray;
double p;
double a11, a12, a21, a22;
double x0, y0, x1, y1;
long x, y;
long spline;
bool bResult;
int bpp = FreeImage_GetBPP(dib);
if(bpp != 8) {
src/Source/FreeImageToolkit/BSplineRotate.cpp view on Meta::CPAN
free(ImageRasterArray);
return NULL;
}
// prepare the geometry
angle *= PI / 180.0;
a11 = cos(angle);
a12 = -sin(angle);
a21 = sin(angle);
a22 = cos(angle);
x0 = a11 * (x_shift + x_origin) + a12 * (y_shift + y_origin);
y0 = a21 * (x_shift + x_origin) + a22 * (y_shift + y_origin);
x_shift = x_origin - x0;
y_shift = y_origin - y0;
// visit all pixels of the output image and assign their value
for(y = 0; y < height; y++) {
BYTE *dst_bits = FreeImage_GetScanLine(dst, height-1-y);
x0 = a12 * (double)y + x_shift;
y0 = a22 * (double)y + y_shift;
for(x = 0; x < width; x++) {
x1 = x0 + a11 * (double)x;
src/Source/FreeImageToolkit/BSplineRotate.cpp view on Meta::CPAN
return dst;
}
/**
Image rotation using a 3rd order (cubic) B-Splines.
@param dib Input dib (8, 24 or 32-bit)
@param angle Output image rotation
@param x_shift Output image horizontal shift
@param y_shift Output image vertical shift
@param x_origin Output origin of the x-axis
@param y_origin Output origin of the y-axis
@param use_mask Whether or not to mask the image
@return Returns the translated & rotated dib if successful, returns NULL otherwise
*/
FIBITMAP * DLL_CALLCONV
FreeImage_RotateEx(FIBITMAP *dib, double angle, double x_shift, double y_shift, double x_origin, double y_origin, BOOL use_mask) {
int x, y, bpp;
int channel, nb_channels;
BYTE *src_bits, *dst_bits;
FIBITMAP *src8 = NULL, *dst8 = NULL, *dst = NULL;
if(!FreeImage_HasPixels(dib)) return NULL;
try {
bpp = FreeImage_GetBPP(dib);
if(bpp == 8) {
FIBITMAP *dst_8 = Rotate8Bit(dib, angle, x_shift, y_shift, x_origin, y_origin, ROTATE_CUBIC, use_mask);
if(dst_8) {
// copy metadata from src to dst
FreeImage_CloneMetadata(dst_8, dib);
}
return dst_8;
}
if((bpp == 24) || (bpp == 32)) {
// allocate dst image
int width = FreeImage_GetWidth(dib);
int height = FreeImage_GetHeight(dib);
src/Source/FreeImageToolkit/BSplineRotate.cpp view on Meta::CPAN
for(y = 0; y < height; y++) {
src_bits = FreeImage_GetScanLine(dib, y);
dst_bits = FreeImage_GetScanLine(src8, y);
for(x = 0; x < width; x++) {
dst_bits[x] = src_bits[channel];
src_bits += nb_channels;
}
}
// process channel
dst8 = Rotate8Bit(src8, angle, x_shift, y_shift, x_origin, y_origin, ROTATE_CUBIC, use_mask);
if(!dst8) throw(1);
// insert channel to destination dib
for(y = 0; y < height; y++) {
src_bits = FreeImage_GetScanLine(dst8, y);
dst_bits = FreeImage_GetScanLine(dst, y);
for(x = 0; x < width; x++) {
dst_bits[channel] = src_bits[x];
dst_bits += nb_channels;
}
src/Source/FreeImageToolkit/ClassicRotate.cpp view on Meta::CPAN
// copy metadata from src to dst
FreeImage_CloneMetadata(dst, dib);
return dst;
}
else if((bpp == 8) || (bpp == 24) || (bpp == 32)) {
FIBITMAP *dst = RotateAny(dib, angle, bkcolor);
if(!dst) throw(1);
if(bpp == 8) {
// copy original palette to rotated bitmap
RGBQUAD *src_pal = FreeImage_GetPalette(dib);
RGBQUAD *dst_pal = FreeImage_GetPalette(dst);
memcpy(&dst_pal[0], &src_pal[0], 256 * sizeof(RGBQUAD));
// copy transparency table
FreeImage_SetTransparencyTable(dst, FreeImage_GetTransparencyTable(dib), FreeImage_GetTransparencyCount(dib));
// copy background color
RGBQUAD bkcolor;
if( FreeImage_GetBackgroundColor(dib, &bkcolor) ) {
src/Source/LibJPEG/README view on Meta::CPAN
its user, assume the entire risk as to its quality and accuracy.
This software is copyright (C) 1991-2014, Thomas G. Lane, Guido Vollbeding.
All Rights Reserved except as specified below.
Permission is hereby granted to use, copy, modify, and distribute this
software (or portions thereof) for any purpose, without fee, subject to these
conditions:
(1) If any part of the source code for this software is distributed, then this
README file must be included, with this copyright and no-warranty notice
unaltered; and any additions, deletions, or changes to the original files
must be clearly indicated in accompanying documentation.
(2) If only executable code is distributed, then the accompanying
documentation must state that "this software is based in part on the work of
the Independent JPEG Group".
(3) Permission for use of this software is granted only if the user accepts
full responsibility for any undesirable consequences; the authors accept
NO LIABILITY for damages of any kind.
These conditions apply to any software derived from or based on the IJG code,
not just to the unmodified library. If you use our work, you ought to
src/Source/LibJPEG/README view on Meta::CPAN
standards (DIS 10918-1 and draft DIS 10918-2).
Although this is by far the most detailed and comprehensive exposition of
JPEG publicly available, we point out that it is still missing an explanation
of the most essential properties and algorithms of the underlying DCT
technology.
If you think that you know about DCT-based JPEG after reading this book,
then you are in delusion. The real fundamentals and corresponding potential
of DCT-based JPEG are not publicly known so far, and that is the reason for
all the mistaken developments taking place in the image coding domain.
The original JPEG standard is divided into two parts, Part 1 being the actual
specification, while Part 2 covers compliance testing methods. Part 1 is
titled "Digital Compression and Coding of Continuous-tone Still Images,
Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS
10918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of
Continuous-tone Still Images, Part 2: Compliance testing" and has document
numbers ISO/IEC IS 10918-2, ITU-T T.83.
IJG JPEG 8 introduced an implementation of the JPEG SmartScale extension
which is specified in two documents: A contributed document at ITU and ISO
with title "ITU-T JPEG-Plus Proposal for Extending ITU-T T.81 for Advanced
Image Coding", April 2006, Geneva, Switzerland. The latest version of this
src/Source/LibJPEG/README view on Meta::CPAN
Thank to Nico Zschach and Dirk Stelling of the technical support team
at the Digital Images company in Halle for providing me with extra
equipment for configuration tests.
Thank to Richard F. Lyon (then of Foveon Inc.) for fruitful
communication about JPEG configuration in Sigma Photo Pro software.
Thank to Andrew Finkenstadt for hosting the ijg.org site.
Last but not least special thank to Thomas G. Lane for the original
design and development of this singular software package.
FILE FORMAT WARS
================
The ISO/IEC JTC1/SC29/WG1 standards committee (previously known as JPEG,
together with ITU-T SG16) currently promotes different formats containing
the name "JPEG" which is misleading because these formats are incompatible
with original DCT-based JPEG and are based on faulty technologies.
IJG therefore does not and will not support such momentary mistakes
(see REFERENCES).
There exist also distributions under the name "OpenJPEG" promoting such
kind of formats which is misleading because they don't support original
JPEG images.
We have no sympathy for the promotion of inferior formats. Indeed, one of
the original reasons for developing this free software was to help force
convergence on common, interoperable format standards for JPEG files.
Don't use an incompatible file format!
(In any case, our decoder will remain capable of reading existing JPEG
image files indefinitely.)
The ISO committee pretends to be "responsible for the popular JPEG" in their
public reports which is not true because they don't respond to actual
requirements for the maintenance of the original JPEG specification.
Furthermore, the ISO committee pretends to "ensure interoperability" with
their standards which is not true because their "standards" support only
application-specific and proprietary use cases and contain mathematically
incorrect code.
There are currently different distributions in circulation containing the
name "libjpeg" which is misleading because they don't have the features and
are incompatible with formats supported by actual IJG libjpeg distributions.
One of those fakes is released by members of the ISO committee and just uses
the name of libjpeg for misdirection of people, similar to the abuse of the
name JPEG as described above, while having nothing in common with actual IJG
libjpeg distributions and containing mathematically incorrect code.
The other one claims to be a "derivative" or "fork" of the original libjpeg,
but violates the license conditions as described under LEGAL ISSUES above
and violates basic C programming properties.
We have no sympathy for the release of misleading, incorrect and illegal
distributions derived from obsolete code bases.
Don't use an obsolete code base!
According to the UCC (Uniform Commercial Code) law, IJG has the lawful and
legal right to foreclose on certain standardization bodies and other
institutions or corporations that knowingly perform substantial and
systematic deceptive acts and practices, fraud, theft, and damaging of the
src/Source/LibJPEG/README view on Meta::CPAN
IJG has secured the value for all concerned free people of the planet.
A partial list of foreclosed institutions and corporations ("Hall of Shame")
is currently prepared and will be published later.
TO DO
=====
Version 9 is the second release of a new generation JPEG standard
to overcome the limitations of the original JPEG specification,
and is the first true source reference JPEG codec.
More features are being prepared for coming releases...
Please send bug reports, offers of help, etc. to jpeg-info@jpegclub.org.
src/Source/LibJPEG/ansi2knr.c view on Meta::CPAN
* line ends with a left or right brace or a semicolon. These algorithms
* ignore whitespace, comments, and preprocessor directives, except that
* the function name must be the first thing on the line. The following
* constructs will confuse it:
* - Any other construct that starts at the left margin and
* follows the above syntax (such as a macro or function call).
* - Some macros that tinker with the syntax of function headers.
*/
/*
* The original and principal author of ansi2knr is L. Peter Deutsch
* <ghost@aladdin.com>. Other authors are noted in the change history
* that follows (in reverse chronological order):
lpd 2000-04-12 backs out Eggert's changes because of bugs:
- concatlits didn't declare the type of its bufend argument;
- concatlits didn't recognize when it was inside a comment;
- scanstring could scan backward past the beginning of the string; when
- the check for \ + newline in scanstring was unnecessary.
2000-03-05 Paul Eggert <eggert@twinsun.com>
src/Source/LibJPEG/ansi2knr.c view on Meta::CPAN
lpd 1994-12-18 added conditionals for systems where ctype macros
don't handle 8-bit characters properly, suggested by
Francois Pinard <pinard@iro.umontreal.ca>;
removed --varargs switch (this is now the default)
lpd 1994-10-10 removed CONFIG_BROKETS conditional
lpd 1994-07-16 added some conditionals to help GNU `configure',
suggested by Francois Pinard <pinard@iro.umontreal.ca>;
properly erase prototype args in function parameters,
contributed by Jim Avera <jima@netcom.com>;
correct error in writeblanks (it shouldn't erase EOLs)
lpd 1989-xx-xx original version
*/
/* Most of the conditionals here are to make ansi2knr work with */
/* or without the GNU configure machinery. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
src/Source/LibJPEG/install.txt view on Meta::CPAN
method). If you use -mips2, you may want to alter the default DCT method to
be float. To do this, put "#define JDCT_DEFAULT JDCT_FLOAT" in jconfig.h.
VMS:
On an Alpha/VMS system with MMS, be sure to use the "/Marco=Alpha=1"
qualifier with MMS when building the JPEG package.
VAX/VMS v5.5-1 may have problems with the test step of the build procedure
reporting differences when it compares the original and test images. If the
error points to the last block of the files, it is most likely bogus and may
be safely ignored. It seems to be because the files are Stream_LF and
Backup/Compare has difficulty with the (presumably) null padded files.
This problem was not observed on VAX/VMS v6.1 or AXP/VMS v6.1.
src/Source/LibJPEG/jdhuff.c view on Meta::CPAN
* because not all machines measure sizeof in 8-bit bytes.
*/
typedef struct { /* Bitreading state saved across MCUs */
bit_buf_type get_buffer; /* current bit-extraction buffer */
int bits_left; /* # of unused bits in it */
} bitread_perm_state;
typedef struct { /* Bitreading working state within an MCU */
/* Current data source location */
/* We need a copy, rather than munging the original, in case of suspension */
const JOCTET * next_input_byte; /* => next byte to read from source */
size_t bytes_in_buffer; /* # of bytes remaining in source buffer */
/* Bit input buffer --- note these values are kept in register variables,
* not in this struct, inside the inner loops.
*/
bit_buf_type get_buffer; /* current bit-extraction buffer */
int bits_left; /* # of unused bits in it */
/* Pointer needed by jpeg_fill_bit_buffer. */
j_decompress_ptr cinfo; /* back link to decompress master record */
} bitread_working_state;
src/Source/LibJPEG/jdmarker.c view on Meta::CPAN
else
limit = marker->length_limit_APPn[cinfo->unread_marker - (int) M_APP0];
if ((unsigned int) length < limit)
limit = (unsigned int) length;
/* allocate and initialize the marker item */
cur_marker = (jpeg_saved_marker_ptr)
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(struct jpeg_marker_struct) + limit);
cur_marker->next = NULL;
cur_marker->marker = (UINT8) cinfo->unread_marker;
cur_marker->original_length = (unsigned int) length;
cur_marker->data_length = limit;
/* data area is just beyond the jpeg_marker_struct */
data = cur_marker->data = (JOCTET FAR *) (cur_marker + 1);
marker->cur_marker = cur_marker;
marker->bytes_read = 0;
bytes_read = 0;
data_length = limit;
} else {
/* deal with bogus length word */
bytes_read = data_length = 0;
src/Source/LibJPEG/jdmarker.c view on Meta::CPAN
if (cinfo->marker_list == NULL) {
cinfo->marker_list = cur_marker;
} else {
jpeg_saved_marker_ptr prev = cinfo->marker_list;
while (prev->next != NULL)
prev = prev->next;
prev->next = cur_marker;
}
/* Reset pointer & calc remaining data length */
data = cur_marker->data;
length = cur_marker->original_length - data_length;
}
/* Reset to initial state for next marker */
marker->cur_marker = NULL;
/* Process the marker if interesting; else just make a generic trace msg */
switch (cinfo->unread_marker) {
case M_APP0:
examine_app0(cinfo, data, data_length, length);
break;
case M_APP14:
src/Source/LibJPEG/jfdctflt.c view on Meta::CPAN
* This implementation should be more accurate than either of the integer
* DCT implementations. However, it may not give the same results on all
* machines because of differences in roundoff behavior. Speed will depend
* on the hardware's floating point capacity.
*
* A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT
* on each column. Direct algorithms are also available, but they are
* much more complex and seem not to be any faster when reduced to code.
*
* This implementation is based on Arai, Agui, and Nakajima's algorithm for
* scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in
* Japanese, but the algorithm is described in the Pennebaker & Mitchell
* JPEG textbook (see REFERENCES section in file README). The following code
* is based directly on figure 4-8 in P&M.
* While an 8-point DCT cannot be done in less than 11 multiplies, it is
* possible to arrange the computation so that many of the multiplies are
* simple scalings of the final outputs. These multiplies can then be
* folded into the multiplications or divisions by the JPEG quantization
* table entries. The AA&N method leaves only 5 multiplies and 29 adds
* to be done in the DCT itself.
* The primary disadvantage of this method is that with a fixed-point
src/Source/LibJPEG/jfdctfst.c view on Meta::CPAN
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains a fast, not so accurate integer implementation of the
* forward DCT (Discrete Cosine Transform).
*
* A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT
* on each column. Direct algorithms are also available, but they are
* much more complex and seem not to be any faster when reduced to code.
*
* This implementation is based on Arai, Agui, and Nakajima's algorithm for
* scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in
* Japanese, but the algorithm is described in the Pennebaker & Mitchell
* JPEG textbook (see REFERENCES section in file README). The following code
* is based directly on figure 4-8 in P&M.
* While an 8-point DCT cannot be done in less than 11 multiplies, it is
* possible to arrange the computation so that many of the multiplies are
* simple scalings of the final outputs. These multiplies can then be
* folded into the multiplications or divisions by the JPEG quantization
* table entries. The AA&N method leaves only 5 multiplies and 29 adds
* to be done in the DCT itself.
* The primary disadvantage of this method is that with fixed-point math,
src/Source/LibJPEG/jidctflt.c view on Meta::CPAN
* IDCT implementations. However, it may not give the same results on all
* machines because of differences in roundoff behavior. Speed will depend
* on the hardware's floating point capacity.
*
* A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT
* on each row (or vice versa, but it's more convenient to emit a row at
* a time). Direct algorithms are also available, but they are much more
* complex and seem not to be any faster when reduced to code.
*
* This implementation is based on Arai, Agui, and Nakajima's algorithm for
* scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in
* Japanese, but the algorithm is described in the Pennebaker & Mitchell
* JPEG textbook (see REFERENCES section in file README). The following code
* is based directly on figure 4-8 in P&M.
* While an 8-point DCT cannot be done in less than 11 multiplies, it is
* possible to arrange the computation so that many of the multiplies are
* simple scalings of the final outputs. These multiplies can then be
* folded into the multiplications or divisions by the JPEG quantization
* table entries. The AA&N method leaves only 5 multiplies and 29 adds
* to be done in the DCT itself.
* The primary disadvantage of this method is that with a fixed-point
src/Source/LibJPEG/jidctfst.c view on Meta::CPAN
* This file contains a fast, not so accurate integer implementation of the
* inverse DCT (Discrete Cosine Transform). In the IJG code, this routine
* must also perform dequantization of the input coefficients.
*
* A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT
* on each row (or vice versa, but it's more convenient to emit a row at
* a time). Direct algorithms are also available, but they are much more
* complex and seem not to be any faster when reduced to code.
*
* This implementation is based on Arai, Agui, and Nakajima's algorithm for
* scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in
* Japanese, but the algorithm is described in the Pennebaker & Mitchell
* JPEG textbook (see REFERENCES section in file README). The following code
* is based directly on figure 4-8 in P&M.
* While an 8-point DCT cannot be done in less than 11 multiplies, it is
* possible to arrange the computation so that many of the multiplies are
* simple scalings of the final outputs. These multiplies can then be
* folded into the multiplications or divisions by the JPEG quantization
* table entries. The AA&N method leaves only 5 multiplies and 29 adds
* to be done in the DCT itself.
* The primary disadvantage of this method is that with fixed-point math,
src/Source/LibJPEG/jpeglib.h view on Meta::CPAN
int Ah, Al; /* progressive JPEG successive approx. parms */
} jpeg_scan_info;
/* The decompressor can save APPn and COM markers in a list of these: */
typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr;
struct jpeg_marker_struct {
jpeg_saved_marker_ptr next; /* next in list, or NULL */
UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */
unsigned int original_length; /* # bytes of data in the file */
unsigned int data_length; /* # bytes of data saved at data[] */
JOCTET FAR * data; /* the data contained in the marker */
/* the marker length word is not counted in data_length or original_length */
};
/* Known color spaces. */
typedef enum {
JCS_UNKNOWN, /* error/unspecified */
JCS_GRAYSCALE, /* monochrome */
JCS_RGB, /* red/green/blue, standard RGB (sRGB) */
JCS_YCbCr, /* Y/Cb/Cr (also known as YUV), standard YCC */
JCS_CMYK, /* C/M/Y/K */
src/Source/LibJPEG/jquant2.c view on Meta::CPAN
JSAMPLE colorlist[MAXNUMCOLORS];
int numcolors; /* number of candidate colors */
/* This array holds the actually closest colormap index for each cell. */
JSAMPLE bestcolor[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS];
/* Convert cell coordinates to update box ID */
c0 >>= BOX_C0_LOG;
c1 >>= BOX_C1_LOG;
c2 >>= BOX_C2_LOG;
/* Compute true coordinates of update box's origin corner.
* Actually we compute the coordinates of the center of the corner
* histogram cell, which are the lower bounds of the volume we care about.
*/
minc0 = (c0 << BOX_C0_SHIFT) + ((1 << C0_SHIFT) >> 1);
minc1 = (c1 << BOX_C1_SHIFT) + ((1 << C1_SHIFT) >> 1);
minc2 = (c2 << BOX_C2_SHIFT) + ((1 << C2_SHIFT) >> 1);
/* Determine which colormap entries are close enough to be candidates
* for the nearest entry to some cell in the update box.
*/
src/Source/LibJPEG/libjpeg.txt view on Meta::CPAN
Image data is returned in top-to-bottom scanline order. If you must write
out the image in bottom-to-top order, you can use the JPEG library's virtual
array mechanism to invert the data efficiently. Examples of this can be
found in the sample application djpeg.
The library maintains a count of the number of scanlines returned so far
in the output_scanline field of the JPEG object. Usually you can just use
this variable as the loop counter, so that the loop test looks like
"while (cinfo.output_scanline < cinfo.output_height)". (Note that the test
should NOT be against image_height, unless you never use scaling. The
image_height field is the height of the original unscaled image.)
The return value always equals the change in the value of output_scanline.
If you don't use a suspending data source, it is safe to assume that
jpeg_read_scanlines() reads at least one scanline per call, until the
bottom of the image has been reached.
If you use a buffer larger than one scanline, it is NOT safe to assume that
jpeg_read_scanlines() fills it. (The current implementation returns only a
few scanlines per call, no matter how large a buffer you pass.) So you must
always provide a loop that calls jpeg_read_scanlines() repeatedly until the
src/Source/LibJPEG/libjpeg.txt view on Meta::CPAN
manager" to obtain the compressed data; you can provide your own source
manager if you want the data to come from somewhere other than a memory
buffer or a stdio stream.
In both cases, compressed data is processed a bufferload at a time: the
destination or source manager provides a work buffer, and the library invokes
the manager only when the buffer is filled or emptied. (You could define a
one-character buffer to force the manager to be invoked for each byte, but
that would be rather inefficient.) The buffer's size and location are
controlled by the manager, not by the library. For example, the memory
source manager just makes the buffer pointer and length point to the original
data in memory. In this case the buffer-reload procedure will be invoked
only if the decompressor ran off the end of the datastream, which would
indicate an erroneous datastream.
The work buffer is defined as an array of datatype JOCTET, which is generally
"char" or "unsigned char". On a machine where char is not exactly 8 bits
wide, you must define JOCTET as a wider data type and then modify the data
source and destination modules to transcribe the work arrays into 8-bit units
on external storage.
src/Source/LibJPEG/libjpeg.txt view on Meta::CPAN
than length_limit data bytes, only length_limit bytes will be saved; this
parameter allows you to avoid chewing up memory when you only need to see the
first few bytes of a potentially large marker. If you want to save all the
data, set length_limit to 0xFFFF; that is enough since marker lengths are only
16 bits. As a special case, setting length_limit to 0 prevents that marker
type from being saved at all. (That is the default behavior, in fact.)
After jpeg_read_header() completes, you can examine the special markers by
following the cinfo->marker_list pointer chain. All the special markers in
the file appear in this list, in order of their occurrence in the file (but
omitting any markers of types you didn't ask for). Both the original data
length and the saved data length are recorded for each list entry; the latter
will not exceed length_limit for the particular marker type. Note that these
lengths exclude the marker length word, whereas the stored representation
within the JPEG file includes it. (Hence the maximum data length is really
only 65533.)
It is possible that additional special markers appear in the file beyond the
SOS marker at which jpeg_read_header stops; if so, the marker list will be
extended during reading of the rest of the file. This is not expected to be
common, however. If you are short on memory you may want to reset the length