91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 35.58 KB
    文件類型: .rar
    金幣: 1
    下載: 0 次
    發布日期: 2024-09-25
  • 語言: 其他
  • 標簽: XML??圖片??

資源簡介

圖片和XML格式互換,非常簡單,一看就明白。

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
using?System.Drawing;
using?System.IO;
namespace?圖片和xml格式互換
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?string?MyFile?=?““;????//文件名
????????private?string?MyFileExt?=?““;//擴展名

????public?System.Drawing.Imaging.ImageFormat?GetImageType(string?str)?//擴展名得到文件類型
????{
????????if?(str.ToLower()?==?“jpg“)
????????{
????????????return?System.Drawing.Imaging.ImageFormat.Jpeg;
????????}
????????else?if?(str.ToLower()?==?“gif“)
????????{
????????????return?System.Drawing.Imaging.ImageFormat.Gif;
????????}
????????else?if?(str.ToLower()?==?“tiff“)
????????{
????????????return?System.Drawing.Imaging.ImageFormat.Tiff;
????????}
????????else?if?(str.ToLower()?==?“icon“)
????????{
????????????return?System.Drawing.Imaging.ImageFormat.Icon;
????????}
????????else?if?(str.ToLower()?==?“image/png“)
????????{
????????????return?System.Drawing.Imaging.ImageFormat.Png;
????????}
????????else
????????{
????????????return?System.Drawing.Imaging.ImageFormat.MemoryBmp;
????????}
????}

????private?void?button1_Click(object?sender?System.EventArgs?e)
????{
????????OpenFileDialog?openFileDialog1?=?new?OpenFileDialog();
????????openFileDialog1.InitialDirectory?=?“c:\\“;
????????openFileDialog1.Filter?=
?????????????“PNG(*.png)|*.png|Gif(*.gif)|*.gif|Jpg(*.jpg)|*.jpg|所有圖象文件(*.*)|*.*“;
????????openFileDialog1.FilterIndex?=?2;
????????openFileDialog1.RestoreDirectory?=?true;
????????if?(openFileDialog1.ShowDialog()?==?DialogResult.OK)
????????{
????????????MyFile?=?openFileDialog1.FileName;
????????????MyFileExt?=?MyFile.Substring(MyFile.LastIndexOf(“.“)?+?1);?//擴展名
????????}
????}

????//把圖像byte讀出,base64編碼寫入xml相應字段就可以了。
????private?void?button2_Click(object?sender?System.EventArgs?e)
????//圖形轉化成二進制存入xml
????{
????????if?(MyFile?==?““)
????????{
????????????MessageBox.Show(“請選擇一個圖片!“?“錯誤“
????????????????MessageBoxButtons.OK?MessageBoxIcon.Warning);
????????????return;
????????}
????????Image?MyImg?=?Image.FromFile(MyFile);
????????MemoryStream?memoryStream?=?new?MemoryStream();
????????MyImg.Save(memoryStream?GetImageType(MyFileExt));?//將圖像以指定格式保存到流中
????????byte[]?b;
????????b?=?memoryStream.GetBuffer();
????????string?pic?=?Convert.Tobase64String(b);
????????memoryStream.Close();
????????System.xml.xmlDocument?Myxml?=?new?System.xml.xmlDocument();
????????//字符串形式加載xml
????????Myxml.Loadxml(““?+?MyFile?+?““?+?pic?+?““);
????????Myxml.Save(“c:\\MyPhoto.xml“);
????????MessageBox.Show(“文件被保存到了:“?+?“c:\\MyPhoto.xml“);
????}

????private?void?button3_Click(object?sender?System.EventArgs?e)
????{
????????string?pic;
????????System.xml.xmlDocument?Myxml?=?new?System.xml.xmlDocument();
????

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????3787??2008-08-01?18:53??26.圖片和xml格式互換\Form1.cs

?????文件???????4056??2008-08-01?18:43??26.圖片和xml格式互換\Form1.Designer.cs

?????文件???????5814??2008-08-01?18:43??26.圖片和xml格式互換\Form1.resx

?????文件????????483??2008-08-01?18:38??26.圖片和xml格式互換\Program.cs

?????文件???????3255??2008-08-01?18:55??26.圖片和xml格式互換\圖片和xml格式互換.csproj

?????文件????????936??2008-08-01?18:55??26.圖片和xml格式互換\圖片和xml格式互換.sln

????..A..H.?????12288??2008-08-01?18:55??26.圖片和xml格式互換\圖片和xml格式互換.suo

?????文件???????5632??2005-11-11?22:25??26.圖片和xml格式互換\bin\Debug\圖片和xml格式互換.vshost.exe

?????文件??????24576??2008-08-01?18:53??26.圖片和xml格式互換\bin\Debug\圖片和xml格式互換.exe

?????文件??????26112??2008-08-01?18:53??26.圖片和xml格式互換\bin\Debug\圖片和xml格式互換.pdb

?????文件?????????80??2008-08-01?18:55??26.圖片和xml格式互換\obj\圖片和xml格式互換.csproj.FileList.txt

?????文件????????180??2008-08-01?18:43??26.圖片和xml格式互換\obj\Debug\圖片和xml格式互換.Form1.resources

?????文件????????180??2008-08-01?18:40??26.圖片和xml格式互換\obj\Debug\圖片和xml格式互換.Properties.Resources.resources

?????文件??????26112??2008-08-01?18:53??26.圖片和xml格式互換\obj\Debug\圖片和xml格式互換.pdb

?????文件??????24576??2008-08-01?18:53??26.圖片和xml格式互換\obj\Debug\圖片和xml格式互換.exe

?????文件????????842??2008-08-01?18:43??26.圖片和xml格式互換\obj\Debug\圖片和xml格式互換.csproj.GenerateResource.Cache

?????文件???????1220??2008-08-01?18:38??26.圖片和xml格式互換\Properties\AssemblyInfo.cs

?????文件???????5612??2008-08-01?18:38??26.圖片和xml格式互換\Properties\Resources.resx

?????文件???????2902??2008-08-01?18:38??26.圖片和xml格式互換\Properties\Resources.Designer.cs

?????文件????????249??2008-08-01?18:38??26.圖片和xml格式互換\Properties\Settings.settings

?????文件???????1107??2008-08-01?18:38??26.圖片和xml格式互換\Properties\Settings.Designer.cs

?????目錄??????????0??2008-08-22?21:53??26.圖片和xml格式互換\obj\Debug\TempPE

?????目錄??????????0??2008-08-22?21:53??26.圖片和xml格式互換\bin\Release

?????目錄??????????0??2008-08-22?21:53??26.圖片和xml格式互換\bin\Debug

?????目錄??????????0??2008-08-22?21:53??26.圖片和xml格式互換\obj\Release

?????目錄??????????0??2008-08-22?21:53??26.圖片和xml格式互換\obj\Debug

?????目錄??????????0??2008-08-22?21:53??26.圖片和xml格式互換\bin

?????目錄??????????0??2008-08-22?21:53??26.圖片和xml格式互換\obj

?????目錄??????????0??2008-08-22?21:53??26.圖片和xml格式互換\Properties

?????目錄??????????0??2008-08-22?21:53??26.圖片和xml格式互換

............此處省略3個文件信息

評論

共有 條評論