Alien-FreeImage
view release on metacpan or search on metacpan
src/Source/FreeImage/PluginJXR.cpp view on Meta::CPAN
case FIT_COMPLEX: // array of FICOMPLEX : 2 x 64-bit IEEE floating point
default:
// unsupported format
break;
}
return (*guid_format != GUID_PKPixelFormatDontCare) ? WMP_errSuccess : WMP_errUnsupportedFormat;
}
// ==========================================================
// Metadata loading
// ==========================================================
/**
Read a JPEG-XR IFD as a buffer
@see ReadMetadata
*/
static ERR
ReadProfile(WMPStream* pStream, unsigned cbByteCount, unsigned uOffset, BYTE **ppbProfile) {
// (re-)allocate profile buffer
BYTE *pbProfile = *ppbProfile;
pbProfile = (BYTE*)realloc(pbProfile, cbByteCount);
if(!pbProfile) {
return WMP_errOutOfMemory;
}
// read the profile
if(WMP_errSuccess == pStream->SetPos(pStream, uOffset)) {
if(WMP_errSuccess == pStream->Read(pStream, pbProfile, cbByteCount)) {
*ppbProfile = pbProfile;
return WMP_errSuccess;
}
}
return WMP_errFileIO;
}
/**
Convert a DPKPROPVARIANT to a FITAG, then store the tag as FIMD_EXIF_MAIN
@see ReadDescriptiveMetadata
*/
static BOOL
ReadPropVariant(WORD tag_id, const DPKPROPVARIANT & varSrc, FIBITMAP *dib) {
DWORD dwSize;
if(varSrc.vt == DPKVT_EMPTY) {
return FALSE;
}
// get the tag key
TagLib& s = TagLib::instance();
const char *key = s.getTagFieldName(TagLib::EXIF_MAIN, tag_id, NULL);
if(!key) {
return FALSE;
}
// create a tag
FITAG *tag = FreeImage_CreateTag();
if(tag) {
// set tag ID
FreeImage_SetTagID(tag, tag_id);
// set tag type, count, length and value
switch (varSrc.vt) {
case DPKVT_LPSTR:
FreeImage_SetTagType(tag, FIDT_ASCII);
dwSize = (DWORD)strlen(varSrc.VT.pszVal) + 1;
FreeImage_SetTagCount(tag, dwSize);
FreeImage_SetTagLength(tag, dwSize);
FreeImage_SetTagValue(tag, varSrc.VT.pszVal);
break;
case DPKVT_LPWSTR:
FreeImage_SetTagType(tag, FIDT_UNDEFINED);
dwSize = (DWORD)(sizeof(U16) * (wcslen((wchar_t *) varSrc.VT.pwszVal) + 1)); // +1 for NULL term
FreeImage_SetTagCount(tag, dwSize);
FreeImage_SetTagLength(tag, dwSize);
FreeImage_SetTagValue(tag, varSrc.VT.pwszVal);
break;
case DPKVT_UI2:
FreeImage_SetTagType(tag, FIDT_SHORT);
FreeImage_SetTagCount(tag, 1);
FreeImage_SetTagLength(tag, 2);
FreeImage_SetTagValue(tag, &varSrc.VT.uiVal);
break;
case DPKVT_UI4:
FreeImage_SetTagType(tag, FIDT_LONG);
FreeImage_SetTagCount(tag, 1);
FreeImage_SetTagLength(tag, 4);
FreeImage_SetTagValue(tag, &varSrc.VT.ulVal);
break;
default:
assert(FALSE); // This case is not handled
break;
}
// get the tag desctiption
const char *description = s.getTagDescription(TagLib::EXIF_MAIN, tag_id);
FreeImage_SetTagDescription(tag, description);
// store the tag
FreeImage_SetMetadata(FIMD_EXIF_MAIN, dib, key, tag);
FreeImage_DeleteTag(tag);
}
return TRUE;
}
/**
Read JPEG-XR descriptive metadata and store as EXIF_MAIN metadata
@see ReadPropVariant
*/
static ERR
ReadDescriptiveMetadata(PKImageDecode *pID, FIBITMAP *dib) {
// get Exif TIFF metadata
const DESCRIPTIVEMETADATA *pDescMetadata = &pID->WMP.sDescMetadata;
// convert metadata to FITAG and store into the EXIF_MAIN metadata model
ReadPropVariant(WMP_tagImageDescription, pDescMetadata->pvarImageDescription, dib);
ReadPropVariant(WMP_tagCameraMake, pDescMetadata->pvarCameraMake, dib);
ReadPropVariant(WMP_tagCameraModel, pDescMetadata->pvarCameraModel, dib);
ReadPropVariant(WMP_tagSoftware, pDescMetadata->pvarSoftware, dib);
( run in 1.107 second using v1.01-cache-2.11-cpan-119454b85a5 )