diff --git a/metainfo.xml b/metainfo.xml
index bbdf1f1206..164133d66e 100644
--- a/metainfo.xml
+++ b/metainfo.xml
@@ -107,7 +107,7 @@
- - ...
+ - Fixes corruption of sixel image on high resolution (#1049)
diff --git a/src/vtbackend/Image.cpp b/src/vtbackend/Image.cpp
index 14bdfcf792..024dcc1039 100644
--- a/src/vtbackend/Image.cpp
+++ b/src/vtbackend/Image.cpp
@@ -60,9 +60,9 @@ Image::Data RasterizedImage::fragment(CellLocation pos) const
Image::Data fragData;
fragData.resize(_cellSize.area() * 4); // RGBA
auto const availableWidth =
- min(unbox(_image->width()) - *pixelOffset.column, unbox(_cellSize.width));
+ min(unbox(_image->width()) - unbox(pixelOffset.column), unbox(_cellSize.width));
auto const availableHeight =
- min(unbox(_image->height()) - *pixelOffset.line, unbox(_cellSize.height));
+ min(unbox(_image->height()) - unbox(pixelOffset.line), unbox(_cellSize.height));
// auto const availableSize = Size{availableWidth, availableHeight};
// std::cout << fmt::format(
@@ -90,7 +90,7 @@ Image::Data RasterizedImage::fragment(CellLocation pos) const
for (int y = 0; y < availableHeight; ++y)
{
auto const startOffset = static_cast(
- ((*pixelOffset.line + y) * unbox(_image->width()) + *pixelOffset.column) * 4);
+ ((pixelOffset.line + y) * unbox(_image->width()) + unbox(pixelOffset.column)) * 4);
const auto* const source = &_image->data()[startOffset];
target = copy(source, source + static_cast(availableWidth) * 4, target);
diff --git a/src/vtbackend/Screen.cpp b/src/vtbackend/Screen.cpp
index db09924452..ec9cdf13b7 100644
--- a/src/vtbackend/Screen.cpp
+++ b/src/vtbackend/Screen.cpp
@@ -1887,9 +1887,9 @@ CRISPY_REQUIRES(CellConcept)
void Screen::sixelImage(ImageSize pixelSize, Image::Data&& rgbaData)
{
auto const columnCount =
- ColumnCount::cast_from(ceilf(float(*pixelSize.width) / float(*_state->cellPixelSize.width)));
+ ColumnCount::cast_from(ceil(pixelSize.width.as() / _state->cellPixelSize.width.as()));
auto const lineCount =
- LineCount::cast_from(ceilf(float(*pixelSize.height) / float(*_state->cellPixelSize.height)));
+ LineCount::cast_from(ceil(pixelSize.height.as() / _state->cellPixelSize.height.as()));
auto const extent = GridSize { lineCount, columnCount };
auto const autoScrollAtBottomMargin = !_terminal->isModeEnabled(DECMode::NoSixelScrolling);
auto const topLeft = autoScrollAtBottomMargin ? logicalCursorPosition() : CellLocation {};
@@ -1939,29 +1939,30 @@ void Screen::renderImage(shared_ptr image,
auto const linesAvailable = pageSize().lines - topLeft.line.as();
auto const linesToBeRendered = min(gridSize.lines, linesAvailable);
- auto const columnsAvailable = *pageSize().columns - *topLeft.column;
- auto const columnsToBeRendered = ColumnCount(min(columnsAvailable, *gridSize.columns));
+ auto const columnsAvailable = pageSize().columns - topLeft.column;
+ auto const columnsToBeRendered = ColumnCount(min(columnsAvailable, gridSize.columns));
auto const gapColor = RGBAColor {}; // TODO: _cursor.graphicsRendition.backgroundColor;
// TODO: make use of imageOffset and imageSize
auto const rasterizedImage = make_shared(
std::move(image), alignmentPolicy, resizePolicy, gapColor, gridSize, _state->cellPixelSize);
- const auto lastSixelBand = imageSize.height.value % 6;
+ const auto lastSixelBand = unbox(imageSize.height) % 6;
const LineOffset offset = [&]() {
auto offset =
- LineOffset::cast_from(std::ceil(static_cast(imageSize.height.value - lastSixelBand)
- / float(*_state->cellPixelSize.height)))
+ LineOffset::cast_from(std::ceil((imageSize.height - lastSixelBand).as()
+ / _state->cellPixelSize.height.as()))
- 1 * (lastSixelBand == 0);
- auto const h = imageSize.height.value - 1;
+ auto const h = unbox(imageSize.height) - 1;
// VT340 has this behavior where for some heights it text cursor is placed not
// at the final sixel line but a line above it.
// See
// https://github.com/hackerb9/vt340test/blob/main/glitches.md#text-cursor-is-left-one-row-too-high-for-certain-sixel-heights
- if (h % 6 > h % _state->cellPixelSize.height.value)
+ if (h % 6 > h % unbox(_state->cellPixelSize.height))
return offset - 1;
return offset;
}();
- if (*linesToBeRendered)
+
+ if (unbox(linesToBeRendered))
{
for (GridSize::Offset const offset: GridSize { linesToBeRendered, columnsToBeRendered })
{
diff --git a/src/vtbackend/SixelParser.h b/src/vtbackend/SixelParser.h
index fe4952d15d..6693687991 100644
--- a/src/vtbackend/SixelParser.h
+++ b/src/vtbackend/SixelParser.h
@@ -8,7 +8,6 @@
#include
-#include
#include
#include
#include
diff --git a/src/vtbackend/primitives.h b/src/vtbackend/primitives.h
index 75ecdfdfa1..6884d8744b 100644
--- a/src/vtbackend/primitives.h
+++ b/src/vtbackend/primitives.h
@@ -353,12 +353,12 @@ struct GridSize
constexpr Offset makeOffset(int offset) noexcept
{
- return Offset { LineOffset(offset / *_width), ColumnOffset(offset % *_width) };
+ return Offset { LineOffset(offset / unbox(_width)), ColumnOffset(offset % unbox(_width)) };
}
};
[[nodiscard]] constexpr iterator begin() const noexcept { return iterator { columns, 0 }; }
- [[nodiscard]] constexpr iterator end() const noexcept { return iterator { columns, *columns * *lines }; }
+ [[nodiscard]] constexpr iterator end() const noexcept { return iterator { columns, unbox(columns) * unbox(lines) }; }
};
constexpr CellLocation operator+(CellLocation a, GridSize::Offset b) noexcept
diff --git a/src/vtpty/PageSize.h b/src/vtpty/PageSize.h
index 495b95cde9..af90069cf9 100644
--- a/src/vtpty/PageSize.h
+++ b/src/vtpty/PageSize.h
@@ -28,7 +28,7 @@ struct PageSize
LineCount lines;
ColumnCount columns;
- [[nodiscard]] int area() const noexcept { return *lines * *columns; }
+ [[nodiscard]] int area() const noexcept { return unbox(lines) * unbox(columns); }
};
constexpr PageSize operator+(PageSize pageSize, LineCount lines) noexcept
diff --git a/src/vtrasterizer/Renderer.cpp b/src/vtrasterizer/Renderer.cpp
index bb8bf45713..1f96cbb492 100644
--- a/src/vtrasterizer/Renderer.cpp
+++ b/src/vtrasterizer/Renderer.cpp
@@ -116,7 +116,10 @@ Renderer::Renderer(vtbackend::PageSize pageSize,
Decorator hyperlinkNormal,
Decorator hyperlinkHover):
_atlasHashtableSlotCount { crispy::nextPowerOfTwo(atlasHashtableSlotCount.value) },
- _atlasTileCount { std::max(atlasTileCount.value, static_cast(pageSize.area())) },
+ _atlasTileCount {
+ std::max(atlasTileCount.value, static_cast(pageSize.area() * 3))
+ }, // TODO instead of pagesize use size for fullscreen window
+ // 3 required for huge sixel images rendering due to initial page size smaller than
_atlasDirectMapping { atlasDirectMapping },
//.
_fontDescriptions { std::move(fontDescriptions) },
| | |