Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | Videos | Photos | Blogs | Beginners | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
6 Months Free & No Setup Fees ASP.NET Hosting!
Search :       Advanced Search »
Home » GDI+ and Graphics » Setting Digital Substitution in GDI+

Setting Digital Substitution in GDI+

In this article I will explain about Setting Digital Substitution in GDI+.

Author Rank :
Page Views : 1700
Downloads : 17
Rating :
 Rate it
Level : Beginner
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
Download Files:
SettingDigitalSubstitutionGDI+.zip
 
 
Discover the top 5 tips for understanding .NET Interop
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 


The SetDigitSubstitution method can be used to substitute digits in a string on the basis of a user's local area. SetDigitSubstitution takes a parameter of the SetDigitSubstitution enumeration, the members of which are described in Table 5.12.

TABLE 5.12: StringDigitSubstitute members

Members

Description

National

Provides substitutions digits based on the national language of the user's locale.

None

Disables substitutions.

Traditional

Provides substitution digits based on user's native script or language.

User

Provides a user-defined substitution.

Rendering Text with Quality and Performance

Here we will discuss the TextRenderingHint property of the Graphics class.

Note: The TextRenderingHint enumeration is defined in the System.Drawing.Text namespace.

The TextRenderingHint property of the Graphics class defines the quality of text rendered on graphics surfaces. The quality also affects drawing performance. For best performance, select low-quality rendering. Better quality will produce slower rendering. For LCD displays, ClearType text provides the best quality.

The TextRenderingHint property takes a value of type TextRenderingHint enumeration. The members of the TextRenderingHint enumeration are described in Table 5.13.

Listing 5.12 uses the TextRenderingHint property to draw text with different options. The code draws four different text strings using different text rendering hint options.

LISTING 5.12: Using TextRenderingHint to set the quality of text

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Drawing.Text
Imports System.Linq
Imports System.IO
Imports System.Text
Imports System.Windows.Forms
Public Class Form1

    Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
        Dim g As Graphics = Me.CreateGraphics()
        g.Clear(Me.BackColor)
        Dim redBrush As New SolidBrush(Color.Red)
        Dim verdana16 As New Font("Verdana", 16)
        Dim text1 As String = "Text with SingleBitPerPixel"
        Dim text2 As String = "Text with ClearTypeGridFit"
        Dim text3 As String = "Text with AntiAliasing"
        Dim text4 As String = "Text with SystemDefault"

        'Set TextRenderingHint property of surface
        'to single bit per pixel
        g.TextRenderingHint = TextRenderingHint.SingleBitPerPixel

        'Draw string
        g.DrawString(text1, verdana16, redBrush, New PointF(10, 10))

        'Set TextRenderingHint property of surface to ClearType grid fit
        g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit

        'Draw string
        g.DrawString(text2, verdana16, redBrush, New PointF(10, 60))

        'Set TextRenderingHint property to surface to Antialias
        g.TextRenderingHint = TextRenderingHint.AntiAlias

        'Draw string
        g.DrawString(text3, verdana16, redBrush, New PointF(10, 100))

        'Set TextRenderingHint property of surface to SystemDefault
        g.TextRenderingHint = TextRenderingHint.SystemDefault

        'Draw string
        g.DrawString(text4, verdana16, redBrush, New PointF(10, 150))

        'Dispose of objects
        redBrush.Dispose()
        g.Dispose()
    End Sub
End Class

TABLE 5.12: TextRenderingHint members
 

Member

Description

AntiAlias

Characters are rendered by anti-aliasing without hinting. AntiAlias offers good quality, but slow performance.

AntiAliasGridFit

Characters are anti-aliased with hinting. AntiAliasGridFit offers good quality and high performance.

ClearTypeGridFit

Characters are drawn by ClearType bitmap with hinting. This is the highest-quality settings, with slow performance. It takes advantage of ClearType font features, if available.

SingleBitPerPixel

Characters are drawn with each glyph's bitmap. Hinting is not used.

SingleBitPerPixelGridFit

Characters are drawn with each glyph's bitmap. Hinting is used to improve character appearance on stems and curvature.

SystemDefault

Characters are drawn with each glyph's bitmap, with the system's default rendering hint.

Figure 5.17 shows the output from Listing 5.12. Different TextRenderingHint options result with higher or lower quality. (How clearly this shows up will vary on different displays-and it may be hard to see in print.)

fig5.17.gif

FIGURE 5.17: Using different TextRenderingHint setting to draw text

Conclusion

Hope the article would have helped you in understanding Setting Digital Substitution in GDI+. Read other articles on GDI+ on the website.

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Dinesh Beniwal
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Discover the top 5 tips for understanding .NET
Ricky Leeks presents the top 5 tips for understanding .NET Interoperability. Learn more.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
 Comments

 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.