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 » Painter and viewports
Re: Painter and viewports [message #43964 is a reply to message #43961] Mon, 01 December 2014 20:07 Go to previous messageGo to previous message
Didier is currently offline  Didier
Messages: 726
Registered: November 2008
Location: France
Contributor
Hello Massimo,

I think Painter and Drawing has all you need.
You don't need to create PaintingPainter sw(20000, 20000); with such a big size.
All you need to do is:

PaintingPainter sw(viewPortXsize, viewPortYsize);
sw.Offset(viewportOrigin);
.... paint you're data
sw.end();

Ideally you may not even need to allocate a PaintingPainter ==> if Draw interface is sufficient you can reuse the draw instance of the control passed to ViewportCtrl::Paint()

If you really need to use painter, I use the following code (or something close to it), look at GraphDraw::Paint() method (in svn repo).
ViewportCtrl::Paint(Draw& w) {
	ImageBuffer ib( Size() ); // Ctrl size
	Upp::Fill( ib.Begin(), bckgColor, ib.GetLength() ); // if you use transparent colors, you will need this
	BufferPainter bp(ib, drawMode);
	bp.Offset(viewportOrigin);
	.... paint you're data
	sw.end();
	DrawImage(0, 0, bp);
}


In fact, the data is first drawn to an image (using painter) and then the image is draw to the Ctrl
Not very efficient, but I don't know a better way to achieve this when you use Painter.

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Should RGBA have got 4 arguments constructor?
Next Topic: Simplest way to add jpg or png to a layout, for logos, image visble off/on for status, etc.
Goto Forum:
  


Current Time: Tue May 13 08:42:16 CEST 2025

Total time taken to generate the page: 0.03885 seconds