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 » RichText,QTF,RTF... » Bad text quality problem in Qtf
Bad text quality problem in Qtf [message #24509] Thu, 21 January 2010 17:36 Go to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Hello all

I have found some strange behaviour. This is the code labelled "Case B" in picture. The text "(Hello)" looks well.

index.php?t=getfile&id=2152&private=0

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

void MyFunc() {
	ImageDraw idw(1200, 600);
	idw.DrawRect(0, 0, 1200, 600, White);
	idw.DrawText(0, 0, "(Hello)", Serif(400));
	
	DrawingDraw dw(350, 250);
	dw.DrawImage(0, 0, 350, 250, idw);
	
	QtfRichObject pict(CreateDrawingObject(dw.GetResult(), Size(350, 250), Size(350, 250)));
	String qtf;
	qtf << "[A6 This is some drawing in QTF: " << pict << "&";
	qtf << "[C3*@B And now in the table: {{1:1 " << pict << ":: Another cell " << pict << "}}";
	
	PromptOK(qtf);
}

GUI_APP_MAIN {
	MyFunc();
}


If It is called MyFunc() in a bigger program it is got "Case A", where text is bad rendered Crying or Very Sad

Is there any parameter in RichEdit to do a good os bad quality rendering ?

Best regards
Koldo
  • Attachment: dib.PNG
    (Size: 31.18KB, Downloaded 742 times)


Best regards
Iñaki
Re: Bad text quality problem in Qtf [message #24510 is a reply to message #24509] Thu, 21 January 2010 17:43 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
koldo wrote on Thu, 21 January 2010 17:36

Hello all

I have found some strange behaviour. This is the code labelled "Case B" in picture. The text "(Hello)" looks well.

index.php?t=getfile&id=2152&private=0

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

void MyFunc() {
	ImageDraw idw(1200, 600);
	idw.DrawRect(0, 0, 1200, 600, White);
	idw.DrawText(0, 0, "(Hello)", Serif(400));
	
	DrawingDraw dw(350, 250);
	dw.DrawImage(0, 0, 350, 250, idw);
	
	QtfRichObject pict(CreateDrawingObject(dw.GetResult(), Size(350, 250), Size(350, 250)));
	String qtf;
	qtf << "[A6 This is some drawing in QTF: " << pict << "&";
	qtf << "[C3*@B And now in the table: {{1:1 " << pict << ":: Another cell " << pict << "}}";
	
	PromptOK(qtf);
}

GUI_APP_MAIN {
	MyFunc();
}


If It is called MyFunc() in a bigger program it is got "Case A", where text is bad rendered Crying or Very Sad

Is there any parameter in RichEdit to do a good os bad quality rendering ?

Best regards
Koldo


Oh !

If MyFunc() is called in a package without Painter, it works well.

If we add Painter to the package (and we do not call any Painter function), the bad render is got Shocked

Best regards
Koldo


Best regards
Iñaki
Re: Bad text quality problem in Qtf [message #24522 is a reply to message #24509] Fri, 22 January 2010 09:32 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Hello all

I have included the simplest sample of the problem.

If you run it it gets the text bad rendered.

If you just remove Painter package, it renders the text right.

Best regards
Koldo
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

GUI_APP_MAIN
{
	ImageDraw idw(1200, 600);
	idw.DrawRect(0, 0, 1200, 600, White);
	idw.DrawText(0, 0, "(Hello)", Serif(400));
	
	DrawingDraw dw(350, 250);
	dw.DrawImage(0, 0, 350, 250, idw);
	QtfRichObject pict(CreateDrawingObject(dw.GetResult(), Size(350, 250), Size(350, 250)));

	PromptOK(String("[A5 Rendering problem: ") + pict.ToString());
}


Best regards
Iñaki
Re: Bad text quality problem in Qtf [message #24532 is a reply to message #24522] Sat, 23 January 2010 09:27 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

May be, you added Painter, and QTF drawing is inernally and impicitly switchied to Painter (not GDI). But you didn't set up appropriate rendering method for Painter. It looks like antialiasing is off now. Try to switch Painter' antialiasing on and watch the results.
Re: Bad text quality problem in Qtf [message #24536 is a reply to message #24532] Sat, 23 January 2010 16:15 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Mindtraveller wrote on Sat, 23 January 2010 09:27

May be, you added Painter, and QTF drawing is inernally and impicitly switchied to Painter (not GDI). But you didn't set up appropriate rendering method for Painter. It looks like antialiasing is off now. Try to switch Painter' antialiasing on and watch the results.

Hello Mindtraveller

The sample does not use Painter classes. The problem comes just only when including Painter package.

It is clear that in any way Qtf functions call Painter if it is available. But I did not know how to "generically" set anti-aliasing on in Painter, not just in BufferPainter objects as usual.

Best regards
Koldo


Best regards
Iñaki
Re: Bad text quality problem in Qtf [message #24541 is a reply to message #24509] Sat, 23 January 2010 19:45 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Hello all

It happens the same in Linux and Windows.

I have tried to find the source of the problem but I cannot find how Painter affects Qtf painting if Painter is not used explicitly.

Best regards
Koldo


Best regards
Iñaki
Re: Bad text quality problem in Qtf [message #24545 is a reply to message #24541] Sat, 23 January 2010 20:25 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

koldo wrote on Sat, 23 January 2010 19:45

I have tried to find the source of the problem but I cannot find how Painter affects Qtf painting if Painter is not used explicitly.

Hi Koldo!
If I remember correctly, the trick is that both Draw and Painter define their DrawTextOp, DrawRectOp etc... Look for that if you want to see the connection to Painter.

But I don't now how to set the quality without BufferPainter, so I'm not really helping... sorry.

Best regards,
Honza
Re: Bad text quality problem in Qtf [message #24548 is a reply to message #24545] Sat, 23 January 2010 20:45 Go to previous messageGo to next message
andrei_natanael is currently offline  andrei_natanael
Messages: 262
Registered: January 2009
Experienced Member
Hi Koldo,
I know what your problem is related to. When you add Painter package and compile with it, it put at program initialization two pointers in Draw package for it to use Painter initialization functions for ImageAnyDraw. Your problem is related to line 233 in Painter/DrawOp.cpp
INITBLOCK {
	ImageAnyDrawPainter(sCP, sEP);
}

Sorry for delayed response. Sad

Andrei
Re: Bad text quality problem in Qtf [message #24549 is a reply to message #24548] Sat, 23 January 2010 21:45 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
andrei_natanael wrote on Sat, 23 January 2010 20:45

Hi Koldo,
I know what your problem is related to. When you add Painter package and compile with it, it put at program initialization two pointers in Draw package for it to use Painter initialization functions for ImageAnyDraw. Your problem is related to line 233 in Painter/DrawOp.cpp
INITBLOCK {
	ImageAnyDrawPainter(sCP, sEP);
}

Sorry for delayed response. Sad

Andrei


Yes, it is there (thank you Honza too Smile)

The problem is in sCP:

void ImageAnyDrawPainter(Draw *(*f)(Size sz), Image (*e)(Draw *w))
{
	//sCreateImageDraw = f;
	sExtractImageDraw = e;
}


With this comment, there is no problem.

sCP is:

static Draw *sCP(Size sz)
{
	return new ImagePainter(sz);
}


and ImagePainter is:

class ImagePainter : private ImageBuffer__, public BufferPainter {
public:
	ImagePainter(Size sz, int mode = MODE_ANTIALIASED);
...

ImagePainter::ImagePainter(Size sz, int mode)
:	ImageBuffer__(sz), BufferPainter(ImageBuffer__::ib, mode)
{}


So ImagePainter is MODE_ANTIALIASED...

but it does not work like this.

Best regards
Koldo


Best regards
Iñaki
Re: Bad text quality problem in Qtf [message #24569 is a reply to message #24549] Sun, 24 January 2010 19:24 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, this is very interesting issue. It is caused by the fact that the image filtering algorithm of Painter is different. This especially affects rescaling down more than 2 times.
Re: Bad text quality problem in Qtf [message #24584 is a reply to message #24569] Mon, 25 January 2010 09:59 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Hello Mirek

It seems not a problem of RichEdit itself.

Just before PromptOK there are now two lines to save the image and it looks perfect.

GUI_APP_MAIN
{
	ImageDraw idw(1200, 600);
	idw.DrawRect(0, 0, 1200, 600, White);
	idw.DrawText(0, 0, "(Hello)", Serif(400));
	
	DrawingDraw dw(350, 250);
	dw.DrawImage(0, 0, 350, 250, idw); 
	
	QtfRichObject pict(CreateDrawingObject(dw.GetResult(), Size(350, 250), Size(350, 250)));
	
	/**/	PNGEncoder png;	
	/**/	png.SaveFile("c:\\kk.png", pict.obj.ToImage(Size(350, 250)));
	
	PromptOK(String("[A5 Rendering problem: ") + pict.ToString());
}


Best regards
Koldo


Best regards
Iñaki
Re: Bad text quality problem in Qtf [message #24585 is a reply to message #24584] Mon, 25 January 2010 10:18 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Mon, 25 January 2010 03:59

Hello Mirek

It seems not a problem of RichEdit itself.



It is not. I know exactly where the problem is.

I will try to improve rescaling algorithm - that should solve the issue...

Re: Bad text quality problem in Qtf [message #24592 is a reply to message #24585] Mon, 25 January 2010 12:08 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Improvement commited. It might be a little bit more optimized, but seems to work quite well.

[Updated on: Mon, 25 January 2010 12:24]

Report message to a moderator

Re: Bad text quality problem in Qtf [message #24598 is a reply to message #24592] Mon, 25 January 2010 13:41 Go to previous message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Great !

In a first test they work both testing code and original code.

Best regards
Koldo


Best regards
Iñaki
Previous Topic: UWord and Windows fole association
Next Topic: Default font and fontsize in RichEdit
Goto Forum:
  


Current Time: Thu Mar 28 10:00:37 CET 2024

Total time taken to generate the page: 0.01046 seconds