Painter improvements: Multithreaded rendering improved, new image filter (like Lanczos 3) option, image mapping is now more precise
This commit is contained in:
mirek-fidler 2023-12-24 15:21:23 +01:00 committed by GitHub
parent eb54503041
commit 2d0f19053a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 10281 additions and 3650 deletions

View file

@ -0,0 +1,33 @@
#include "Examples.h"
void ImageFilters(Painter& sw)
{
int nx = 0;
int ny = 0;
auto Do = [&](const char *name, int filter) {
Size isz = TestImg::test().GetSize();
int x = nx * 3 * isz.cx;
int y = ny * 3 * isz.cy;
sw.DrawText(x + 10, y, name, Arial(28));
sw.Rectangle(x + 10, y + 30, 7 * isz.cx / 3, 7 * isz.cy / 3)
.ImageFilter(filter)
.Fill(TestImg::test(), x + 10, y + 30, x + 10 + 7 * isz.cx / 3, y + 30, FILL_PAD);
nx++;
if(nx > 2) {
nx = 0;
ny++;
}
};
Do("Nearest", FILTER_NEAREST);
Do("Bilinear", FILTER_BILINEAR);
Do("B-spline", FILTER_BSPLINE);
Do("Costella", FILTER_COSTELLA);
Do("Bicubic Mitchell", FILTER_BICUBIC_MITCHELL);
Do("Bicubic Catmull Rom", FILTER_BICUBIC_CATMULLROM);
Do("Lanczos3", FILTER_LANCZOS3);
}
INITBLOCK {
RegisterExample("Image filters", ImageFilters);
}

View file

@ -8,6 +8,7 @@ file
Examples.h,
main.cpp,
Image.cpp,
ImageFilter.cpp,
Lion.cpp,
Pythagoras.cpp,
Spiral.cpp,

View file

@ -13,6 +13,9 @@ void DoRect(Painter &sw, double size, bool image)
sw.Fill(TestImg::test(), 0, 0, size, 0);
else
sw.Fill(Blue());
sw.Begin();
sw.Opacity(0.9);
sw.Begin();
sw.Translate(0, size);
@ -25,6 +28,8 @@ void DoRect(Painter &sw, double size, bool image)
sw.Rotate(-M_PI/4.0);
DoRect(sw, size / M_SQRT2, image);
sw.End();
sw.End();
}
void PythagorasTree(Painter& sw)

View file

@ -100,11 +100,11 @@ void App::Paint(Draw& w)
ImageBuffer ib(sz);
{
BufferPainter sw(ib, ctrl.quality);
sw.Co(ctrl.mt);
if(ctrl.transparent)
sw.Clear(RGBAZero());
else
sw.Clear(White());
sw.Co(ctrl.mt);
sw.PreClip(ctrl.preclip);
DoPaint(sw);
}
@ -207,7 +207,7 @@ App::App() {
ctrl.print <<= THISBACK(Print);
Reset();
LoadFromFile(*this);
Title("Painter");
Title("Painter 2");
}
App::~App()