Hi Chris,

Please run the sample below, and tell me how it goes.
It runs without the GenericTypographic StringFormat.

Instead of that I used CEILING()  to round the measures obtained by Measure 
String. 

In the original case, when the sample obtained 164,15 pixels, it created an 
empty bitmap with the size of 164 pixels wide, instead of 165.

In my tests, using CEILING() the problem was fixed.


What do you think Christof ???

DO LOCFILE("System.prg")
WITH _SCREEN.System.Drawing
LOCAL lcText
lcText = INPUTBOX("Type a string to create Image:")
* Create a Font
LOCAL loFont as xfcFont
loFont = _screen.system.Drawing.Font.New("Verdana", 32, .FontStyle.BoldItalic)
LOCAL loTmpBmp as xfcBitmap
loTmpBmp = .Bitmap.New(1,1)
* Retrieve the graphics object.
LOCAL loTmpGfx AS xfcGraphics
loTmpGfx = .Graphics.FromImage(loTmpBmp)
* Measure the String
* Get the size required for our text
LOCAL loSize as xfcSize
loSize = loTmpGfx.MeasureString(lcText, loFont)
LOCAL loNewBmp as xfcBitmap
loNewBmp = .Bitmap.New(CEILING(loSize.Width), CEILING(loSize.Height))
LOCAL loNewGfx as xfcGraphics
loNewGfx = .Graphics.FromImage(loNewBmp)
* Clear the background to Yellow
loNewGfx.Clear(.Color.Yellow)
* Create a solid brush
LOCAL loBrush as xfcSolidBrush
loBrush = .SolidBrush.New(.Color.FromRGB(255,0,0)) && Red
* Create an StringFormat object in order to draw the sting centered in the image
LOCAL loStringFmt as xfcStringFormat
loStringFmt = .StringFormat.New()
loStringFmt.Alignment = .StringAlignment.Center
* Create a Rectangle with the measures of the Bitmap
LOCAL loRect as xfcRectangleF
loRect = loNewBmp.GetBounds()
* Draw the String
loNewGfx.DrawString(lcText, loFont, loBrush, loRect, loStringFmt)
* Finally save the image
loNewBmp.Save("c:\MyText.Png", .Imaging.ImageFormat.Png)
* Show the image
RUN /N Explorer.exe c:\Mytext.Png
ENDWITH


---------- Início da mensagem original ----------- 
De: [EMAIL PROTECTED] 
Para: [EMAIL PROTECTED] 
Cc: 
Data: Mon, 26 Nov 2007 17:30:02 -0000 
Assunto: RE: GDI+ 
> Cesar, 
> 
> Is this something I can fix my end, or should I be waiting for an update to 
> the GdiPlusX stuff ? 
> 
> Cheers 
> 
> Chris. 
> 
> P.S. Any thoughts about the report side of things. 
> 
> -----Original Message----- 
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf 
> Of Cesar 
> Sent: 26 November 2007 16:40 
> To: profox 
> Subject: RE: GDI+ 
> 
> Hey Christof ! 
> 
> ROUND() did the magic. 
> 
> Thanks a lot ! 
> 
> 
> ---------- Início da mensagem original ----------- 
> De: [EMAIL PROTECTED] 
> Para: [EMAIL PROTECTED] 
> Cc: 
> Data: Mon, 26 Nov 2007 17:37:07 +0100 
> Assunto: RE: GDI+ 
> > Hi Cesar, 
> > 
> > > Even using the cloned Generic Typographic, together with "Measure 
> trailing 
> > spaces" etc, I still get the missing pixel. 
> > 
> > One pixel sounds like PixelOffsetMode is kicking in. Try setting 
> > Graphics.PixelOffsetMode to 4. Also, as GDI+ allows floating point values 
> > instead of integers for position and size, I found it necessary to apply 
> > ROUND(xxx,0) for any position or dimension value. Otherwise I would get 
> > occasionally an off-by-one-pixel error. 
> > 
> > -- 
> > Christof 
> > 
> > 
> > 
> > 
[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to