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 » Developing U++ » U++ Developers corner » Some new functions
Re: Some new functions [message #29831 is a reply to message #29829] Sun, 21 November 2010 00:05 Go to previous messageGo to previous message
koldo is currently offline  koldo
Messages: 3361
Registered: August 2008
Senior Veteran
Just some more Smile...

byte BW(Color color) {
	return byte(0.299*color.GetR() + 0.587*color.GetG() + 0.114*color.GetB());
}

Image Rotate180(const Image& orig) {
	Size sz = orig.GetSize();
	ImageBuffer dest(sz);
	for(int rw = 0; rw < sz.cy; rw++)
		for(int cl = 0; cl < sz.cx; cl++)
			dest[rw][cl] = orig[sz.cy - rw - 1][sz.cx - cl - 1];
	return dest;
}

Image GetRect(const Image& orig, const Rect &r) {
	if(r.IsEmpty())
		return Image();
	ImageBuffer ib(r.GetSize());
	for(int y = r.top; y < r.bottom; y++) {
		const RGBA *s = orig[y] + r.left;
		const RGBA *e = orig[y] + r.right;
		RGBA *t = ib[y - r.top];
		while(s < e) {
			*t = *s;
			t++;
			s++;
		}
	}
	return ib;
}

Color RandomColor() {
	int num = Random();
	return Color(num&0xFF, (num&0xFF00)>>8, (num&0xFF0000)>>16);
}


Best regards
IƱaki
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to commit on svn ?
Next Topic: FileSel change
Goto Forum:
  


Current Time: Thu May 16 18:32:04 CEST 2024

Total time taken to generate the page: 0.03285 seconds