Dim objBitmap As Bitmap Dim objGraphics As Graphics Dim param As DrawParam = ParseParam() ' param = ParseParam() Dim width As Integer = param.Width Dim sweep As Single = 0.0F Dim offSet As Single objBitmap = New Bitmap(width, width) objGraphics = Graphics.FromImage(objBitmap) objGraphics.CompositingQuality = CompositingQuality.HighQuality objGraphics.FillRectangle(New SolidBrush(Color.White), 0, 0, width, width) Dim p As Part For Each p In param.Parts sweep = p.Percent * 360.0 / 100.0 objGraphics.FillPie(New SolidBrush(p.ForeColor), New Rectangle(0, 0, width, width), offSet, sweep) Dim textY As Single = 1 / 2 * width + 1 / 3 * width * (Math.Sin((offSet + sweep / 2) * Math.PI / 180)) Dim textX As Single = 1 / 2 * width + 1 / 3 * width * (Math.Cos((offSet + sweep / 2) * Math.PI / 180)) objGraphics.TranslateTransform(textX, textY) objGraphics.DrawString(p.Text, New Font("宋体", 12), New SolidBrush(Color.Red), 0, 0) objGraphics.Save() objGraphics.ResetTransform() offSet += sweep Next objBitmap.Save(Response.OutputStream, ImageFormat.Gif) objBitmap.Dispose() objGraphics.Dispose() Me.Response.ContentType = "image/gif"
AspNetPager 免费分页控件4.1版发布,欢迎下载使用:http://www.webdiyer.com
Dim objGraphics As Graphics Dim param As DrawParam = ParseParam() ' param = ParseParam()
Dim width As Integer = param.Width
Dim sweep As Single = 0.0F
Dim offSet As Single objBitmap = New Bitmap(width, width)
objGraphics = Graphics.FromImage(objBitmap)
objGraphics.CompositingQuality = CompositingQuality.HighQuality
objGraphics.FillRectangle(New SolidBrush(Color.White), 0, 0, width, width) Dim p As Part
For Each p In param.Parts sweep = p.Percent * 360.0 / 100.0
objGraphics.FillPie(New SolidBrush(p.ForeColor), New Rectangle(0, 0, width, width), offSet, sweep) Dim textY As Single = 1 / 2 * width + 1 / 3 * width * (Math.Sin((offSet + sweep / 2) * Math.PI / 180))
Dim textX As Single = 1 / 2 * width + 1 / 3 * width * (Math.Cos((offSet + sweep / 2) * Math.PI / 180))
objGraphics.TranslateTransform(textX, textY)
objGraphics.DrawString(p.Text, New Font("宋体", 12), New SolidBrush(Color.Red), 0, 0)
objGraphics.Save()
objGraphics.ResetTransform()
offSet += sweep
Next
objBitmap.Save(Response.OutputStream, ImageFormat.Gif) objBitmap.Dispose()
objGraphics.Dispose() Me.Response.ContentType = "image/gif"
objBitmap.Save(Response.OutputStream, ImageFormat.Gif)