Fix SubPixmap

This commit is contained in:
Elias Batek 2024-10-06 01:34:51 +02:00
parent a391b8dad9
commit 0bdcc43a57
1 changed files with 9 additions and 7 deletions

View File

@ -348,11 +348,13 @@ struct SubPixmap {
/++ /++
$(I Advanced functionality.) $(I Advanced functionality.)
Offset of the bottom right corner of the subimage Offset of the pixel following the bottom right corner of the subimage.
from the top left corner the source image.
(`Point(O, 0)` is the top left corner of the source image.)
+/ +/
Point sourceOffsetEnd() const { Point sourceOffsetEnd() const {
return (offset + castTo!Point(size)); auto vec = Point(size.x, (size.y - 1));
return (offset + vec);
} }
/++ /++
@ -2016,11 +2018,11 @@ void drawPixmap(Pixmap target, const SubPixmap image, Point pos, Blend blend = b
} }
Point drawingEnd = drawingTarget + drawingSize.castTo!Point(); Point drawingEnd = drawingTarget + drawingSize.castTo!Point();
if (drawingEnd.x >= source.width) { if (drawingEnd.x >= target.width) {
drawingSize.width -= (drawingEnd.x - source.width); drawingSize.width -= (drawingEnd.x - target.width);
} }
if (drawingEnd.y >= source.height) { if (drawingEnd.y >= target.height) {
drawingSize.height -= (drawingEnd.y - source.height); drawingSize.height -= (drawingEnd.y - target.height);
} }
auto dst = SubPixmap(target, drawingTarget, drawingSize); auto dst = SubPixmap(target, drawingTarget, drawingSize);