diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-05-23 11:57:17 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-05-23 18:16:10 +0200 |
commit | daac48d510a64cfc2ca12a35ee6f54262c8e77dc (patch) | |
tree | e49888d291fe2ef04d0f5948dd8efdac8db763e4 /vcl | |
parent | 95567d6175bccd45f8f954d3b329f73a73a7b8bf (diff) |
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 <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/filter/itiff/itiff.cxx | 40 |
1 files changed, 38 insertions, 2 deletions
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); |