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 » How to efficiently update a large Image?
Re: How to efficiently update a large Image? [message #22950 is a reply to message #22944] Wed, 02 September 2009 11:37 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14265
Registered: November 2005
Ultimate Member
Tom1 wrote on Tue, 01 September 2009 02:24

Mirek,

Here's the testcase. Only after running your test code I realized the problem was related to having a control inside the main window. So, I guess this has something to do with the control offset within the parent control.

#include <CtrlLib/CtrlLib.h>
#include <Painter/Painter.h>

using namespace Upp;

class PainterCtrl : public Ctrl {
	ImageBuffer ib;

public:
	virtual void Paint(Painter &pntr,Size &sz)=0;

	virtual void Layout(){
		Size sz=GetSize();
		ib.Clear();
		ib.Create(sz);
		BufferPainter pntr(ib);
		Paint(pntr,sz);
	}

	virtual void Paint(Draw &draw) {
		Rect paintrect=draw.GetPaintRect();
		
		Point p = paintrect.TopLeft();
		if(p.x < ib.GetSize().cx && p.y < ib.GetSize().cy) 
			SetSurface(draw, paintrect, ib, ib.GetSize(), p);
	}
	
};

struct ExampleCtrl : PainterCtrl {
	
	virtual void Paint(Painter &pntr,Size &sz){
		pntr.Move(0,0).Line(sz.cx,0).Line(sz.cx,sz.cy).Line(0,sz.cy).Close().Fill(White()).Stroke(5,Black());
		pntr.Move(0,0).Line(sz.cx,sz.cy).Stroke(5,Black());           
	}
};

class ExampleTopWindow: public TopWindow{
public:
	ExampleCtrl ec;
	
	virtual void Layout(){
		ec.SetRect(20,0,GetSize().cx-20,GetSize().cy);
	}

	ExampleTopWindow(){
		Add(ec);
	}
};

GUI_APP_MAIN
{
   ExampleTopWindow win;
   win.Sizeable();
   win.Open();
   win.Run();
}


(This example also sort of demonstrates how to boost application performance when drawing complex items with e.g. Painter and then not having to regenerate them each time the window gets an OS initiated paint request.)

// Tom


Thanks for testcase. You are right, the cause was that offset of child widget was not taken into account.

Hopefully fixed now.

Mirek
 
Read Message
Read Message
Read Message
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: Color menu choice
Next Topic: Support for 2bpp tiff images
Goto Forum:
  


Current Time: Sun Jul 06 06:01:49 CEST 2025

Total time taken to generate the page: 0.03811 seconds