1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

Direct2D: Fix seams between tiles for large bitmaps

This commit is contained in:
attila 2025-07-16 19:13:44 +02:00 committed by Attila Szarvas
parent 19906c9d2f
commit f97355b9f6

View file

@ -945,12 +945,19 @@ void Direct2DGraphicsContext::drawImage (const Image& imageIn, const AffineTrans
}
else
{
const auto lastMode = deviceContext->GetAntialiasMode();
if (pagesAndArea.pages.size() > 1)
deviceContext->SetAntialiasMode (D2D1_ANTIALIAS_MODE_ALIASED);
deviceContext->DrawBitmap (page.bitmap,
dstConverted,
currentState->fillType.getOpacity(),
currentState->interpolationMode,
srcConverted,
{});
deviceContext->SetAntialiasMode (lastMode);
}
}
};
@ -1337,6 +1344,42 @@ public:
}
}
}
beginTest ("Check that there is no seam between D2D image tiles");
{
const auto width = 229;
const auto height = 80 * width;
Image filmStripSoftware { Image::RGB, width, height, true, SoftwareImageType{} };
{
Graphics g { filmStripSoftware };
g.setGradientFill ({ Colours::red, 0, 0, Colours::cyan, (float) filmStripSoftware.getWidth(), 0, false });
g.fillAll();
}
const auto filmStrip = NativeImageType{}.convert (filmStripSoftware);
Image targetNative { Image::RGB, targetDim, targetDim, true, NativeImageType{} };
Image targetSoftware { Image::RGB, targetDim, targetDim, true, SoftwareImageType{} };
const auto transform = AffineTransform::scale (1.1f);
for (auto* target : { &targetNative, &targetSoftware })
{
Graphics g { *target };
g.setColour (Colours::orange);
g.fillAll();
g.addTransform (transform);
g.drawImage (filmStrip, 0, 0, width, width, 0, (16384 / width) * width, width, width);
}
auto pixelsToIgnore = createEdgeMask (width,
width,
targetNative.getWidth(),
targetNative.getHeight(),
transform);
compareImages (targetNative, targetSoftware, 1, pixelsToIgnore);
}
}
static Image createEdgeMask (int sourceWidth,