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    | 
		 
		
			
				
				
				  | 
					
						  
						koldo
						 Messages: 3453 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
		
 |  
	| 
		
	 | 
 
 
 |  
  
 
Goto Forum:
 
 Current Time: Tue Nov 04 08:28:17 CET 2025 
 Total time taken to generate the page: 0.15172 seconds 
 |