本文整理匯總了C++中FreeImage_OutputMessageProc函數的典型用法代碼示例。如果您正苦於以下問題:C++ FreeImage_OutputMessageProc函數的具體用法?C++ FreeImage_OutputMessageProc怎麽用?C++ FreeImage_OutputMessageProc使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了FreeImage_OutputMessageProc函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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;
}