fix resize bug

This commit is contained in:
Geoffray Levasseur committed 2026-11-04 15:06:43 +01:00
1 parent e5f109327c
commit 988acdbab8
2 files changed
+6

No files matched your search

+3
View File
@@ -339,7 +339,10 @@ void glowFrame(Dpi::Bitmap &dst, int x0, int y0, int width, int height, QColor c
void sprite(Dpi::Canvas &canvas, GraphicSet &graphicSet, int xDst, int yDst, void sprite(Dpi::Canvas &canvas, GraphicSet &graphicSet, int xDst, int yDst,
int width, int height, int xGr, int yGr) int width, int height, int xGr, int yGr)
{ {
// dst = (dst AND mask) OR data: start from what is already on the canvas (when it is image backed).
Dpi::Bitmap scratch(width, height); Dpi::Bitmap scratch(width, height);
scratch.canvas().copyRect(QRect(0, 0, width, height), canvas, QRect(xDst, yDst, width, height));
scratch.canvas().end();
bitBltBitmap(scratch, 0, 0, width, height, graphicSet.mask, xGr, yGr, RasterOp::And); bitBltBitmap(scratch, 0, 0, width, height, graphicSet.mask, xGr, yGr, RasterOp::And);
bitBltBitmap(scratch, 0, 0, width, height, graphicSet.data, xGr, yGr, RasterOp::Paint); bitBltBitmap(scratch, 0, 0, width, height, graphicSet.data, xGr, yGr, RasterOp::Paint);
canvas.draw(xDst, yDst, scratch.image()); canvas.draw(xDst, yDst, scratch.image());
+3
View File
@@ -304,6 +304,7 @@ Bitmap::Bitmap(int width, int height)
void Bitmap::setSize(int width, int height) void Bitmap::setSize(int width, int height)
{ {
m_canvas.end(); // the painter must not outlive the image it paints on
QImage resized(width, height, QImage::Format_ARGB32); QImage resized(width, height, QImage::Format_ARGB32);
resized.fill(Qt::transparent); resized.fill(Qt::transparent);
m_image = resized; m_image = resized;
@@ -318,6 +319,7 @@ void Bitmap::setTransparentColor(const QColor &value)
void Bitmap::loadFromFile(const QString &fileName) void Bitmap::loadFromFile(const QString &fileName)
{ {
m_canvas.end();
m_image.load(fileName); m_image.load(fileName);
m_image = m_image.convertToFormat(QImage::Format_ARGB32); m_image = m_image.convertToFormat(QImage::Format_ARGB32);
m_canvas.setDevice(&m_image); m_canvas.setDevice(&m_image);
@@ -330,6 +332,7 @@ void Bitmap::saveToFile(const QString &fileName) const
void Bitmap::assign(const Bitmap &source) void Bitmap::assign(const Bitmap &source)
{ {
m_canvas.end();
m_image = source.m_image; m_image = source.m_image;
m_transparent = source.m_transparent; m_transparent = source.m_transparent;
m_transparentColor = source.m_transparentColor; m_transparentColor = source.m_transparentColor;