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 #22944 is a reply to message #22911] Tue, 01 September 2009 08:24 Go to previous messageGo to previous message
Tom1
Messages: 1305
Registered: March 2007
Ultimate Contributor
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
 
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: Fri Jul 18 03:15:02 CEST 2025

Total time taken to generate the page: 0.04886 seconds