Two Pilots™    Home  |  Navigation  |  Site Map  |  Products  |  Download  |  Prices  |  For Partners  |  Support


All forums · Statistics · Search ·

Two Pilots forum / For software developers / GDI+ DrawRectangle messes text drawing!
. 1 . 2 . >>
Author Message
Pisoi
# Posted: 29 Mar 2007 12:30


Hello,

We're thinking to use PDF Creator into our product, however I've just found an issue when using GDI+ functions on a Graphics created on the HDC retrieved: when I draw a rectangle first using DrawRectangle the text drawn immediately afterwards using DrawString has almost double height !

Please help!

Thanks

Stanislav
Member
# Posted: 29 Mar 2007 13:07


Dear Pisoi,

Can you send us the code example please ? You can use our support form to send us a zip archive.

Please try to test GDI functions, not GDI+.

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

Pisoi
# Posted: 29 Mar 2007 13:26


Thanks for the answer !

I have to use GDI+ both for rotated text. Here's the code snippet:

{
Graphics graphics( hPrinterDC);
graphics.SetPageUnit( UnitPixel);
Gdiplus::Font font( L"Arial", 15, FontStyleRegular, UnitPixel);
SolidBrush brush( Color::Black);
graphics.DrawString( L"bla", 3, &font, PointF(0,40), &brush);
}

PDF->PDFPAGE_SetActiveFont("Arial", false, false, false, false, 15, charsetANSI_CHARSET);
PDF->PDFPAGE_TextOutBox2(0, 0, 100, 100, hjCenter, vjCenter, "bla");

The text drawn with GDI+ is narrower and looking weird.

Thanks again.

Pisoi
# Posted: 30 Mar 2007 04:19


Hello !

Have you reproduced the issue ?
Please tell me if you need more details.

Thanks

Stanislav
Member
# Posted: 30 Mar 2007 04:28


Dear Pisoi,

Yes, i informed developers. I can recommend you to try to use usual GDI calls, not GDI+. I can't confirm that GDI+ is supported in current version, will get this information from developers when our lead developer will be available. Sorry for any inconvenience.

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

Pisoi
# Posted: 30 Mar 2007 04:56


Hello,

Thanks for answering, I hope you will get info as soon as possible. As said before, I need rotated text thus I need to use GDI+.

Eugene from your team said here (http://www.colorpilot.com/forum/index.php?action= vthread&forum=36&topic=95) :

"you can use Win GDI and GDI+ functions with .HDC property that mimics screen/printer DC."

So I guess it should be supported ...

Thanks.

Stanislav
Member
# Posted: 30 Mar 2007 05:30


Dear Pisoi,

Yes, i think developers will give exact explanation of this.

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

Pisoi
# Posted: 4 Apr 2007 03:20


Hello,

Any news on this issue ?

Thanks

Stanislav
Member
# Posted: 4 Apr 2007 03:52


Dear Pisoi,

Developers are working now to check this. Sorry for any inconvenience.

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

Pisoi
# Posted: 5 Apr 2007 07:45


Thanks very much!

Stanislav
Member
# Posted: 11 Apr 2007 03:22


Dear Pisoi,

The problem found in the library, new version will be released soon.

Please use this code:

Graphics graphics(hDC);
graphics.SetPageUnit(UnitPixel);
Gdiplus::Font font(L"Arial", (Gdiplus::REAL)(fontSize * PDF->Resolution /
72), FontStyleRegular, UnitPixel);
SolidBrush brush((Gdiplus::ARGB)Color::Black);
graphics.DrawString(L"bla", 3, &font, PointF(0,40), &brush);

Please note the fontSize * PDF->Resolution / 72
The font size is measured differently in the DC and in the library. In library it's measured in points, in DC it's measured in logical units (in this case they are equal to pixels).

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

Pisoi
# Posted: 11 Apr 2007 04:32


Thanks a lot! Will try the new code

Pisoi
# Posted: 14 Apr 2007 08:24


Hello,

It still doesn't work :( Here's the code:

{
Graphics graphics( hPrinterDC);
graphics.SetPageUnit(UnitPixel);
Gdiplus::Font font(L"Arial", (Gdiplus::REAL)(15 * PDF->Resolution / 72), FontStyleRegular, UnitPixel);
SolidBrush brush((Gdiplus::ARGB)Color::Black);
graphics.DrawString(L"bla", 3, &font, PointF(100,200), &brush);
}

PDF->PDFPAGE_SetActiveFont("Arial", false, false, false, false, 15, charsetANSI_CHARSET);
PDF->PDFPAGE_TextOutBox2(0, 0, 100, 100, hjCenter, vjCenter, "bla");

The first text is different, font is very narrow.
I also have in the beginning:

PDF->PDFPAGE_Resolution = dpi;
PDF->PDFPAGE_Width = szDoc.cx * dpi / 96;
PDF->PDFPAGE_Height = szDoc.cy * dpi / 96;

with dpi=72

Another point, changing the font size when declaring the Gdiplus::Font font seems to affect character width only (height stays the same!)

If you specify an e-mail I will send you some screenshots.

Please help!
Thanks

Stanislav
Member
# Posted: 16 Apr 2007 03:42


Dear Pisoi,

I'll forward this information to developers.

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

Stanislav
Member
# Posted: 18 Apr 2007 01:13


Dear Pisoi,

I've uploaded test code from developers which shows relation between resolution and font size in PDF. You can download it here:
http://www.colorpilot.com/~spanasik/code/fontsizes .cpp

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

Pisoi
# Posted: 18 Apr 2007 05:09


Hello,

Ok, here's the resulted PDF: http://www.hardcode.ro/Storyboard1.zip

Text is duplicated and the left text is narrower!

Please help!
Thanks

Stanislav
Member
# Posted: 18 Apr 2007 05:35


Dear Pisoi,

Please send us the code used to produce this PDF.

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

Pisoi
# Posted: 18 Apr 2007 09:10


Hello,

The one you've posted above.

Thanks

Pisoi
# Posted: 18 Apr 2007 09:10


Hi

Only the DrawTextData call actually.

Thanks again

Stanislav
Member
# Posted: 18 Apr 2007 09:28


Dear Pisoi,

I'm sorry, i can't find DrawTextData. Can you post here full code, please ?

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

Pisoi
# Posted: 18 Apr 2007 09:31


Hello,

It's here: http://www.colorpilot.com/~spanasik/code/fontsizes .cpp , the second method.

Thanks

Stanislav
Member
# Posted: 18 Apr 2007 10:24


Dear Pisoi,

Please download latest version from our website - i'm using it and get different result.

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

Pisoi
# Posted: 20 Apr 2007 12:29


Hello,

Here's the result: http://www.hardcode.ro/DrawTextData.zip
By the way, here are some PDFs with different font sizes (8,9,10,11) at different DPIs given to PDFPAGE_Resolution: http://www.hardcode.ro/PDFs.zip
Text is drawn using GDI+.

I'm getting these results using both the 3.4.249 evaluation version and the full 3.4 version.

Please help!
Thanks

Stanislav
Member
# Posted: 20 Apr 2007 13:07


Dear Pisoi,

Yes, i have same results. Developers told me that this is expected behaviour under different resolutions.

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

Pisoi
# Posted: 21 Apr 2007 06:40


Hello,

And what resolution should I use for correct drawing ?
With 72 that seems the best there are still some obvious problems - the text drawn with font sizes 9 and 10 is narrower that it should be.

Please help!

Thanks

Pisoi
# Posted: 21 Apr 2007 11:19


Hi,

By the way drawing with a clipped region does not work :( using SelectClipRgn, the region is not taken into account.

Please help!

Thanks

Stanislav
Member
# Posted: 23 Apr 2007 09:00


Dear Pisoi,

The most correct output should be when used resolution is equal to screen DC resolution (usually 96 dpi)

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

Stanislav
Member
# Posted: 23 Apr 2007 09:04


Dear Pisoi,

SelectClipRgn is supported. Can you send us the code which demonstrates this issue, please ? I'll forward it to developers.

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

Pisoi
# Posted: 23 Apr 2007 11:37


Hello,

Please take a look at http://www.hardcode.ro/PDFs2.zip
I don't understand how I'm supposed to draw text using dpi 96, the text is far from correct (it's definitely narrower) - please help.

As for the clipping, take a look at Clipping.pdf, here's the code:

CSize szViewportExtN, szWindowExtN;
CPoint ptOrgView, ptOrg;
GetViewportExtEx( hPrinterDC, &szViewportExtN);
GetWindowExtEx( hPrinterDC, &szWindowExtN);
GetWindowOrgEx( hPrinterDC, &ptOrg);
GetViewportOrgEx( hPrinterDC, &ptOrgView);

float fx = (float) szViewportExtN.cx / szWindowExtN.cx;
float fy = (float) szViewportExtN.cy / szWindowExtN.cy;

CRgn clipRgn;

clipRgn.CreateRectRgn((0 - ptOrg.x)*fx + ptOrgView.x,
(0 - ptOrg.y)*fy + ptOrgView.y,
(50 - ptOrg.x)*fx + ptOrgView.x,
(50 - ptOrg.y)*fy + ptOrgView.y);

HBRUSH brRed = CreateSolidBrush( RGB( 255, 0, 0));
HBRUSH brBlack = CreateSolidBrush( RGB( 0, 0, 0));
FillRect( hPrinterDC, &CRect( 0, 0, 100, 100), brRed);
SelectClipRgn( hPrinterDC, clipRgn);
FillRect( hPrinterDC, &CRect( 0, 0, 100, 100), brBlack);
SelectClipRgn( hPrinterDC, NULL);
DeleteObject( brRed);
DeleteObject( brBlack);


It's the most simple example of clipping, yet it does not work.

Best wishes and good luck with these issues.

Stanislav
Member
# Posted: 23 Apr 2007 12:04


Dear Pisoi,

Thanks, your information is very valuable for us.

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

. 1 . 2 . >>
 

 

Powered by miniBB 2.0 RC7 © 2001-2004 Page creation time (sec.): 0.016

 

Page top