Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » DrawImage scaling
Re: DrawImage scaling [message #9454 is a reply to message #9430] Tue, 08 May 2007 19:21 Go to previous message
mirek is currently offline  mirek
Messages: 13975
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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: PNG to IML?
Next Topic: Delayed Image Loading
Goto Forum:
  


Current Time: Mon May 06 16:51:14 CEST 2024

Total time taken to generate the page: 0.02043 seconds