• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

gisoracle

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

C# 其他图片格式转emf

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;


namespace pngtoemf
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Save()
        {
            string filePath = @"D:\闫磊.emf";

            Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            Graphics gs = Graphics.FromImage(bmp);
            Metafile mf = new Metafile(filePath, gs.GetHdc());

            Graphics g = Graphics.FromImage(mf);

            //g.FillEllipse(Brushes.Gray, 0, 0, 100, 100);
            //g.DrawEllipse(Pens.Black, 0, 0, 100, 100);
            //g.DrawArc(new Pen(Color.Red, 10), 20, 20, 60, 60, 30, 120);
            g.DrawImage(pictureBox1.Image, 0, 0);
            g.Save();
            g.Dispose();
            mf.Dispose();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            pictureBox1.Load(this.textBox1.Text);
            Save();

          
        }
    }
}

 

posted on 2018-04-05 10:45  gisai  阅读(1161)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3