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 » U++ Widgets - General questions or Mixed problems » Qtf and drawing
Qtf and drawing [message #1033] Wed, 15 February 2006 20:55 Go to previous message
pivica is currently offline  pivica
Messages: 57
Registered: November 2005
Location: Belgrade, Serbia
Member
Here is situation. I have some input data and then some calculation and some output data. And on the end I generate some Qtf text and all is very nice and good looking:))
But now I want to generate some images, based on calculated data, and put them in qtf document. After some investigation in uppsrc I figure a way how to generate simple png image in qtf:

String GenerateQtfImage() const
{
	int w = 1;
	int dist = 400;
	const Point p1(0, 0);
	const Point p2(dist, 0);
	const Point p3(dist, dist);
	const Point p4(0, dist);
	
	Size simg(p3);
	DrawingDraw dw(simg);
	
	for(int i = 0; i < 10; i++)
		dw.DrawLine(dist/2, dist/2,
		           int(dist/2 + dist/2 * sin(i * M_PI / 10)),
		           int(dist/2 + dist/2 * cos(i * M_PI / 10)),
		           w, SLtGray);
	
	Size sz = dw.GetTextSize("DRAWING", Courier(dist/5).Italic());
	dw.DrawText((p2.x - sz.cx) / 2, (p3.y - sz.cy) / 2, "DRAWING", Courier(dist/5).Italic());
	
	int scale = 4;
	Image img (dist/scale, dist/scale, dw.GetResult(), SWhite());
	
	String qtfimg;
	{	
		RichPara::CharFormat cformat;
		cformat. Face(Font::COURIER).Height(dist/20);
		
		// What's this for??
		/*Size size = dw.Dots() ? img.GetSize()
		: iscale(size, Size(DOTS_PER_METER_INT, DOTS_PER_METER_INT), GetPixelsPerMeter(draw));*/
		
		RichPara para;// rich paragraf
		
		para.Cat(RichObject("PNG",
				            PngEncoder().SaveImage(img), 
				            img.GetSize()
				            )
				 , cformat);
		
		RichText rtext;
		rtext.Cat(para);
		qtfimg = BodyAsQTF(rtext);
	}
	return qtfimg;
}


Now this stuff is working, but is this a good way?
Also I have some problem with resolution when changing scale parameter. With 1 image is looking good, but when I raise scale (2,4,..) image is losing resolution.

What I need is to generate images for pie diagram and gauss distribution diagram. Maybe it's better to use Geom package for this?

One more question. There is DrawArc method for drawing arc, but how to fill arc with some color?
 
Read Message
Read Message
Read Message
Previous Topic: tray icon & balloon notification
Next Topic: How to set transparency level for static rectangle?
Goto Forum:
  


Current Time: Tue May 14 11:12:16 CEST 2024

Total time taken to generate the page: 0.02668 seconds