Use TexturedBrush to draw string : Text Rendering : Graphics C# Source Code


Custom Search

C# Source Code » Graphics » Text Rendering »

 

Use TexturedBrush to draw string









    
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

public class MainForm : Form {

    private Brush texturedTextBrush;
    private Brush texturedBGroundBrush;

    public MainForm() {
        Image bGroundBrushImage = new Bitmap("Clouds.bmp");
        texturedBGroundBrush = new TextureBrush(bGroundBrushImage);
        Image textBrushImage = new Bitmap("Soap Bubbles.bmp");
        texturedTextBrush = new TextureBrush(textBrushImage);
    }

    protected void OnPaint(PaintEventArgs e) {
        Graphics g = e.Graphics;
        Rectangle r = ClientRectangle;
        g.FillRectangle(texturedBGroundBrush, r);
        g.DrawString("Bitmaps as brushes",
                     new Font("Arial", 30,
                     FontStyle.Bold | FontStyle.Italic),
                     texturedTextBrush,
                     r);

    }
    public static void Main(){
       Application.Run(new MainForm());
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Graphics
» Text Rendering