找回密码
 注册
搜索
热搜: 回贴

ASP.net:如何使用标签显示完整的svg图像?

2009-12-13 13:29| 发布者: admin| 查看: 51| 评论: 0|原作者: 江月

◆在html中,显示svg,

在html中,显示svg,看起来要比更加合适,因为当svg尺寸过大时,只会对其缩放,而会将图像裁剪掉
正所谓:既生瑜,何生亮。但是是一个比更不正式的标签!
如果你的svg需要给更多的人看,那么使用是一个不错的选择!
很简单,我们可以从svg读出其width,height!
由于svg也是XML格式的,那么就容易多了!
<%@ Import NameSpace="System.XML" %> 别忘了导入相应的名称空间

方法如下:相应的函数的作用我就不详细说明了,.NET Framework中都有详细的说明
sub showSvgWindow(theSvgPath as string)
dim reader as xmlTextReader = Nothing
dim nodeAttribtion as new arrayList()
dim i,width,height as integer

reader = new xmlTextReader(server.MapPath(theSvgPath))
dim exp as exception

Try
While reader.Read()
If reader.NodeType = XmlNodeType.Element And reader.Name = "svg" Then
If reader.HasAttributes Then
For i = 0 to (reader.attributeCount-1)
reader.moveToAttribute(i)
If reader.Name = "width" Then
width = reader.Value
End If
If reader.Name = "height" Then
height = reader.Value
End If
Next
End If
Exit While
End If
End While
Catch exp

End Try

If CInt(width) < 50 Then
width = "50"
Else If CInt(height) < 50 Then
height = "50"
End If
svgWindow.Text = ""
svgTitle.Text = request.QueryString("title")
end sub

最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-29 23:22 , Processed in 0.223281 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部