mirror of
https://github.com/Evolution-X/external_piex
synced 2026-01-28 01:43:28 +00:00
Update PIEX
This commit is contained in:
13
src/piex.cc
13
src/piex.cc
@@ -419,19 +419,26 @@ Error DngGetPreviewData(StreamInterface* stream,
|
|||||||
kTiffTagStripByteCounts, kTiffTagStripOffsets, kTiffTagSubIfd};
|
kTiffTagStripByteCounts, kTiffTagStripOffsets, kTiffTagSubIfd};
|
||||||
|
|
||||||
TiffContent tiff_content;
|
TiffContent tiff_content;
|
||||||
const std::uint32_t kNumberOfIfds = 4;
|
const std::uint32_t kNumberOfIfds = 3;
|
||||||
if (!GetPreviewData(extended_tags, 0, kNumberOfIfds, stream, &tiff_content,
|
if (!GetPreviewData(extended_tags, 0, kNumberOfIfds, stream, &tiff_content,
|
||||||
preview_image_data)) {
|
preview_image_data)) {
|
||||||
return kFail;
|
return kFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const TiffDirectory& tiff_directory = tiff_content.tiff_directory[0];
|
||||||
|
|
||||||
|
if (!GetFullCropDimension(tiff_directory, &preview_image_data->full_width,
|
||||||
|
&preview_image_data->full_height)) {
|
||||||
|
return kFail;
|
||||||
|
}
|
||||||
|
|
||||||
// Find the jpeg compressed thumbnail and preview image.
|
// Find the jpeg compressed thumbnail and preview image.
|
||||||
Image preview;
|
Image preview;
|
||||||
Image thumbnail;
|
Image thumbnail;
|
||||||
|
|
||||||
// Search for images in IFD0
|
// Search for images in IFD0
|
||||||
Image temp_image;
|
Image temp_image;
|
||||||
if (GetImageData(tiff_content.tiff_directory[0], stream, &temp_image)) {
|
if (GetImageData(tiff_directory, stream, &temp_image)) {
|
||||||
if (IsThumbnail(temp_image, kDngThumbnailMaxDimension)) {
|
if (IsThumbnail(temp_image, kDngThumbnailMaxDimension)) {
|
||||||
thumbnail = temp_image;
|
thumbnail = temp_image;
|
||||||
} else if (temp_image.format == Image::kJpegCompressed) {
|
} else if (temp_image.format == Image::kJpegCompressed) {
|
||||||
@@ -440,7 +447,7 @@ Error DngGetPreviewData(StreamInterface* stream,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Search for images in other IFDs
|
// Search for images in other IFDs
|
||||||
for (const auto& ifd : tiff_content.tiff_directory[0].GetSubDirectories()) {
|
for (const auto& ifd : tiff_directory.GetSubDirectories()) {
|
||||||
if (GetImageData(ifd, stream, &temp_image)) {
|
if (GetImageData(ifd, stream, &temp_image)) {
|
||||||
// Try to find the largest thumbnail/preview.
|
// Try to find the largest thumbnail/preview.
|
||||||
if (IsThumbnail(temp_image, kDngThumbnailMaxDimension)) {
|
if (IsThumbnail(temp_image, kDngThumbnailMaxDimension)) {
|
||||||
|
|||||||
@@ -557,17 +557,7 @@ bool GetFullDimension32(const TiffDirectory& tiff_directory,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tiff_directory.Has(kExifTagDefaultCropSize)) {
|
if (tiff_directory.Has(kExifTagDefaultCropSize)) {
|
||||||
std::vector<std::uint32_t> crop(2);
|
if (!GetFullCropDimension(tiff_directory, width, height)) {
|
||||||
std::vector<Rational> crop_rational(2);
|
|
||||||
if (tiff_directory.Get(kExifTagDefaultCropSize, &crop)) {
|
|
||||||
*width = crop[0];
|
|
||||||
*height = crop[1];
|
|
||||||
} else if (tiff_directory.Get(kExifTagDefaultCropSize, &crop_rational) &&
|
|
||||||
crop_rational[0].denominator != 0 &&
|
|
||||||
crop_rational[1].denominator != 0) {
|
|
||||||
*width = crop_rational[0].numerator / crop_rational[0].denominator;
|
|
||||||
*height = crop_rational[1].numerator / crop_rational[1].denominator;
|
|
||||||
} else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (tiff_directory.Has(kExifTagWidth) &&
|
} else if (tiff_directory.Has(kExifTagWidth) &&
|
||||||
@@ -604,6 +594,27 @@ bool GetFullDimension32(const TiffDirectory& tiff_directory,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GetFullCropDimension(const tiff_directory::TiffDirectory& tiff_directory,
|
||||||
|
std::uint32_t* width, std::uint32_t* height) {
|
||||||
|
if (tiff_directory.Has(kExifTagDefaultCropSize)) {
|
||||||
|
std::vector<std::uint32_t> crop(2);
|
||||||
|
std::vector<Rational> crop_rational(2);
|
||||||
|
if (tiff_directory.Get(kExifTagDefaultCropSize, &crop)) {
|
||||||
|
*width = crop[0];
|
||||||
|
*height = crop[1];
|
||||||
|
} else if (tiff_directory.Get(kExifTagDefaultCropSize, &crop_rational) &&
|
||||||
|
crop_rational[0].denominator != 0 &&
|
||||||
|
crop_rational[1].denominator != 0) {
|
||||||
|
*width = crop_rational[0].numerator / crop_rational[0].denominator;
|
||||||
|
*height = crop_rational[1].numerator / crop_rational[1].denominator;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
TiffParser::TiffParser(StreamInterface* stream) : stream_(stream) {}
|
TiffParser::TiffParser(StreamInterface* stream) : stream_(stream) {}
|
||||||
|
|
||||||
TiffParser::TiffParser(StreamInterface* stream, const std::uint32_t offset)
|
TiffParser::TiffParser(StreamInterface* stream, const std::uint32_t offset)
|
||||||
|
|||||||
@@ -162,6 +162,11 @@ bool GetExifOrientation(StreamInterface* stream, const std::uint32_t offset,
|
|||||||
bool GetFullDimension32(const tiff_directory::TiffDirectory& tiff_directory,
|
bool GetFullDimension32(const tiff_directory::TiffDirectory& tiff_directory,
|
||||||
std::uint32_t* width, std::uint32_t* height);
|
std::uint32_t* width, std::uint32_t* height);
|
||||||
|
|
||||||
|
// Reads the width and height of the crop information if available.
|
||||||
|
// Returns false if an error occured.
|
||||||
|
bool GetFullCropDimension(const tiff_directory::TiffDirectory& tiff_directory,
|
||||||
|
std::uint32_t* width, std::uint32_t* height);
|
||||||
|
|
||||||
// Enables us to parse through data that complies to the Tiff/EP specification.
|
// Enables us to parse through data that complies to the Tiff/EP specification.
|
||||||
class TiffParser {
|
class TiffParser {
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user