zoukankan      html  css  js  c++  java
  • 图像传输有用到,图像与数据流相互转换

    原文发布时间为:2009-03-26 —— 来源于本人的百度文章 [由搬家工具导入]

    //一个按钮,两个picturebox,一个picturebox有一张图,一个没有图。。。点击按钮,则出现图

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

    using System.IO;
    namespace imgtobmp
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }

            private void button1_Click(object sender, EventArgs e)
            {
               
                pictureBox2.Image =ByteArrayToImage(ImageToByteArray(pictureBox1.Image));
                  
            }

            public byte[] ImageToByteArray(System.Drawing.Image imageIn)
            {
                MemoryStream ms = new MemoryStream();
                imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                return ms.ToArray();
            }

            public Image ByteArrayToImage(byte[] bytes)
            {
                MemoryStream ms = new MemoryStream(bytes);
                ms.Position = 0;
                Image img = Image.FromStream(ms);
                ms.Close();
                return img;
            }

        }
    }

  • 相关阅读:
    GotoAndPlay 图论
    P1965 转圈游戏  快速幂
    双栈排序 图论
    威尔逊定理 数学
    n!mod p 的求法 数学
    P3195 [HNOI2008]玩具装箱TOY DP+优化
    loj6485. LJJ 学二项式定理
    loj6539. 奇妙数论题
    loj535. 「LibreOJ Round #6」花火
    loj534. 「LibreOJ Round #6」花团
  • 原文地址:https://www.cnblogs.com/handboy/p/7153307.html
Copyright © 2011-2022 走看看