Wednesday, April 6, 2011

Creating a .jpg file using System.Drawing , saving it and then sending it to .apsx page


http://www.aspnettutorials.com/tutorials/graphics/Drawing-Csharp.aspx



Imports System.DrawingImports System.Drawing.ImagingImports System.Drawing.TextPartial




objBitmap =
objGraphics = Graphics.FromImage(objBitmap)
objGraphics.Clear(Color.White)


objGraphics.DrawEllipse(p, rect)



objGraphics.FillPie(b1, rect, 0.0F, 60.0F)
objGraphics.FillPie(b2, rect, 60.0F, 150.0F)
objGraphics.FillPie(b3, rect, 210.0F, 150.0F)



objGraphics.DrawString(
objBitmap.Save(Response.OutputStream, ImageFormat.Gif)
objBitmap.Save(Server.MapPath(
objBitmap.Dispose()
objGraphics.Dispose()


End







Class _DefaultInherits System.Web.UI.PageProtected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadDim objBitmap As BitmapDim objGraphics As GraphicsNew Bitmap(400, 440)Dim p As New Pen(Color.Yellow, 0)Dim rect As New Rectangle(10, 10, 280, 280)Dim b1 As Brush = New SolidBrush(Color.Red)Dim b2 As Brush = New SolidBrush(Color.Green)Dim b3 As Brush = New SolidBrush(Color.Blue)Dim fontfml As FontFamily = New FontFamily(GenericFontFamilies.Serif)Dim font As Font = New Font(fontfml, 16)Dim brush As SolidBrush = New SolidBrush(Color.Blue)"Drawing Graphics", font, brush, 70, 300)"x.jpg"), ImageFormat.Jpeg)End Sub Class

No comments:

Post a Comment