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 » U++ Library : Other (not classified elsewhere) » Fastest way to capture control as image
Re: Fastest way to capture control as image [message #60601 is a reply to message #60600] Fri, 31 May 2024 08:21 Go to previous messageGo to previous message
koldo is currently offline  koldo
Messages: 3435
Registered: August 2008
Senior Veteran
Hi Luoganda

There is this in GLCanvas. It works if the control is selected.

Image GLCanvas::GetImage() {
	Size sz = GetSize();
	ImageBuffer ib(sz);

	glGetError();
	glReadPixels(0, 0, sz.cx, sz.cy, GL_BGRA_EXT, GL_UNSIGNED_BYTE, static_cast<GLvoid *>(~ib));
	if (GL_NO_ERROR != glGetError())
		return Null;
	
	Buffer<RGBA> temp(sz.cx);
	for(int i = 0; i < sz.cy/2; i++){
		memcpy(temp,ib[i], sz.cx*sizeof(RGBA));
		memcpy(ib[i], ib[sz.cy-1-i], sz.cx*sizeof(RGBA));
		memcpy(ib[sz.cy-1-i], temp, sz.cx*sizeof(RGBA));
	}
	
	for (int y = 0; y < sz.cy; y++)
		for (int x = 0; x < sz.cx; x++) 
			ib[y][x].a = 255;

	return ib;
}


Best regards
IƱaki
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Horizontal Mouse Wheel support request
Next Topic: selection in ColumnList
Goto Forum:
  


Current Time: Wed May 14 05:13:15 CEST 2025

Total time taken to generate the page: 0.05153 seconds