asp.net – 如何使用System.Drawing绘制透明图像?
发布时间:2020-05-24 04:11:28 所属栏目:asp.Net 来源:互联网
导读:我正在尝试从.aspx页面返回透明的GIF,以便在网页中显示.我试图让图像具有透明度,但是我只是不断地将黑色变成透明的图像. 有谁知道我做错了什么? Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles Me.Load Change th
|
我正在尝试从.aspx页面返回透明的GIF,以便在网页中显示.我试图让图像具有透明度,但是我只是不断地将黑色变成透明的图像. 有谁知道我做错了什么? Protected Sub Page_Load(ByVal sender As Object,ByVal e As System.EventArgs) _
Handles Me.Load
'' Change the response headers to output a GIF image.
Response.Clear()
Response.ContentType = "image/gif"
Dim width = 110
Dim height = width
'' Create a new 32-bit bitmap image
Dim b = New Bitmap(width,height)
'' Create Grahpics object for drawing
Dim g = Graphics.FromImage(b)
Dim rect = New Rectangle(0,width - 1,height - 1)
'' Fill in with Transparent
Dim tbrush = New System.Drawing.SolidBrush(Color.Transparent)
g.FillRectangle(tbrush,rect)
'' Draw Circle Border
Dim bPen = Pens.Red
g.DrawPie(bPen,rect,365)
'' Fill in Circle
Dim cbrush = New SolidBrush(Color.LightBlue)
g.FillPie(cbrush,365)
'' Clean up
g.Flush()
g.Dispose()
'' Make Transparent
b.MakeTransparent()
b.Save(Response.OutputStream,Imaging.ImageFormat.Gif)
Response.Flush()
Response.End()
End Sub
解决方法不幸的是,使用Bitmap对象创建透明的Gif并不容易. (见 this KB article)您也可以使用支持透明度的PNG格式与您正在使用的代码. (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 在ASP.NET中,在.aspx中内联代码的不同方法有哪些?
- asp.net-mvc – 自定义授权MVC 3和Ninject IoC
- asp.net:如何在button onclick上使用eventargs进行参数传递
- ASP.Net的最佳免费文件管理器
- asp.net-mvc – 为MVC3 DateTime设置DataFormatString
- asp.net-mvc – ASP.Net MVC如何使用Html.RenderAction将ur
- 在ASP.NET中使用回发的jQuery模态对话框
- 下载ASP.NET MVC C#中字节数组列表中包含的多个文件
- asp.net-mvc-5 – 如何使用asp.net身份更改当前用户的UserN
- asp.net – asp:ContentPlaceHolder和代码块问题
推荐文章
站长推荐
热点阅读
