Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Drawing.Drawing2D
Imports System.Drawing.Text
Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class _Default
Inherits System.Web.UI.Page
Private _Width As Integer = 600
Private _Height As Integer = 600
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim BitmapImage As New Bitmap(_Width, _Height, PixelFormat.Format32bppArgb)
Dim Canvas As Graphics = Graphics.FromImage(BitmapImage)
' 好了,現在我們取得 Graphics,在這張畫布畫圖,相當於畫在 Bitmap 上
' 填入漸層藍色當背景
Dim ClientArea As New Rectangle(New Point(0, 0), New Size(_Width, _Height))
Dim BlueGradientBrush As New LinearGradientBrush(New Point(0, 0), _
New Point(0, _Height), Color.White, Color.White)
Canvas.FillRectangle(BlueGradientBrush, ClientArea)
' 畫出邊框
Dim BluePen As New Pen(Color.Black, 2)
Canvas.DrawRectangle(BluePen, ClientArea)
Graphics_Loop(Canvas, "888888888888888", 5, 10, 100, 20)
Graphics_Loop(Canvas, "99999", 5, 35, 100, 20)
' 以標楷體 18 點斜體字樣秀出文字
'Dim SF As New StringFormat(StringFormatFlags.NoWrap Or _
' StringFormatFlags.NoFontFallback)
'SF.LineAlignment = StringAlignment.Near
'SF.Alignment = StringAlignment.Center
'Dim F As Font = New Font("標楷體", 18, FontStyle.Italic)
'ClientArea.Offset(0, 4)
'Canvas.DrawString(ContentString, F, Brushes.Black, _
' CType(ClientArea, RectangleF), SF)
'ClientArea.Offset(0, -4)
' 再裝飾一段底線文字
'Canvas.FillRectangle(Brushes.Black, 0, 30, _Width, 10)
'SF.LineAlignment = StringAlignment.Far
'SF.Alignment = StringAlignment.Center
'F = New Font("Arial", 8, FontStyle.Italic)
'Canvas.DrawString("Anti-phishing with Sign-in Seal", F, _
' Brushes.White, CType(ClientArea, RectangleF), SF)
' 輸出圖片到 Client 端
Response.Clear()
Response.ContentType = "image/jpeg"
BitmapImage.Save(Response.OutputStream, ImageFormat.Jpeg)
Response.End()
End Sub
Function Graphics_Loop(ByVal Canvas As Graphics, ByVal Txt As String, ByVal xv As Integer, ByVal yv As Integer, ByVal wv As Integer, ByVal hv As Integer)
Dim ClientArea As New Rectangle(New Point(xv, yv), New Size(wv, hv))
Dim BluePen As New Pen(Color.Black, 1)
Canvas.DrawRectangle(BluePen, ClientArea)
Dim SF As New StringFormat(StringFormatFlags.NoWrap Or _
StringFormatFlags.NoFontFallback)
SF.LineAlignment = StringAlignment.Near
SF.Alignment = StringAlignment.Center
Dim F As Font = New Font("標楷體", 12, FontStyle.Bold)
ClientArea.Offset(0, 4)
Canvas.DrawString(txt, F, Brushes.Black, _
CType(ClientArea, RectangleF), SF)
ClientArea.Offset(0, -4)
End Function
End Class
沒有留言:
張貼留言