本文整理汇总了C++中FreeImage_OutputMessageProc函数的典型用法代码示例。如果您正苦于以下问题:C++ FreeImage_OutputMessageProc函数的具体用法?C++ FreeImage_OutputMessageProc怎么用?C++ FreeImage_OutputMessageProc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FreeImage_OutputMessageProc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: openStdIO
static BOOL
openStdIO(const char* src_file, const char* dst_file, FreeImageIO* dst_io, fi_handle* src_handle, fi_handle* dst_handle) {
*src_handle = NULL;
*dst_handle = NULL;
FreeImageIO io;
SetDefaultIO (&io);
const BOOL isSameFile = (dst_file && (strcmp(src_file, dst_file) == 0)) ? TRUE : FALSE;
FILE* srcp = NULL;
FILE* dstp = NULL;
if(isSameFile) {
srcp = fopen(src_file, "r+b");
dstp = srcp;
}
else {
srcp = fopen(src_file, "rb");
if(dst_file) {
dstp = fopen(dst_file, "wb");
}
}
if(!srcp || (dst_file && !dstp)) {
if(!srcp) {
FreeImage_OutputMessageProc(FIF_JPEG, "Cannot open \"%s\" for reading", src_file);
} else {
FreeImage_OutputMessageProc(FIF_JPEG, "Cannot open \"%s\" for writing", dst_file);
}
closeStdIO(srcp, dstp);
return FALSE;
}
if(FreeImage_GetFileTypeFromHandle(&io, srcp) != FIF_JPEG) {
FreeImage_OutputMessageProc(FIF_JPEG, " Source file \"%s\" is not jpeg", src_file);
closeStdIO(srcp, dstp);
return FALSE;
}
*dst_io = io;
*src_handle = srcp;
*dst_handle = dstp;
return TRUE;
}
开发者ID:Remotion,项目名称:freeimage,代码行数:46,代码来源:JPEGTransform.cpp
示例2: ls_jpeg_output_message
ls_jpeg_output_message (j_common_ptr cinfo) {
char buffer[JMSG_LENGTH_MAX];
// create the message
(*cinfo->err->format_message)(cinfo, buffer);
// send it to user's message proc
FreeImage_OutputMessageProc(FIF_JPEG, buffer);
}
开发者ID:Remotion,项目名称:freeimage,代码行数:8,代码来源:JPEGTransform.cpp
示例3: Load
static FIBITMAP * DLL_CALLCONV
Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
if (handle != NULL) {
BITMAPFILEHEADER bitmapfileheader;
DWORD type = 0;
BYTE magic[2];
// we use this offset value to make seemingly absolute seeks relative in the file
long offset_in_file = io->tell_proc(handle);
// read the magic
io->read_proc(&magic, sizeof(magic), 1, handle);
// compare the magic with the number we know
// somebody put a comment here explaining the purpose of this loop
while (memcmp(&magic, "BA", 2) == 0) {
io->read_proc(&bitmapfileheader.bfSize, sizeof(DWORD), 1, handle);
io->read_proc(&bitmapfileheader.bfReserved1, sizeof(WORD), 1, handle);
io->read_proc(&bitmapfileheader.bfReserved2, sizeof(WORD), 1, handle);
io->read_proc(&bitmapfileheader.bfOffBits, sizeof(DWORD), 1, handle);
io->read_proc(&magic, sizeof(magic), 1, handle);
}
// read the fileheader
io->seek_proc(handle, 0 - sizeof(magic), SEEK_CUR);
io->read_proc(&bitmapfileheader, sizeof(BITMAPFILEHEADER), 1, handle);
#ifdef FREEIMAGE_BIGENDIAN
SwapFileHeader(&bitmapfileheader);
#endif
// read the first byte of the infoheader
io->read_proc(&type, sizeof(DWORD), 1, handle);
io->seek_proc(handle, 0 - sizeof(DWORD), SEEK_CUR);
#ifdef FREEIMAGE_BIGENDIAN
SwapLong(&type);
#endif
// call the appropriate load function for the found bitmap type
if (type == 40)
return LoadWindowsBMP(io, handle, flags, offset_in_file + bitmapfileheader.bfOffBits);
if (type == 12)
return LoadOS21XBMP(io, handle, flags, offset_in_file + bitmapfileheader.bfOffBits);
if (type <= 64)
return LoadOS22XBMP(io, handle, flags, offset_in_file + bitmapfileheader.bfOffBits);
FreeImage_OutputMessageProc(s_format_id, "unknown bmp subtype with id %d", type);
}
return NULL;
}
开发者ID:MichaelH13,项目名称:sdkpub,代码行数:58,代码来源:PluginBMP.cpp
示例4: compression
/**
Save using EXR_LC compression (works only with RGB[A]F images)
*/
static BOOL
SaveAsEXR_LC(C_OStream& ostream, FIBITMAP *dib, Imf::Header& header, int width, int height) {
int x, y;
Imf::RgbaChannels rgbaChannels;
try {
FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(dib);
// convert from float to half
Imf::Array2D<Imf::Rgba> pixels(height, width);
switch(image_type) {
case FIT_RGBF:
rgbaChannels = Imf::WRITE_YC;
for(y = 0; y < height; y++) {
FIRGBF *src_bits = (FIRGBF*)FreeImage_GetScanLine(dib, height - 1 - y);
for(x = 0; x < width; x++) {
Imf::Rgba &dst_bits = pixels[y][x];
dst_bits.r = src_bits[x].red;
dst_bits.g = src_bits[x].green;
dst_bits.b = src_bits[x].blue;
}
}
break;
case FIT_RGBAF:
rgbaChannels = Imf::WRITE_YCA;
for(y = 0; y < height; y++) {
FIRGBAF *src_bits = (FIRGBAF*)FreeImage_GetScanLine(dib, height - 1 - y);
for(x = 0; x < width; x++) {
Imf::Rgba &dst_bits = pixels[y][x];
dst_bits.r = src_bits[x].red;
dst_bits.g = src_bits[x].green;
dst_bits.b = src_bits[x].blue;
dst_bits.a = src_bits[x].alpha;
}
}
break;
default:
THROW (Iex::IoExc, "Bad image type");
break;
}
// write the data
Imf::RgbaOutputFile file(ostream, header, rgbaChannels);
file.setFrameBuffer (&pixels[0][0], 1, width);
file.writePixels (height);
return TRUE;
} catch(Iex::BaseExc & e) {
FreeImage_OutputMessageProc(s_format_id, e.what());
return FALSE;
}
}
开发者ID:respu,项目名称:xsilium-engine,代码行数:59,代码来源:PluginEXR.cpp
示例5: rgbe_Error
/**
Default error routine. change this to change error handling
*/
static BOOL
rgbe_Error(rgbe_error_code error_code, const char *msg) {
switch (error_code) {
case rgbe_read_error:
FreeImage_OutputMessageProc(s_format_id, "RGBE read error");
break;
case rgbe_write_error:
FreeImage_OutputMessageProc(s_format_id, "RGBE write error");
break;
case rgbe_format_error:
FreeImage_OutputMessageProc(s_format_id, "RGBE bad file format: %s\n", msg);
break;
default:
case rgbe_memory_error:
FreeImage_OutputMessageProc(s_format_id, "RGBE error: %s\n",msg);
}
return FALSE;
}
开发者ID:FlyApple,项目名称:_3rdParty,代码行数:22,代码来源:PluginHDR.cpp
示例6: Load
static FIBITMAP * DLL_CALLCONV
Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
FIBITMAP *dib = NULL;
if(!handle) {
return NULL;
}
BOOL header_only = (flags & FIF_LOAD_NOPIXELS) == FIF_LOAD_NOPIXELS;
try {
rgbeHeaderInfo header_info;
unsigned width, height;
// Read the header
if(rgbe_ReadHeader(io, handle, &width, &height, &header_info) == FALSE) {
return NULL;
}
// allocate a RGBF image
dib = FreeImage_AllocateHeaderT(header_only, FIT_RGBF, width, height);
if(!dib) {
throw FI_MSG_ERROR_MEMORY;
}
// set the metadata as comments
rgbe_ReadMetadata(dib, &header_info);
if(header_only) {
// header only mode
return dib;
}
// read the image pixels and fill the dib
for(unsigned y = 0; y < height; y++) {
FIRGBF *scanline = (FIRGBF*)FreeImage_GetScanLine(dib, height - 1 - y);
if(!rgbe_ReadPixels_RLE(io, handle, scanline, width, 1)) {
FreeImage_Unload(dib);
return NULL;
}
}
}
catch(const char *text) {
if(dib != NULL) {
FreeImage_Unload(dib);
}
FreeImage_OutputMessageProc(s_format_id, text);
}
return dib;
}
开发者ID:FlyApple,项目名称:_3rdParty,代码行数:54,代码来源:PluginHDR.cpp
示例7: libraw_LoadEmbeddedPreview
/**
Get the embedded JPEG preview image from RAW picture with included Exif Data.
@param RawProcessor Libraw handle
@param flags JPEG load flags
@return Returns the loaded dib if successfull, returns NULL otherwise
*/
static FIBITMAP *
libraw_LoadEmbeddedPreview(LibRaw *RawProcessor, int flags) {
FIBITMAP *dib = NULL;
libraw_processed_image_t *thumb_image = NULL;
try {
// unpack data
if(RawProcessor->unpack_thumb() != LIBRAW_SUCCESS) {
// run silently "LibRaw : failed to run unpack_thumb"
return NULL;
}
// retrieve thumb image
int error_code = 0;
thumb_image = RawProcessor->dcraw_make_mem_thumb(&error_code);
if(thumb_image) {
if(thumb_image->type != LIBRAW_IMAGE_BITMAP) {
// attach the binary data to a memory stream
FIMEMORY *hmem = FreeImage_OpenMemory((BYTE*)thumb_image->data, (DWORD)thumb_image->data_size);
// get the file type
FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(hmem, 0);
if(fif == FIF_JPEG) {
// rotate according to Exif orientation
flags |= JPEG_EXIFROTATE;
}
// load an image from the memory stream
dib = FreeImage_LoadFromMemory(fif, hmem, flags);
// close the stream
FreeImage_CloseMemory(hmem);
} else if((flags & FIF_LOAD_NOPIXELS) != FIF_LOAD_NOPIXELS) {
// convert processed data to output dib
dib = libraw_ConvertProcessedImageToDib(thumb_image);
}
} else {
throw "LibRaw : failed to run dcraw_make_mem_thumb";
}
// clean-up and return
RawProcessor->dcraw_clear_mem(thumb_image);
return dib;
} catch(const char *text) {
// clean-up and return
if(thumb_image) {
RawProcessor->dcraw_clear_mem(thumb_image);
}
if(text != NULL) {
FreeImage_OutputMessageProc(s_format_id, text);
}
}
return NULL;
}
开发者ID:TLeonardUK,项目名称:MicroBuild,代码行数:60,代码来源:PluginRAW.cpp
示例8: FreeImage_CloneTag
FITAG * DLL_CALLCONV
FreeImage_CloneTag(FITAG *tag) {
if(!tag) return NULL;
// allocate a new tag
FITAG *clone = FreeImage_CreateTag();
if(!clone) return NULL;
try {
// copy the tag
FITAGHEADER *src_tag = (FITAGHEADER *)tag->data;
FITAGHEADER *dst_tag = (FITAGHEADER *)clone->data;
// tag ID
dst_tag->id = src_tag->id;
// tag key
if(src_tag->key) {
dst_tag->key = (char*)malloc((strlen(src_tag->key) + 1) * sizeof(char));
if(!dst_tag->key) {
throw FI_MSG_ERROR_MEMORY;
}
strcpy(dst_tag->key, src_tag->key);
}
// tag description
if(src_tag->description) {
dst_tag->description = (char*)malloc((strlen(src_tag->description) + 1) * sizeof(char));
if(!dst_tag->description) {
throw FI_MSG_ERROR_MEMORY;
}
strcpy(dst_tag->description, src_tag->description);
}
// tag data type
dst_tag->type = src_tag->type;
// tag count
dst_tag->count = src_tag->count;
// tag length
dst_tag->length = src_tag->length;
// tag value
dst_tag->value = (BYTE*)malloc(src_tag->length * sizeof(BYTE));
if(!dst_tag->value) {
throw FI_MSG_ERROR_MEMORY;
}
memcpy(dst_tag->value, src_tag->value, src_tag->length);
return clone;
} catch(const char *message) {
FreeImage_DeleteTag(clone);
FreeImage_OutputMessageProc(FIF_UNKNOWN, message);
return NULL;
}
}
开发者ID:respu,项目名称:xsilium-engine,代码行数:52,代码来源:FreeImageTag.cpp
示例9: libraw_ConvertProcessedImageToDib
/**
Convert a processed raw image to a FIBITMAP
@param image Processed raw image
@return Returns the converted dib if successfull, returns NULL otherwise
@see libraw_LoadEmbeddedPreview
*/
static FIBITMAP *
libraw_ConvertProcessedImageToDib(libraw_processed_image_t *image) {
FIBITMAP *dib = NULL;
try {
unsigned width = image->width;
unsigned height = image->height;
unsigned bpp = image->bits;
if(bpp == 16) {
// allocate output dib
dib = FreeImage_AllocateT(FIT_RGB16, width, height);
if(!dib) {
throw FI_MSG_ERROR_DIB_MEMORY;
}
// write data
WORD *raw_data = (WORD*)image->data;
for(unsigned y = 0; y < height; y++) {
FIRGB16 *output = (FIRGB16*)FreeImage_GetScanLine(dib, height - 1 - y);
for(unsigned x = 0; x < width; x++) {
output[x].red = raw_data[0];
output[x].green = raw_data[1];
output[x].blue = raw_data[2];
raw_data += 3;
}
}
} else if(bpp == 8) {
// allocate output dib
dib = FreeImage_AllocateT(FIT_BITMAP, width, height, 24);
if(!dib) {
throw FI_MSG_ERROR_DIB_MEMORY;
}
// write data
BYTE *raw_data = (BYTE*)image->data;
for(unsigned y = 0; y < height; y++) {
RGBTRIPLE *output = (RGBTRIPLE*)FreeImage_GetScanLine(dib, height - 1 - y);
for(unsigned x = 0; x < width; x++) {
output[x].rgbtRed = raw_data[0];
output[x].rgbtGreen = raw_data[1];
output[x].rgbtBlue = raw_data[2];
raw_data += 3;
}
}
}
return dib;
} catch(const char *text) {
FreeImage_Unload(dib);
FreeImage_OutputMessageProc(s_format_id, text);
return NULL;
}
}
开发者ID:TLeonardUK,项目名称:MicroBuild,代码行数:58,代码来源:PluginRAW.cpp
示例10: marker
/**
Read JPEG_APP1 marker (Exif profile)
@param dib Input FIBITMAP
@param dataptr Pointer to the APP1 marker
@param datalen APP1 marker length
@return Returns TRUE if successful, FALSE otherwise
*/
BOOL
jpeg_read_exif_profile(FIBITMAP *dib, const BYTE *dataptr, unsigned int datalen) {
// marker identifying string for Exif = "Exif\0\0"
BYTE exif_signature[6] = { 0x45, 0x78, 0x69, 0x66, 0x00, 0x00 };
BYTE lsb_first[4] = { 0x49, 0x49, 0x2A, 0x00 }; // Intel order
BYTE msb_first[4] = { 0x4D, 0x4D, 0x00, 0x2A }; // Motorola order
unsigned int length = datalen;
BYTE *profile = (BYTE*)dataptr;
// verify the identifying string
if(memcmp(exif_signature, profile, sizeof(exif_signature)) == 0) {
// Exif profile
profile += sizeof(exif_signature);
length -= sizeof(exif_signature);
// check the endianess order
BOOL bMotorolaOrder = TRUE;
if(memcmp(profile, lsb_first, sizeof(lsb_first)) == 0) {
// Exif section in Intel order
bMotorolaOrder = FALSE;
} else {
if(memcmp(profile, msb_first, sizeof(msb_first)) == 0) {
// Exif section in Motorola order
bMotorolaOrder = TRUE;
} else {
// Invalid Exif alignment marker
return FALSE;
}
}
// this is the offset to the first IFD
unsigned long first_offset = ReadUint32(bMotorolaOrder, profile + 4);
if (first_offset < 8 || first_offset > 16) {
// This is usually set to 8
// but PENTAX Optio 230 has it set differently, and uses it as offset.
FreeImage_OutputMessageProc(FIF_JPEG, "Exif: Suspicious offset of first IFD value");
return FALSE;
}
// process Exif directories
return jpeg_read_exif_dir(dib, profile, first_offset, length, bMotorolaOrder);
}
return FALSE;
}
开发者ID:MrLobo,项目名称:El-Rayo-de-Zeus,代码行数:58,代码来源:Exif.cpp
示例11: throw
FIBITMAP* psdParser::Load(FreeImageIO *io, fi_handle handle, int s_format_id) {
FIBITMAP *Bitmap = NULL;
try {
if (NULL == handle) {
throw("Cannot open file");
}
if (!_headerInfo.Read(io, handle)) {
throw("Error in header");
}
if (!_colourModeData.Read(io, handle)) {
throw("Error in ColourMode Data");
}
if (!ReadImageResource(io, handle)) {
throw("Error in Image Resource");
}
if (!ReadLayerAndMaskInfoSection(io, handle)) {
throw("Error in Mask Info");
}
Bitmap = ReadImageData(io, handle);
if (NULL == Bitmap) {
throw("Error in Image Data");
}
// set resolution info
if(NULL != Bitmap) {
unsigned res_x = 2835; // 72 dpi
unsigned res_y = 2835; // 72 dpi
if (_bResolutionInfoFilled) {
_resolutionInfo.GetResolutionInfo(res_x, res_y);
}
FreeImage_SetDotsPerMeterX(Bitmap, res_x);
FreeImage_SetDotsPerMeterY(Bitmap, res_y);
}
// set ICC profile
if(NULL != _iccProfile._ProfileData) {
FreeImage_CreateICCProfile(Bitmap, _iccProfile._ProfileData, _iccProfile._ProfileSize);
}
} catch(const char *text) {
FreeImage_OutputMessageProc(s_format_id, text);
}
return Bitmap;
}
开发者ID:MrLobo,项目名称:El-Rayo-de-Zeus,代码行数:51,代码来源:PSDParser.cpp
示例12: libraw_ConvertProcessedRawToDib
/**
Convert a processed raw data array to a FIBITMAP
@param RawProcessor LibRaw handle containing the processed raw image
@return Returns the converted dib if successfull, returns NULL otherwise
*/
static FIBITMAP *
libraw_ConvertProcessedRawToDib(LibRaw *RawProcessor) {
FIBITMAP *dib = NULL;
int width, height, colors, bpp;
try {
int bgr = 0; // pixel copy order: RGB if (bgr == 0) and BGR otherwise
// get image info
RawProcessor->get_mem_image_format(&width, &height, &colors, &bpp);
// only 3-color images supported...
if(colors != 3) {
throw "LibRaw : only 3-color images supported";
}
if(bpp == 16) {
// allocate output dib
dib = FreeImage_AllocateT(FIT_RGB16, width, height);
if(!dib) {
throw FI_MSG_ERROR_DIB_MEMORY;
}
} else if(bpp == 8) {
#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR
bgr = 1; // only useful for FIT_BITMAP types
#endif
// allocate output dib
dib = FreeImage_AllocateT(FIT_BITMAP, width, height, 24);
if(!dib) {
throw FI_MSG_ERROR_DIB_MEMORY;
}
}
// copy post-processed bitmap data into FIBITMAP buffer
if(RawProcessor->copy_mem_image(FreeImage_GetBits(dib), FreeImage_GetPitch(dib), bgr) != LIBRAW_SUCCESS) {
throw "LibRaw : failed to copy data into dib";
}
// flip vertically
FreeImage_FlipVertical(dib);
return dib;
} catch(const char *text) {
FreeImage_Unload(dib);
FreeImage_OutputMessageProc(s_format_id, text);
return NULL;
}
}
开发者ID:TLeonardUK,项目名称:MicroBuild,代码行数:56,代码来源:PluginRAW.cpp
示例13: bitdepth
/**
Load raw data and convert to FIBITMAP
@param RawProcessor Libraw handle
@param bitspersample Output bitdepth (8- or 16-bit)
@return Returns the loaded dib if successfull, returns NULL otherwise
*/
static FIBITMAP *
libraw_LoadRawData(LibRaw *RawProcessor, int bitspersample) {
FIBITMAP *dib = NULL;
try {
// set decoding parameters
// -----------------------
// (-6) 16-bit or 8-bit
RawProcessor->imgdata.params.output_bps = bitspersample;
// (-g power toe_slope)
if(bitspersample == 16) {
// set -g 1 1 for linear curve
RawProcessor->imgdata.params.gamm[0] = 1;
RawProcessor->imgdata.params.gamm[1] = 1;
} else if(bitspersample == 8) {
// by default settings for rec. BT.709 are used: power 2.222 (i.e. gamm[0]=1/2.222) and slope 4.5
RawProcessor->imgdata.params.gamm[0] = 1/2.222;
RawProcessor->imgdata.params.gamm[1] = 4.5;
}
// (-W) Don't use automatic increase of brightness by histogram
RawProcessor->imgdata.params.no_auto_bright = 1;
// (-a) Use automatic white balance obtained after averaging over the entire image
RawProcessor->imgdata.params.use_auto_wb = 1;
// (-q 3) Adaptive homogeneity-directed demosaicing algorithm (AHD)
RawProcessor->imgdata.params.user_qual = 3;
// -----------------------
// unpack data
if(RawProcessor->unpack() != LIBRAW_SUCCESS) {
throw "LibRaw : failed to unpack data";
}
// process data (... most consuming task ...)
if(RawProcessor->dcraw_process() != LIBRAW_SUCCESS) {
throw "LibRaw : failed to process data";
}
// retrieve processed image
dib = libraw_ConvertProcessedRawToDib(RawProcessor);
return dib;
} catch(const char *text) {
FreeImage_OutputMessageProc(s_format_id, text);
return NULL;
}
}
开发者ID:TLeonardUK,项目名称:MicroBuild,代码行数:55,代码来源:PluginRAW.cpp
示例14: mymngerror
mng_bool
mymngerror(mng_handle mng, mng_int32 code, mng_int8 severity, mng_chunkid chunktype, mng_uint32 chunkseq, mng_int32 extra1, mng_int32 extra2, mng_pchar text) {
char msg[256];
if((code == MNG_SEQUENCEERROR) && (chunktype == MNG_UINT_TERM)) {
// ignore sequence error for TERM
return MNG_TRUE;
}
if(text) {
// text can be null depending on compiler options
sprintf(msg, "Error reported by libmng (%d)\r\n\r\n%s", code, text);
} else {
sprintf(msg, "Error %d reported by libmng", code);
}
FreeImage_OutputMessageProc(s_format_id, msg);
return MNG_FALSE;
}
开发者ID:Ayane,项目名称:BLPConverter,代码行数:16,代码来源:PluginMNG.cpp
示例15: FreeImage_ZLibCompress
/**
Compresses a source buffer into a target buffer, using the ZLib library.
Upon entry, target_size is the total size of the destination buffer,
which must be at least 0.1% larger than source_size plus 12 bytes.
@param target Destination buffer
@param target_size Size of the destination buffer, in bytes
@param source Source buffer
@param source_size Size of the source buffer, in bytes
@return Returns the actual size of the compressed buffer, returns 0 if an error occured
@see FreeImage_ZLibUncompress
*/
DWORD DLL_CALLCONV
FreeImage_ZLibCompress(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size) {
uLongf dest_len = (uLongf)target_size;
int zerr = compress(target, &dest_len, source, source_size);
switch(zerr) {
case Z_MEM_ERROR: // not enough memory
case Z_BUF_ERROR: // not enough room in the output buffer
FreeImage_OutputMessageProc(FIF_UNKNOWN, "Zlib error : %s", zError(zerr));
return 0;
case Z_OK:
return dest_len;
}
return 0;
}
开发者ID:Ali-il,项目名称:gamekit,代码行数:28,代码来源:ZLibInterface.cpp
示例16: FreeImage_ZLibUncompress
/**
Decompresses a source buffer into a target buffer, using the ZLib library.
Upon entry, target_size is the total size of the destination buffer,
which must be large enough to hold the entire uncompressed data.
The size of the uncompressed data must have been saved previously by the compressor
and transmitted to the decompressor by some mechanism outside the scope of this
compression library.
@param target Destination buffer
@param target_size Size of the destination buffer, in bytes
@param source Source buffer
@param source_size Size of the source buffer, in bytes
@return Returns the actual size of the uncompressed buffer, returns 0 if an error occured
@see FreeImage_ZLibCompress
*/
DWORD DLL_CALLCONV
FreeImage_ZLibUncompress(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size) {
DWORD dest_len = target_size;
int zerr = uncompress(target, &dest_len, source, source_size);
switch(zerr) {
case Z_MEM_ERROR: // not enough memory
case Z_BUF_ERROR: // not enough room in the output buffer
case Z_DATA_ERROR: // input data was corrupted
FreeImage_OutputMessageProc(FIF_UNKNOWN, "Zlib error : %s", zError(zerr));
return 0;
case Z_OK:
return dest_len;
}
return 0;
}
开发者ID:BackupTheBerlios,项目名称:tap-svn,代码行数:32,代码来源:ZLibInterface.cpp
示例17: SetPreviewImage
/**
Set the preview image using the dib embedded thumbnail
*/
static BOOL
SetPreviewImage(FIBITMAP *dib, Imf::Header& header) {
if(!FreeImage_GetThumbnail(dib)) {
return FALSE;
}
FIBITMAP* thumbnail = FreeImage_GetThumbnail(dib);
if((FreeImage_GetImageType(thumbnail) != FIT_BITMAP) || (FreeImage_GetBPP(thumbnail) != 32)) {
// invalid thumbnail - ignore it
FreeImage_OutputMessageProc(s_format_id, FI_MSG_WARNING_INVALID_THUMBNAIL);
} else {
const unsigned thWidth = FreeImage_GetWidth(thumbnail);
const unsigned thHeight = FreeImage_GetHeight(thumbnail);
Imf::PreviewImage preview(thWidth, thHeight);
// copy thumbnail to 32-bit RGBA preview image
const BYTE* src_line = FreeImage_GetScanLine(thumbnail, thHeight - 1);
Imf::PreviewRgba* dst_line = preview.pixels();
const unsigned srcPitch = FreeImage_GetPitch(thumbnail);
for (unsigned y = 0; y < thHeight; y++) {
const RGBQUAD* src_pixel = (RGBQUAD*)src_line;
Imf::PreviewRgba* dst_pixel = dst_line;
for(unsigned x = 0; x < thWidth; x++) {
dst_pixel->r = src_pixel->rgbRed;
dst_pixel->g = src_pixel->rgbGreen;
dst_pixel->b = src_pixel->rgbBlue;
dst_pixel->a = src_pixel->rgbReserved;
src_pixel++;
dst_pixel++;
}
src_line -= srcPitch;
dst_line += thWidth;
}
header.setPreviewImage(preview);
}
return TRUE;
}
开发者ID:respu,项目名称:xsilium-engine,代码行数:48,代码来源:PluginEXR.cpp
示例18: FreeImage_SaveToMemory
BOOL DLL_CALLCONV
FreeImage_SaveToMemory(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FIMEMORY *stream, int flags) {
if (stream) {
FreeImageIO io;
SetMemoryIO(&io);
FIMEMORYHEADER *mem_header = (FIMEMORYHEADER*)(stream->data);
if(mem_header->delete_me == TRUE) {
return FreeImage_SaveToHandle(fif, dib, &io, (fi_handle)stream, flags);
} else {
// do not save in a user buffer
FreeImage_OutputMessageProc(fif, "Memory buffer is read only");
}
}
return FALSE;
}
开发者ID:12019,项目名称:svn.gov.pt,代码行数:18,代码来源:MemoryIO.cpp
示例19: FreeImage_WriteMemory
/**
Writes data to a memory stream.
@param buffer Pointer to data to be written
@param size Item size in bytes
@param count Maximum number of items to be written
@param stream Pointer to FIMEMORY structure
@return Returns the number of full items actually written, which may be less than count if an error occurs
*/
unsigned DLL_CALLCONV
FreeImage_WriteMemory(const void *buffer, unsigned size, unsigned count, FIMEMORY *stream) {
if (stream != NULL) {
FreeImageIO io;
SetMemoryIO(&io);
FIMEMORYHEADER *mem_header = (FIMEMORYHEADER*)(((FIMEMORY*)stream)->data);
if(mem_header->delete_me == TRUE) {
return io.write_proc((void *)buffer, size, count, stream);
} else {
// do not write in a user buffer
FreeImage_OutputMessageProc(FIF_UNKNOWN, "Memory buffer is read only");
}
}
return 0;
}
开发者ID:12019,项目名称:svn.gov.pt,代码行数:26,代码来源:MemoryIO.cpp
示例20: Load
static FIBITMAP * DLL_CALLCONV
Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
FIBITMAP *dib = NULL;
if(handle) {
try {
rgbeHeaderInfo header_info;
unsigned width, height;
// Read the header
if(rgbe_ReadHeader(io, handle, &width, &height, &header_info) == FALSE)
return NULL;
// allocate a RGBF image
dib = FreeImage_AllocateT(FIT_RGBF, width, height);
if(!dib) {
throw "Memory allocation failed";
}
// read the image pixels and fill the dib
for(unsigned y = 0; y < height; y++) {
FIRGBF *scanline = (FIRGBF*)FreeImage_GetScanLine(dib, height - 1 - y);
if(!rgbe_ReadPixels_RLE(io, handle, scanline, width, 1)) {
FreeImage_Unload(dib);
return NULL;
}
}
// set the metadata as comments
rgbe_ReadMetadata(dib, &header_info);
}
catch(const char *text) {
if(dib != NULL) {
FreeImage_Unload(dib);
}
FreeImage_OutputMessageProc(s_format_id, text);
}
}
return dib;
}
开发者ID:BackupTheBerlios,项目名称:mimplugins-svn,代码行数:44,代码来源:PluginHDR.cpp
注:本文中的FreeImage_OutputMessageProc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论