vcl/source/filter/itiff/itiff.cxx |   40 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

New commits:
commit daac48d510a64cfc2ca12a35ee6f54262c8e77dc
Author:     Caolán McNamara <[email protected]>
AuthorDate: Mon May 23 11:57:17 2022 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Mon May 23 18:16:10 2022 +0200

    tiff: reverse row pixels for ORIENTATION_LEFTBOT
    
    and rotate
    
    e.g. novell600797-1.tiff
    
    Change-Id: I03edcc44f86a40f3e005bec1d8b82a0a89cad276
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134817
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/vcl/source/filter/itiff/itiff.cxx 
b/vcl/source/filter/itiff/itiff.cxx
index 90c7bf5f3422..292621ed0b83 100644
--- a/vcl/source/filter/itiff/itiff.cxx
+++ b/vcl/source/filter/itiff/itiff.cxx
@@ -36,6 +36,17 @@ namespace
     {
         SvStream& rStream;
         tsize_t nSize;
+        /*
+            ORIENTATION_TOPLEFT = 1
+            ORIENTATION_TOPRIGHT = 2
+            ORIENTATION_BOTRIGHT = 3
+            ORIENTATION_BOTLEFT = 4
+            ORIENTATION_LEFTTOP = 5
+            ORIENTATION_RIGHTTOP = 6
+            ORIENTATION_RIGHTBOT = 7
+            ORIENTATION_LEFTBOT = 8
+         */
+        uint16_t nOrientation;
 
         tileContigRoutine pOrigContig;
         tileSeparateRoutine pOrigSeparate;
@@ -46,6 +57,7 @@ namespace
         Context(SvStream& rInStream, tsize_t nInSize)
             : rStream(rInStream)
             , nSize(nInSize)
+            , nOrientation(0)
             , pOrigContig(nullptr)
             , pOrigSeparate(nullptr)
             , pWriteAccess(nullptr)
@@ -79,9 +91,20 @@ namespace
             {
                 for (uint32_t nCol = 0; nCol < w; ++nCol)
                 {
-                    pWriteAccess->SetPixel(nDestRow, x + nCol,
+                    uint32_t nDestCol;
+                    switch (nOrientation)
+                    {
+                        case ORIENTATION_LEFTBOT:
+                            nDestCol = x + w - 1 - nCol;
+                            break;
+                        default:
+                            nDestCol = x + nCol;
+                            break;
+                    }
+
+                    pWriteAccess->SetPixel(nDestRow, nDestCol,
                         Color(TIFFGetR(*pSrc), TIFFGetG(*pSrc), 
TIFFGetB(*pSrc)));
-                    pAlphaAccess->SetPixelIndex(nDestRow, x + nCol, 255 - 
TIFFGetA(*pSrc));
+                    pAlphaAccess->SetPixelIndex(nDestRow, nDestCol, 255 - 
TIFFGetA(*pSrc));
                     ++pSrc;
                 }
                 pSrc += skew;
@@ -205,6 +228,9 @@ bool ImportTiffGraphicImport(SvStream& rTIFF, Graphic& 
rGraphic)
             break;
         }
 
+        aContext.nOrientation = 0;
+        TIFFGetField(tif, TIFFTAG_ORIENTATION, &aContext.nOrientation);
+
         Bitmap bitmap(Size(w, h), vcl::PixelFormat::N24_BPP);
         AlphaMask bitmapAlpha(Size(w, h));
 
@@ -255,6 +281,16 @@ bool ImportTiffGraphicImport(SvStream& rTIFF, Graphic& 
rGraphic)
         if (bOk)
         {
             BitmapEx aBitmapEx(bitmap, bitmapAlpha);
+
+            switch (aContext.nOrientation)
+            {
+                case ORIENTATION_LEFTBOT:
+                    aBitmapEx.Rotate(2700_deg10, COL_BLACK);
+                    break;
+                default:
+                    break;
+            }
+
             AnimationBitmap aAnimationBitmap(aBitmapEx, Point(0, 0), 
aBitmapEx.GetSizePixel(),
                                              ANIMATION_TIMEOUT_ON_CLICK, 
Disposal::Back);
             aAnimation.Insert(aAnimationBitmap);

Reply via email to