png转xml在线

png转xml在线,第1张

把png图片转换成svg矢量图,然后再生成xml文件

1、打开png图片

使用Inkscape这个软件

File->Open->你的png图片

选择默认配置

2.转换

选中你的图片,path->Trace Bitmap (Ctrl+Shift+B)

Scans要选2,不然会有很多path出来。点击ok。然后保存。

3.使用svg2android-gh-pages转换

下载

这个软件,其实是一个文件夹下载解压出来后。然后打开index.html就可以开始转换了

利用 NET 框架下的FromBase String和ToBase String方法可以很容易地实现图象文件和XML文件的互换 这样可以轻易解决以XML格式保存图片的问题 代码如下 Public Class Form Inherits System Windows Forms Form#Region Windows 窗体设计器生成的代码 Public Sub New()MyBase New()InitializeComponent()在 InitializeComponent() 调用之后添加任何初始化End Sub窗体重写处置以清理组件列表 Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)If disposing ThenIf Not (ponents Is Nothing) Thenponents Dispose()End IfEnd IfMyBase Dispose(disposing)End SubWindows 窗体设计器所必需的Private ponents As System ComponentModel IContainer注意 以下过程是 Windows 窗体设计器所必需的可以使用 Windows 窗体设计器修改此过程 不要使用代码编辑器修改它 Friend WithEvents Button As System Windows Forms ButtonFriend WithEvents Button As System Windows Forms ButtonFriend WithEvents PictureBox As System Windows Forms PictureBoxFriend WithEvents Button As System Windows Forms ButtonFriend WithEvents Label As System Windows Forms LabelFriend WithEvents Label As System Windows Forms Label<System Diagnostics DebuggerStepThrough()>Private Sub InitializeComponent()Me Button = New System Windows Forms Button()Me Button = New System Windows Forms Button()Me PictureBox = New System Windows Forms PictureBox()Me Button = New System Windows Forms Button()Me Label = New System Windows Forms Label()Me Label = New System Windows Forms Label()Me SuspendLayout()Button Me Button Location = New System Drawing Point( )Me Button Name = Button Me Button Size = New System Drawing Size( )Me Button TabIndex = Me Button Text = 将图象保存成XML Button Me Button Location = New System Drawing Point( )Me Button Name = Button Me Button Size = New System Drawing Size( )Me Button TabIndex = Me Button Text = 从XML中得到图象 PictureBox Me PictureBox Location = New System Drawing Point( )Me PictureBox Name = PictureBox Me PictureBox Size = New System Drawing Size( )Me PictureBox TabIndex = Me PictureBox TabStop = FalseButton Me Button Location = New System Drawing Point( )Me Button Name = Button Me Button Size = New System Drawing Size( )Me Button TabIndex = Me Button Text = 浏览图片… Label Me Label Location = New System Drawing Point( )Me Label Name = Label Me Label Size = New System Drawing Size( )Me Label TabIndex = Label Me Label Location = New System Drawing Point( )Me Label Name = Label Me Label Size = New System Drawing Size( )Me Label TabIndex = Me Label Text = 【孟宪会之精彩世界】 Form Me AutoScaleBaseSize = New System Drawing Size( )Me ClientSize = New System Drawing Size( )Me Controls AddRange(New System Windows Forms Control() {Me Label Me Label Me Button Me PictureBox Me Button Me Button })Me Name = Form Me Text = 图象文件和XML格式文件互换例子 Me ResumeLayout(False)End Sub#End RegionPrivate MyFile As String = Private MyFileExt As String = Private Sub Button _Click(ByVal sender As System Object ByVal e As System EventArgs) _Handles Button ClickDim pic As StringDim MyXml As System Xml XmlDocument = New System Xml XmlDocument()MyXml Load( c:\MyPhoto xml )Dim picNode As System Xml XmlNodepicNode = MyXml SelectSingleNode( /pic/photo )pic = picNode InnerTextDim memoryStream As System IO MemoryStreammemoryStream = New System IO MemoryStream(Convert FromBase String(pic))Me PictureBox Image = New System Drawing Bitmap(memoryStream)memoryStream Close()End SubPrivate Sub Button _Click(ByVal sender As System Object ByVal e As System EventArgs) _Handles Button ClickIf MyFile = ThenMessageBox Show( 请选择一个图片! 错误 MessageBoxButtons OK MessageBoxIcon Warning)Exit SubEnd IfDim MyImg As System Drawing Image = MyImg FromFile(MyFile)Dim memoryStream As System IO MemoryStream = New System IO MemoryStream()MyImg Save(memoryStream GetImageType(MyFileExt))Dim b() As Byteb = memoryStream GetBuffer()Dim pic As String = Convert ToBase String(b)memoryStream Close()Dim MyXml As System Xml XmlDocument = New System Xml XmlDocument()MyXml LoadXml( <pic><name>孟宪会</name><photo>+ pic + </photo></pic>)MyXml Save( c:\MyPhoto xml )Label Text = 文件被保存到了 + Microsoft VisualBasic ChrW( ) + c:\MyPhoto xml End SubPrivate Sub Button _Click(ByVal sender As System Object ByVal e As System EventArgs) _Handles Button ClickDim openFileDialog As New OpenFileDialog()openFileDialog InitialDirectory = c:\ openFileDialog Filter = PNG(* png)|* png|Gif(* gif)|* gif|Jpg(* jpg)|* jpg|所有图象文件(* *)|* * openFileDialog FilterIndex = openFileDialog RestoreDirectory = TrueIf openFileDialog ShowDialog() = DialogResult OK ThenMyFile = openFileDialog FileName()MyFileExt = MyFile Substring(MyFile LastIndexOf( ) + )End IfEnd SubPublic Function GetImageType(ByVal str As String) As System Drawing Imaging ImageFormatSelect Case str ToLower()Case jpg Return System Drawing Imaging ImageFormat JpegCase gif Return System Drawing Imaging ImageFormat GifCase tiff Return System Drawing Imaging ImageFormat Tiff()Case icon Return System Drawing Imaging ImageFormat IconCase image/png Return System Drawing Imaging ImageFormat PngCase ElseReturn System Drawing Imaging ImageFormat MemoryBmpEnd SelectEnd FunctionPrivate Sub Form _Closing(ByVal sender As Object ByVal e As System ComponentModel CancelEventArgs) _Handles MyBase ClosingSystem Diagnostics Process Start( IExplore exe )End SubEnd Class lishixinzhi/Article/program/net/201311/11970


欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/bake/11781258.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-18
下一篇2023-05-18

发表评论

登录后才能评论

评论列表(0条)

    保存