P. 1
Csharp

Csharp

|Views: 639|Likes:
Published by negin17h

More info:

Published by: negin17h on Mar 07, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

11/17/2011

pdf

text

original

Next we provide a program that displays images using the method DrawImage. The

file formats could be bmp, gif or jpeg.

// mydrawim.cs

using System;

using System.Drawing;

using System.Drawing.Drawing2D;

using System.Windows.Forms;

public class Texturedbru : Form

{

public Texturedbru()

{

this.Text = "Using Texture Brushes";

this.Paint += new PaintEventHandler(Text_bru);

}

public void Text_bru(object sender,PaintEventArgs e)

{

Graphics g = e.Graphics;

Image bgimage = new Bitmap("forest.bmp");

g.DrawImage(bgimage,20,20,1000,600);

}

public static void Main()

{

Application.Run(new Texturedbru());

94

CHAPTER 7. GRAPHICS

}

}

Another option to display the picture is

// textbru.cs

using System;

using System.Drawing;

using System.Drawing.Drawing2D;

using System.Windows.Forms;

public class Texturedbru : Form

{

Brush bgbrush;

public Texturedbru()

{

this.Text = "Using Texture Brushes";

Image bgimage = new Bitmap("forest.bmp");

bgbrush = new TextureBrush(bgimage);

this.Paint += new PaintEventHandler(Text_bru);

}

public void Text_bru(object sender,PaintEventArgs e )

{

Graphics g = e.Graphics;

g.FillEllipse(bgbrush,50,50,500,300);

g.FillEllipse(bgbrush,150,150,450,300);

g.FillRectangle(bgbrush,350,450,100,130);

}

public static void Main()

{

Application.Run(new Texturedbru());

}

}

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->