HighTechTalks DotNet Forums  

Pasted clipboard text looks bad

Dotnet Framework (Drawing) microsoft.public.dotnet.framework.drawing


Discuss Pasted clipboard text looks bad in the Dotnet Framework (Drawing) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Academia
 
Posts: n/a

Default Pasted clipboard text looks bad - 10-01-2007 , 09:05 AM






I copy text to the clipboard using WordPad and then retrieve it and draw it
on a panel.

The edges of the text looks bad.

I suspect that it's the result of antialiasing and the background of the
original and panel are different colors.

Can you confirm that that could cause it?

Can you tell me a way to minimize the effect?



Thanks



Reply With Quote
  #2  
Old   
Bob Powell [MVP]
 
Posts: n/a

Default Re: Pasted clipboard text looks bad - 10-01-2007 , 11:11 AM






What clipboard format are you using? You _should_ be copying text, not a
bitmap.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote

Quote:
I copy text to the clipboard using WordPad and then retrieve it and draw it
on a panel.

The edges of the text looks bad.

I suspect that it's the result of antialiasing and the background of the
original and panel are different colors.

Can you confirm that that could cause it?

Can you tell me a way to minimize the effect?



Thanks



Reply With Quote
  #3  
Old   
Academia
 
Posts: n/a

Default Re: Pasted clipboard text looks bad - 10-01-2007 , 03:52 PM



DataFormats.Text to get Strng and

Dim Gr As Graphics = ...

Gr.DrawString(strng, ...

to draw it





"Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote

Quote:
What clipboard format are you using? You _should_ be copying text, not a
bitmap.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote in message
news:uxi7oQDBIHA.1184 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
I copy text to the clipboard using WordPad and then retrieve it and draw
it on a panel.

The edges of the text looks bad.

I suspect that it's the result of antialiasing and the background of the
original and panel are different colors.

Can you confirm that that could cause it?

Can you tell me a way to minimize the effect?



Thanks





Reply With Quote
  #4  
Old   
Bob Powell [MVP]
 
Posts: n/a

Default Re: Pasted clipboard text looks bad - 10-01-2007 , 04:06 PM



Try setting the Graphics TextRenderingHint

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote

Quote:
DataFormats.Text to get Strng and

Dim Gr As Graphics = ...

Gr.DrawString(strng, ...

to draw it





"Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote in message
news:CBAFE9CE-7892-4F4A-B218-EDB9BF2702BB (AT) microsoft (DOT) com...
What clipboard format are you using? You _should_ be copying text, not a
bitmap.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote in message
news:uxi7oQDBIHA.1184 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
I copy text to the clipboard using WordPad and then retrieve it and draw
it on a panel.

The edges of the text looks bad.

I suspect that it's the result of antialiasing and the background of the
original and panel are different colors.

Can you confirm that that could cause it?

Can you tell me a way to minimize the effect?



Thanks






Reply With Quote
  #5  
Old   
Academia
 
Posts: n/a

Default Re: Pasted clipboard text looks bad - 10-01-2007 , 06:24 PM



I used SingleBitPerPixelGridFit and it is better.
I tried ClearTypeGridFit but that didn't help.

Is it your experience that SingleBitPerPixelGridFit gives the best looking
characters in general (big characters, small characters, different fonts,
colors...)?



Thanks for the help


"Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote

Quote:
Try setting the Graphics TextRenderingHint

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote in message
news:OSTI%23zGBIHA.3548 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
DataFormats.Text to get Strng and

Dim Gr As Graphics = ...

Gr.DrawString(strng, ...

to draw it





"Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote in message
news:CBAFE9CE-7892-4F4A-B218-EDB9BF2702BB (AT) microsoft (DOT) com...
What clipboard format are you using? You _should_ be copying text, not a
bitmap.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote in message
news:uxi7oQDBIHA.1184 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
I copy text to the clipboard using WordPad and then retrieve it and draw
it on a panel.

The edges of the text looks bad.

I suspect that it's the result of antialiasing and the background of
the original and panel are different colors.

Can you confirm that that could cause it?

Can you tell me a way to minimize the effect?



Thanks








Reply With Quote
  #6  
Old   
Bob Powell [MVP]
 
Posts: n/a

Default Re: Pasted clipboard text looks bad - 10-02-2007 , 03:02 AM



SingleBitPerPixelGidFit doesn't use any antialiasing at-all. This leads me
to the question-What are you drawing on exactly?

I suspect a black-transparent bitmap?

Post some real code because your example of dim gr as Graphics=... isn't
really telling me what's going on.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote

Quote:
I used SingleBitPerPixelGridFit and it is better.
I tried ClearTypeGridFit but that didn't help.

Is it your experience that SingleBitPerPixelGridFit gives the best looking
characters in general (big characters, small characters, different fonts,
colors...)?



Thanks for the help


"Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote in message
news:3FE46BB2-1312-4643-8216-AE8417DED095 (AT) microsoft (DOT) com...
Try setting the Graphics TextRenderingHint

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote in message
news:OSTI%23zGBIHA.3548 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
DataFormats.Text to get Strng and

Dim Gr As Graphics = ...

Gr.DrawString(strng, ...

to draw it





"Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote in message
news:CBAFE9CE-7892-4F4A-B218-EDB9BF2702BB (AT) microsoft (DOT) com...
What clipboard format are you using? You _should_ be copying text, not
a bitmap.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote in message
news:uxi7oQDBIHA.1184 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
I copy text to the clipboard using WordPad and then retrieve it and
draw it on a panel.

The edges of the text looks bad.

I suspect that it's the result of antialiasing and the background of
the original and panel are different colors.

Can you confirm that that could cause it?

Can you tell me a way to minimize the effect?



Thanks









Reply With Quote
  #7  
Old   
Academia
 
Posts: n/a

Default Re: Pasted clipboard text looks bad - 10-02-2007 , 07:46 AM



I posted more code below. I tried to show only the important code to keep it
short, hope I got enough and didn't add bugs.

ModGraphics(e.Graphics) is where SingleBitPerPixelGridFit was getting set.
I've recently tried AntiAliasGridFit and that seems to work good. I want the
best rendering of all size fonts in all colors on all backgraounds. Speed is
not important.
The background color, text color and font is set by the user so I need to
optimize over all of them somehow.



Thanks for your interest


Dim Addition As Size = mGraphicsBmp.MeasureString(strng, Panel1.Font, 0,
StrngFormat).ToSize

Dim Bm As Bitmap = New Bitmap(newWidth, newHeight,
PixelFormat.Format32bppPArgb)

Dim Gr As Graphics = Graphics.FromImage(Bm)

Picture.ModifyGraphics(Gr)

Gr.DrawString(strng, Panel1.Font, Brush1, 0, 0)

Gr.Dispose()

..............

Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint

Try

ModGraphics(e.Graphics)

Dim Mx As New Matrix(ScaleDisplay, 0, 0, ScaleDisplay, 0, 0)

e.Graphics.Transform = Mx

e.Graphics.DrawImage(Bm , 0, 0) )

Catch

End Try

End Sub







"Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote

Quote:
SingleBitPerPixelGidFit doesn't use any antialiasing at-all. This leads me
to the question-What are you drawing on exactly?

I suspect a black-transparent bitmap?

Post some real code because your example of dim gr as Graphics=... isn't
really telling me what's going on.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote in message
news:eFgGmIIBIHA.3400 (AT) TK2MSFTNGP03 (DOT) phx.gbl...
I used SingleBitPerPixelGridFit and it is better.
I tried ClearTypeGridFit but that didn't help.

Is it your experience that SingleBitPerPixelGridFit gives the best
looking characters in general (big characters, small characters,
different fonts, colors...)?



Thanks for the help


"Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote in message
news:3FE46BB2-1312-4643-8216-AE8417DED095 (AT) microsoft (DOT) com...
Try setting the Graphics TextRenderingHint

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote in message
news:OSTI%23zGBIHA.3548 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
DataFormats.Text to get Strng and

Dim Gr As Graphics = ...

Gr.DrawString(strng, ...

to draw it





"Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote in message
news:CBAFE9CE-7892-4F4A-B218-EDB9BF2702BB (AT) microsoft (DOT) com...
What clipboard format are you using? You _should_ be copying text, not
a bitmap.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote in message
news:uxi7oQDBIHA.1184 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
I copy text to the clipboard using WordPad and then retrieve it and
draw it on a panel.

The edges of the text looks bad.

I suspect that it's the result of antialiasing and the background of
the original and panel are different colors.

Can you confirm that that could cause it?

Can you tell me a way to minimize the effect?



Thanks











Reply With Quote
  #8  
Old   
Bob Powell [MVP]
 
Posts: n/a

Default Re: Pasted clipboard text looks bad - 10-04-2007 , 02:56 PM



Yeah, exactly, black transparent bitmap. Try either clearing the bitmap
to some other colour such as white (Gr.Clear(Color.White)) or drawing
the text directly to the image without passing by the intermediate
image- (my preferred solution) -

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





Academia wrote:
Quote:
I posted more code below. I tried to show only the important code to keep it
short, hope I got enough and didn't add bugs.

ModGraphics(e.Graphics) is where SingleBitPerPixelGridFit was getting set.
I've recently tried AntiAliasGridFit and that seems to work good. I want the
best rendering of all size fonts in all colors on all backgraounds. Speed is
not important.
The background color, text color and font is set by the user so I need to
optimize over all of them somehow.



Thanks for your interest


Dim Addition As Size = mGraphicsBmp.MeasureString(strng, Panel1.Font, 0,
StrngFormat).ToSize

Dim Bm As Bitmap = New Bitmap(newWidth, newHeight,
PixelFormat.Format32bppPArgb)

Dim Gr As Graphics = Graphics.FromImage(Bm)

Picture.ModifyGraphics(Gr)

Gr.DrawString(strng, Panel1.Font, Brush1, 0, 0)

Gr.Dispose()

.............

Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint

Try

ModGraphics(e.Graphics)

Dim Mx As New Matrix(ScaleDisplay, 0, 0, ScaleDisplay, 0, 0)

e.Graphics.Transform = Mx

e.Graphics.DrawImage(Bm , 0, 0) )

Catch

End Try

End Sub







"Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote in message
news:BD438369-453E-480A-81E3-46814178F351 (AT) microsoft (DOT) com...
SingleBitPerPixelGidFit doesn't use any antialiasing at-all. This leads me
to the question-What are you drawing on exactly?

I suspect a black-transparent bitmap?

Post some real code because your example of dim gr as Graphics=... isn't
really telling me what's going on.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote in message
news:eFgGmIIBIHA.3400 (AT) TK2MSFTNGP03 (DOT) phx.gbl...
I used SingleBitPerPixelGridFit and it is better.
I tried ClearTypeGridFit but that didn't help.

Is it your experience that SingleBitPerPixelGridFit gives the best
looking characters in general (big characters, small characters,
different fonts, colors...)?



Thanks for the help


"Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote in message
news:3FE46BB2-1312-4643-8216-AE8417DED095 (AT) microsoft (DOT) com...
Try setting the Graphics TextRenderingHint

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote in message
news:OSTI%23zGBIHA.3548 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
DataFormats.Text to get Strng and

Dim Gr As Graphics = ...

Gr.DrawString(strng, ...

to draw it





"Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote in message
news:CBAFE9CE-7892-4F4A-B218-EDB9BF2702BB (AT) microsoft (DOT) com...
What clipboard format are you using? You _should_ be copying text, not
a bitmap.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote in message
news:uxi7oQDBIHA.1184 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
I copy text to the clipboard using WordPad and then retrieve it and
draw it on a panel.

The edges of the text looks bad.

I suspect that it's the result of antialiasing and the background of
the original and panel are different colors.

Can you confirm that that could cause it?

Can you tell me a way to minimize the effect?



Thanks






Reply With Quote
  #9  
Old   
Academia
 
Posts: n/a

Default Re: Pasted clipboard text looks bad - 10-05-2007 , 08:19 AM




"Bob Powell [MVP]" <bob (AT) _spamkiller_bobpowell (DOT) net> wrote

Quote:
Yeah, exactly, black transparent bitmap.
That resulted from the "New" ?

Thanks



Quote:
Try either clearing the bitmap to some other colour such as white
(Gr.Clear(Color.White)) or drawing the text directly to the image without
passing by the intermediate image- (my preferred solution) -

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





Academia wrote:
I posted more code below. I tried to show only the important code to keep
it short, hope I got enough and didn't add bugs.

ModGraphics(e.Graphics) is where SingleBitPerPixelGridFit was getting
set. I've recently tried AntiAliasGridFit and that seems to work good. I
want the best rendering of all size fonts in all colors on all
backgraounds. Speed is not important.
The background color, text color and font is set by the user so I need to
optimize over all of them somehow.



Thanks for your interest


Dim Addition As Size = mGraphicsBmp.MeasureString(strng, Panel1.Font, 0,
StrngFormat).ToSize

Dim Bm As Bitmap = New Bitmap(newWidth, newHeight,
PixelFormat.Format32bppPArgb)

Dim Gr As Graphics = Graphics.FromImage(Bm)

Picture.ModifyGraphics(Gr)

Gr.DrawString(strng, Panel1.Font, Brush1, 0, 0)

Gr.Dispose()

.............

Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint

Try

ModGraphics(e.Graphics)

Dim Mx As New Matrix(ScaleDisplay, 0, 0, ScaleDisplay, 0, 0)

e.Graphics.Transform = Mx

e.Graphics.DrawImage(Bm , 0, 0) )

Catch

End Try

End Sub







"Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote in message
news:BD438369-453E-480A-81E3-46814178F351 (AT) microsoft (DOT) com...
SingleBitPerPixelGidFit doesn't use any antialiasing at-all. This leads
me to the question-What are you drawing on exactly?

I suspect a black-transparent bitmap?

Post some real code because your example of dim gr as Graphics=... isn't
really telling me what's going on.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote in message
news:eFgGmIIBIHA.3400 (AT) TK2MSFTNGP03 (DOT) phx.gbl...
I used SingleBitPerPixelGridFit and it is better.
I tried ClearTypeGridFit but that didn't help.

Is it your experience that SingleBitPerPixelGridFit gives the best
looking characters in general (big characters, small characters,
different fonts, colors...)?



Thanks for the help


"Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote in message
news:3FE46BB2-1312-4643-8216-AE8417DED095 (AT) microsoft (DOT) com...
Try setting the Graphics TextRenderingHint

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote in message
news:OSTI%23zGBIHA.3548 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
DataFormats.Text to get Strng and

Dim Gr As Graphics = ...

Gr.DrawString(strng, ...

to draw it





"Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote in message
news:CBAFE9CE-7892-4F4A-B218-EDB9BF2702BB (AT) microsoft (DOT) com...
What clipboard format are you using? You _should_ be copying text,
not a bitmap.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote in message
news:uxi7oQDBIHA.1184 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
I copy text to the clipboard using WordPad and then retrieve it and
draw it on a panel.

The edges of the text looks bad.

I suspect that it's the result of antialiasing and the background
of the original and panel are different colors.

Can you confirm that that could cause it?

Can you tell me a way to minimize the effect?



Thanks






Reply With Quote
  #10  
Old   
Academia
 
Posts: n/a

Default Re: Pasted clipboard text looks bad - 10-05-2007 , 08:27 AM



I know this is a dumb question but I hadn't known about the black
transparent bitmap either so here goes.

The fact that it is black transparent bitmap would not be important if I
drew an image on the bitmap that filled it.

True?


Thanks


"Bob Powell [MVP]" <bob (AT) _spamkiller_bobpowell (DOT) net> wrote

Quote:
Yeah, exactly, black transparent bitmap. Try either clearing the bitmap to
some other colour such as white (Gr.Clear(Color.White)) or drawing the
text directly to the image without passing by the intermediate image- (my
preferred solution) -

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





Academia wrote:
I posted more code below. I tried to show only the important code to keep
it short, hope I got enough and didn't add bugs.

ModGraphics(e.Graphics) is where SingleBitPerPixelGridFit was getting
set. I've recently tried AntiAliasGridFit and that seems to work good. I
want the best rendering of all size fonts in all colors on all
backgraounds. Speed is not important.
The background color, text color and font is set by the user so I need to
optimize over all of them somehow.



Thanks for your interest


Dim Addition As Size = mGraphicsBmp.MeasureString(strng, Panel1.Font, 0,
StrngFormat).ToSize

Dim Bm As Bitmap = New Bitmap(newWidth, newHeight,
PixelFormat.Format32bppPArgb)

Dim Gr As Graphics = Graphics.FromImage(Bm)

Picture.ModifyGraphics(Gr)

Gr.DrawString(strng, Panel1.Font, Brush1, 0, 0)

Gr.Dispose()

.............

Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint

Try

ModGraphics(e.Graphics)

Dim Mx As New Matrix(ScaleDisplay, 0, 0, ScaleDisplay, 0, 0)

e.Graphics.Transform = Mx

e.Graphics.DrawImage(Bm , 0, 0) )

Catch

End Try

End Sub







"Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote in message
news:BD438369-453E-480A-81E3-46814178F351 (AT) microsoft (DOT) com...
SingleBitPerPixelGidFit doesn't use any antialiasing at-all. This leads
me to the question-What are you drawing on exactly?

I suspect a black-transparent bitmap?

Post some real code because your example of dim gr as Graphics=... isn't
really telling me what's going on.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote in message
news:eFgGmIIBIHA.3400 (AT) TK2MSFTNGP03 (DOT) phx.gbl...
I used SingleBitPerPixelGridFit and it is better.
I tried ClearTypeGridFit but that didn't help.

Is it your experience that SingleBitPerPixelGridFit gives the best
looking characters in general (big characters, small characters,
different fonts, colors...)?



Thanks for the help


"Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote in message
news:3FE46BB2-1312-4643-8216-AE8417DED095 (AT) microsoft (DOT) com...
Try setting the Graphics TextRenderingHint

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote in message
news:OSTI%23zGBIHA.3548 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
DataFormats.Text to get Strng and

Dim Gr As Graphics = ...

Gr.DrawString(strng, ...

to draw it





"Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote in message
news:CBAFE9CE-7892-4F4A-B218-EDB9BF2702BB (AT) microsoft (DOT) com...
What clipboard format are you using? You _should_ be copying text,
not a bitmap.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Academia" <academiaNOSPAM (AT) a-znet (DOT) com> wrote in message
news:uxi7oQDBIHA.1184 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
I copy text to the clipboard using WordPad and then retrieve it and
draw it on a panel.

The edges of the text looks bad.

I suspect that it's the result of antialiasing and the background
of the original and panel are different colors.

Can you confirm that that could cause it?

Can you tell me a way to minimize the effect?



Thanks






Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.