lineargradientbrush.aspx

来自「asp.net技术内幕的书配源码」· ASPX 代码 · 共 35 行

ASPX
35
字号
<%@ Page ContentType="image/gif" %>
<%@ Import namespace="System.Drawing" %>
<%@ Import namespace="System.Drawing.Imaging" %>
<%@ Import namespace="System.Drawing.Drawing2D" %>

<Script Runat="Server">

Sub Page_Load
  Dim objBitmap As Bitmap
  Dim objGraphics As Graphics
  Dim objRect As Rectangle
  Dim objBrush As LinearGradientBrush

  ' Create Bitmap
  objBitmap = New Bitmap( 400, 200 )

  ' Create Graphics
  objGraphics = Graphics.FromImage( objBitmap )

  ' Create Rectangle
  objRect = New Rectangle( 10, 10, 300, 100 )

  ' Create LinearGradient Brush
  objBrush = New LinearGradientBrush( objRect, Color.Red, _
    Color.Yellow, LinearGradientMode.ForwardDiagonal )

  ' Draw Rectangle
  objGraphics.FillRectangle( objBrush, objRect )

  ' Display Bitmap
  objBitmap.Save( Response.OutputStream, ImageFormat.Gif )
End Sub

</Script>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?