![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#11
| |||
| |||
|
|
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 in message news:OiriLAsBIHA.748 (AT) TK2MSFTNGP04 (DOT) phx.gbl... 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 |
#12
| |||
| |||
|
|
Correct. The basic new bitmap has all the pixel elements set to 0 (transparent black) if you draw on it with an image or a colour then these overwrite the default settings and whatever you draw onto the bitmap afterward will be affected by those settings. Hence, if you draw antialiased text onto a white bitmap then the "halo" around the text will be white. -- -- 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:uc%238AO1BIHA.5960 (AT) TK2MSFTNGP05 (DOT) phx.gbl... 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 in message news:OiriLAsBIHA.748 (AT) TK2MSFTNGP04 (DOT) phx.gbl... 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 |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |