Commit e1d030ca authored by Amy spark's avatar Amy spark 👉
Browse files

TIFF: support sub IFD offsets

BUG: 459840
(cherry picked from commit 96ee473d)
parent 40f3f450
Pipeline #241302 passed with stage
in 67 minutes and 49 seconds
......@@ -52,6 +52,8 @@
struct KisTiffBasicInfo {
uint32_t width{};
uint32_t height{};
float x{};
float y{};
float xres{};
float yres{};
uint16_t depth{};
......@@ -1406,6 +1408,9 @@ KisTIFFImport::readImageFromTiff(KisDocument *m_doc,
m_image->addNode(KisNodeSP(layer), m_image->rootLayer().data());
layer->paintDevice()->setX(static_cast<int>(basicInfo.x * basicInfo.xres));
layer->paintDevice()->setY(static_cast<int>(basicInfo.y * basicInfo.yres));
// Process rotation before handing image over
// https://developer.apple.com/documentation/imageio/cgimagepropertyorientation
switch (orientation) {
......@@ -1502,6 +1507,16 @@ KisImportExportErrorCode KisTIFFImport::readTIFFDirectory(KisDocument *m_doc,
basicInfo.yres = 100;
}
if (TIFFGetField(image, TIFFTAG_XPOSITION, &basicInfo.x) == 0) {
dbgFile << "Image does not define a horizontal offset";
basicInfo.x = 0;
}
if (TIFFGetField(image, TIFFTAG_YPOSITION, &basicInfo.y) == 0) {
dbgFile << "Image does not define a vertical offset";
basicInfo.y = 0;
}
if ((TIFFGetField(image, TIFFTAG_BITSPERSAMPLE, &basicInfo.depth) == 0)) {
dbgFile << "Image does not define its depth";
basicInfo.depth = 1;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment