From 3dddd080e0b56fe9b0c3d6d4fe80d72dddee4bc9 Mon Sep 17 00:00:00 2001 From: Utkarsh khambra Date: Thu, 22 Sep 2022 12:41:58 +0530 Subject: [PATCH] Fixed sixel image rendering with different aspect ratios --- metainfo.xml | 1 + src/terminal/SixelParser.cpp | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/metainfo.xml b/metainfo.xml index e4baa5d523..0e02c6c9de 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -104,6 +104,7 @@ diff --git a/src/terminal/SixelParser.cpp b/src/terminal/SixelParser.cpp index da5d75f05b..ab5598569d 100644 --- a/src/terminal/SixelParser.cpp +++ b/src/terminal/SixelParser.cpp @@ -412,13 +412,19 @@ void SixelImageBuilder::write(CellLocation const& _coord, RGBColor const& _value size_.width = Width::cast_from(_coord.column + 1); } - auto const base = - unbox(_coord.line) * unbox((explicitSize_ ? size_.width : maxSize_.width)) * 4 - + unbox(_coord.column) * 4; - buffer_[base + 0] = _value.red; - buffer_[base + 1] = _value.green; - buffer_[base + 2] = _value.blue; - buffer_[base + 3] = 0xFF; + for (auto i = 0; i < aspectRatio_.nominator; ++i) + { + auto const base = unbox(_coord.line + i) + * unbox((explicitSize_ ? size_.width : maxSize_.width)) * 4 + + unbox(_coord.column) * 4; + for (auto j = 0; j < aspectRatio_.denominator; ++j) + { + buffer_[base + 0 + 4 * static_cast(j)] = _value.red; + buffer_[base + 1 + 4 * static_cast(j)] = _value.green; + buffer_[base + 2 + 4 * static_cast(j)] = _value.blue; + buffer_[base + 3 + 4 * static_cast(j)] = 0xFF; + } + } } } @@ -451,7 +457,7 @@ void SixelImageBuilder::setRaster(int _pan, int _pad, ImageSize _imageSize) size_.width = clamp(_imageSize.width, Width(0), maxSize_.width); size_.height = clamp(_imageSize.height, Height(0), maxSize_.height); - buffer_.resize(size_.area() * 4); + buffer_.resize(size_.area() * static_cast(_pad * _pan) * 4); explicitSize_ = true; }