Graphics::TextContrast Property
.NET Framework (current version)
Gets or sets the gamma correction value for rendering text.
Assembly: System.Drawing (in System.Drawing.dll)
Property Value
Type: System::Int32The gamma correction value used for rendering antialiased and ClearType text.
The gamma correction value must be between 0 and 12. The default value is 4.
The following code example demonstrates the use of the TextRenderingHint and TextContrast properties.
This example is designed to be used with Windows Forms. Paste the code into a form and call the ChangeTextRenderingHintAndTextContrast method when handling the form's Paint event, passing e as PaintEventArgs.
private: void ChangeTextRenderingHintAndTextContrast( PaintEventArgs^ e ) { // Retrieve the graphics object. Graphics^ formGraphics = e->Graphics; // Declare a new font. System::Drawing::Font^ myFont = gcnew System::Drawing::Font( FontFamily::GenericSansSerif,20,FontStyle::Regular ); // Set the TextRenderingHint property. formGraphics->TextRenderingHint = System::Drawing::Text::TextRenderingHint::SingleBitPerPixel; // Draw the string. formGraphics->DrawString( "Hello World", myFont, Brushes::Firebrick, 20.0F, 20.0F ); // Change the TextRenderingHint property. formGraphics->TextRenderingHint = System::Drawing::Text::TextRenderingHint::AntiAliasGridFit; // Draw the string again. formGraphics->DrawString( "Hello World", myFont, Brushes::Firebrick, 20.0F, 60.0F ); // Set the text contrast to a high-contrast setting. formGraphics->TextContrast = 0; // Draw the string. formGraphics->DrawString( "Hello World", myFont, Brushes::DodgerBlue, 20.0F, 100.0F ); // Set the text contrast to a low-contrast setting. formGraphics->TextContrast = 12; // Draw the string again. formGraphics->DrawString( "Hello World", myFont, Brushes::DodgerBlue, 20.0F, 140.0F ); // Dispose of the font object. delete myFont; }
.NET Framework
Available since 1.1
Available since 1.1
Show: