传送图片信息 [英] Transfer Picture Information

查看:46
本文介绍了传送图片信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将图片信息从PictureBox,Image,Bitmap和Graphics类的任何对象传输到同一类或这些类中的另一个对象的不同对象?

How to transfer picture information from any object of the PictureBox, Image, Bitmap and Graphics classes to a different object of the same class or a different one of these classes?

推荐答案

嗨jagbir21,

Hi jagbir21,

谢谢您在这里发布.

对于您的问题,您能否提供更多信息?

For your question, could you provide more information?

您要传输什么图片信息?整个图片?理智类的不同对象或这些类中的不同对象是什么意思?您是否要将图片转换为字节并将字节转换为其他类,然后将 字节到图像?

What picture information you want to transfer? The whole picture? What does the to a different object of the sane class or a different one of these classes mean? Do you want to convert the picture to byte and transfer byte to other class then convert the byte to image?

我以图片为例.

 static void Main(string[] args)
        {
            Image image = Image.FromFile(@"C:\Users\v-wezan\Desktop\1.png");
            byte[] b = imageToByteArray(image);
            byteArrayToImage(b).Save("2.gif");
        }
        public static byte[] imageToByteArray(System.Drawing.Image imageIn)
        {
            MemoryStream ms = new MemoryStream();
            imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
            return ms.ToArray();
        }
        public static Image byteArrayToImage(byte[] byteArrayIn)
        {
            MemoryStream ms = new MemoryStream(byteArrayIn);
            Image returnImage = Image.FromStream(ms);
            return returnImage;
        }

最好的问候,

温迪


这篇关于传送图片信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆