Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » DrawImage scaling
DrawImage scaling [message #7476] |
Sun, 31 December 2006 03:27 |
Coder
Messages: 3 Registered: December 2006
|
Junior Member |
|
|
Does Draw::DrawImage support point sampled (non-filtered) scaling now or in the future maybe?
|
|
|
|
|
|
Re: DrawImage scaling [message #9454 is a reply to message #9430] |
Tue, 08 May 2007 19:21 |
|
mirek
Messages: 13984 Registered: November 2005
|
Ultimate Member |
|
|
nixnixnix wrote on Mon, 07 May 2007 15:34 | I need this too. Is the only alternative that one needs to draw a rectangle to represent each pixel?
Cheers,
Nick
|
If "zoom" is all you need, it is trivial to implement:
(IconDes/ImageOp.cpp 170):
Image Magnify(const Image& img, int nx, int ny)
{
if(nx == 1 && ny == 1)
return img;
if(nx == 0 || ny == 0)
return Image();
Size sz = img.GetSize();
bool xdown = nx < 0;
nx = abs(nx);
int ncx = xdown ? sz.cx / nx : sz.cx * nx;
ImageBuffer b(ncx, sz.cy * ny);
const RGBA *s = ~img;
const RGBA *e = s + img.GetLength();
RGBA *t = ~b;
while(s < e) {
RGBA *q = t;
const RGBA *le = s + sz.cx;
while(s < le) {
Fill(q, *s, nx);
q += nx;
s++;
}
for(int n = ny - 1; n--;) {
memcpy(q, t, ncx * sizeof(RGBA));
q += ncx;
}
t = q;
}
return b;
}
BTW, if you are about to do any image processing, IconDes is quite good studying material...
Mirek
|
|
|
Goto Forum:
Current Time: Mon Jun 10 12:59:32 CEST 2024
Total time taken to generate the page: 0.02065 seconds
|