summaryrefslogtreecommitdiff
path: root/plugins/AdvaImg/src/FreeImage/PluginJPEG.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/AdvaImg/src/FreeImage/PluginJPEG.cpp')
-rw-r--r--plugins/AdvaImg/src/FreeImage/PluginJPEG.cpp106
1 files changed, 3 insertions, 103 deletions
diff --git a/plugins/AdvaImg/src/FreeImage/PluginJPEG.cpp b/plugins/AdvaImg/src/FreeImage/PluginJPEG.cpp
index 1e0237d115..c1b45e6347 100644
--- a/plugins/AdvaImg/src/FreeImage/PluginJPEG.cpp
+++ b/plugins/AdvaImg/src/FreeImage/PluginJPEG.cpp
@@ -656,46 +656,6 @@ jpeg_read_xmp_profile(FIBITMAP *dib, const BYTE *dataptr, unsigned int datalen)
}
/**
- 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
-*/
-static BOOL
-jpeg_read_exif_profile_raw(FIBITMAP *dib, const BYTE *profile, unsigned int length) {
- // marker identifying string for Exif = "Exif\0\0"
- BYTE exif_signature[6] = { 0x45, 0x78, 0x69, 0x66, 0x00, 0x00 };
-
- // verify the identifying string
- if(memcmp(exif_signature, profile, sizeof(exif_signature)) != 0) {
- // not an Exif profile
- return FALSE;
- }
-
- // create a tag
- FITAG *tag = FreeImage_CreateTag();
- if(tag) {
- FreeImage_SetTagID(tag, EXIF_MARKER); // (JPEG_APP0 + 1) => EXIF marker / Adobe XMP marker
- FreeImage_SetTagKey(tag, g_TagLib_ExifRawFieldName);
- FreeImage_SetTagLength(tag, (DWORD)length);
- FreeImage_SetTagCount(tag, (DWORD)length);
- FreeImage_SetTagType(tag, FIDT_BYTE);
- FreeImage_SetTagValue(tag, profile);
-
- // store the tag
- FreeImage_SetMetadata(FIMD_EXIF_RAW, dib, FreeImage_GetTagKey(tag), tag);
-
- // destroy the tag
- FreeImage_DeleteTag(tag);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
Read JFIF "JFXX" extension APP0 marker
@param dib Input FIBITMAP
@param dataptr Pointer to the APP0 marker
@@ -976,14 +936,14 @@ jpeg_write_exif_profile_raw(j_compress_ptr cinfo, FIBITMAP *dib) {
for(DWORD i = 0; i < tag_length; i += 65504L) {
unsigned length = MIN((long)(tag_length - i), 65504L);
-
+
memcpy(profile, tag_value + i, length);
jpeg_write_marker(cinfo, EXIF_MARKER, profile, length);
}
free(profile);
- return TRUE;
+ return TRUE;
}
return FALSE;
@@ -1126,66 +1086,6 @@ store_size_info(FIBITMAP *dib, JDIMENSION width, JDIMENSION height) {
}
}
-// ------------------------------------------------------------
-// Rotate a dib according to Exif info
-// ------------------------------------------------------------
-
-static void
-rotate_exif(FIBITMAP **dib) {
- // check for Exif rotation
- if(FreeImage_GetMetadataCount(FIMD_EXIF_MAIN, *dib)) {
- FIBITMAP *rotated = NULL;
- // process Exif rotation
- FITAG *tag = NULL;
- FreeImage_GetMetadata(FIMD_EXIF_MAIN, *dib, "Orientation", &tag);
- if(tag != NULL) {
- if(FreeImage_GetTagID(tag) == TAG_ORIENTATION) {
- unsigned short orientation = *((unsigned short *)FreeImage_GetTagValue(tag));
- switch (orientation) {
- case 1: // "top, left side" => 0°
- break;
- case 2: // "top, right side" => flip left-right
- FreeImage_FlipHorizontal(*dib);
- break;
- case 3: // "bottom, right side"; => -180°
- rotated = FreeImage_Rotate(*dib, 180);
- FreeImage_Unload(*dib);
- *dib = rotated;
- break;
- case 4: // "bottom, left side" => flip up-down
- FreeImage_FlipVertical(*dib);
- break;
- case 5: // "left side, top" => +90° + flip up-down
- rotated = FreeImage_Rotate(*dib, 90);
- FreeImage_Unload(*dib);
- *dib = rotated;
- FreeImage_FlipVertical(*dib);
- break;
- case 6: // "right side, top" => -90°
- rotated = FreeImage_Rotate(*dib, -90);
- FreeImage_Unload(*dib);
- *dib = rotated;
- break;
- case 7: // "right side, bottom" => -90° + flip up-down
- rotated = FreeImage_Rotate(*dib, -90);
- FreeImage_Unload(*dib);
- *dib = rotated;
- FreeImage_FlipVertical(*dib);
- break;
- case 8: // "left side, bottom" => +90°
- rotated = FreeImage_Rotate(*dib, 90);
- FreeImage_Unload(*dib);
- *dib = rotated;
- break;
- default:
- break;
- }
- }
- }
- }
-}
-
-
// ==========================================================
// Plugin Implementation
// ==========================================================
@@ -1473,7 +1373,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
// check for automatic Exif rotation
if(!header_only && ((flags & JPEG_EXIFROTATE) == JPEG_EXIFROTATE)) {
- rotate_exif(&dib);
+ RotateExif(&dib);
}
// everything went well. return the loaded dib