Hi everybody, i want to know how can i copy all content of a QPainter object to a QImage?
i dont have orginal widget reference. before programmers only send QPainter object to another functions.
thanks.
 Intermediate user
					
					
						Intermediate user
					
					
                                        
					
						
							
								 
							
						
					
					
						 
    
    
    
       
    
    
    
    
   
    
    
       
    
    
    
    
   copy QPainter content to a QImage
 copy QPainter content to a QImage
		Hi everybody, i want to know how can i copy all content of a QPainter object to a QImage?
i dont have orginal widget reference. before programmers only send QPainter object to another functions.
thanks.
 
    
    
       
    
    
       
    
    
       
    
    
    
    
   
    
    
       
    
    
    
       
    
    
       
    
   Re: copy QPainter content to a QImage
 Re: copy QPainter content to a QImage
		QPainter doesn't have any "content". If you want to copy content of one paint device to another paint device, the source paint device has to allow it by providing a way to render itself using QPainter (e.g. QWidget::render()).
danics (14th January 2013)
 Intermediate user
					
					
						Intermediate user
					
					
                                        
					
						
							
								 
							
						
					
					
						 
    
    
    
       
    
    
    
    
   
    
    
       
    
    
    
    
   Re: copy QPainter content to a QImage
 Re: copy QPainter content to a QImage
		in qt3 we have bilBlt function for copy one PaintDevice to another, so if i dont know main type of paintdevice how can i copy its content in qt4, however, you mean if i know the main type i can cast it like this?
destpainter.drawImage(0,0, (QImage) (*((QImage*)sourcepainter->device()));
and if i havent paint device type i must using qt3support or another option?
Last edited by danics; 14th January 2013 at 11:00.
 
    
    
       
    
    
       
    
    
       
    
    
    
    
   
    
    
       
    
    
    
       
    
    
       
    
   Intermediate user
					
					
						Intermediate user
					
					
                                        
					
						
							
								 
							
						
					
					
						 
    
    
    
       
    
    
    
    
   
    
    
       
    
    
    
    
   Re: copy QPainter content to a QImage
 Re: copy QPainter content to a QImage
		i have a old program with 170000 lines of code, i must change something in that and port it to qt 4.8, so they have so many function and only send the qpainter object to these functions , i must get a copy of all content of this painters to some images. i haven't the main widget or image reference, now how can i do this?
 
    
    
       
    
    
       
    
    
       
    
    
    
    
   
    
    
       
    
    
    
       
    
    
       
    
   Re: copy QPainter content to a QImage
 Re: copy QPainter content to a QImage
		It still doesn't explain what you are trying to do. Architecture of Qt3 and Qt4 drawing differs greatly, there is no single magic call you can use.
 Intermediate user
					
					
						Intermediate user
					
					
                                        
					
						
							
								 
							
						
					
					
						 
    
    
    
       
    
    
    
    
   
    
    
       
    
    
    
    
   Re: copy QPainter content to a QImage
 Re: copy QPainter content to a QImage
		Ok, I know content of painter's, they have some symbols and i need to extract them, i know the coordinates of symbols and i know the background color too i must extract this symbol without background and load them in another widgets,
it seems i must use bitBlt there is no other choice, am i right?
 
    
    
       
    
    
       
    
    
       
    
    
    
    
   
    
    
       
    
    
    
       
    
    
       
    
   Re: copy QPainter content to a QImage
 Re: copy QPainter content to a QImage
		 Intermediate user
					
					
						Intermediate user
					
					
                                        
					
						
							
								 
							
						
					
					
						 
    
    
    
       
    
    
    
    
   
    
    
       
    
    
    
    
   Re: copy QPainter content to a QImage
 Re: copy QPainter content to a QImage
		you want me to casting paintingdevice?
i m sure its not qwidget its qimage or qpixmap or qbitmap i dont know exactly what is that!
 
    
    
       
    
    
       
    
    
       
    
    
    
    
   
    
    
       
    
    
    
       
    
    
       
    
   Re: copy QPainter content to a QImage
 Re: copy QPainter content to a QImage
		I'm asking you to look into the source code of the application you are maintaining and see what is the source device for the call being made.
So check. If it's QImage or QPixmap (or QBitmap which is its subclass) then you can use QImage::copy() or QPixmap::copy().i m sure its not qwidget its qimage or qpixmap or qbitmap i dont know exactly what is that!
 Intermediate user
					
					
						Intermediate user
					
					
                                        
					
						
							
								 
							
						
					
					
						 
    
    
    
       
    
    
    
    
   
    
    
       
    
    
    
    
   Re: copy QPainter content to a QImage
 Re: copy QPainter content to a QImage
		if i wanna do this i must check so much code, and change so many functions for referencing that object too, if i have only QPainterDevice i cannot do anything?
 
    
    
       
    
    
       
    
    
       
    
    
    
    
   
    
    
       
    
    
    
       
    
    
       
    
   Re: copy QPainter content to a QImage
 Re: copy QPainter content to a QImage
		
Bookmarks