30 #ifndef PT_GFX_BLOCKSCALE_H
31 #define PT_GFX_BLOCKSCALE_H
33 #include <Pt/Gfx/Api.h>
34 #include <Pt/Gfx/CopyPixel.h>
35 #include <Pt/Gfx/LineView.h>
44 template <
typename FromView,
typename ToView>
47 const Pt::ssize_t fromWidth = from.width();
48 const Pt::ssize_t fromHeight = from.height();
49 const Pt::ssize_t toWidth = to.width();
50 const Pt::ssize_t toHeight = to.height();
52 auto fromLines = lineView(from);
53 auto toLines = lineView(to);
54 auto fromLine = fromLines.begin();
55 auto toLine = toLines.begin();
56 auto toLineEnd = toLines.end();
60 while(toLine != toLineEnd)
62 Pt::ssize_t rows = (toHeight - dh + fromHeight - 1) / fromHeight;
64 for(Pt::ssize_t i = 0; i < rows; ++i)
66 auto fromIt = fromLine->begin();
69 for(
auto& toPixel : *toLine)
74 fromIt += dw / toWidth;
81 dh += rows * fromHeight;
82 fromLine += dh / toHeight;