本文介绍了在Unity中将位图转换为Texture2D的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我处于使用Unity中的AForge.net操纵位图的情况.但是,位图无法应用于Unity中的纹理,因此我可以看到我的输出,这是怎么做的?

I'm in a scenario where I'm manipulating bitmaps using AForge.net in Unity. However, a Bitmap can't be applied to a texture in Unity, so I visibly can see my output, so how is this done?

我相信我必须使用MemoryStream,但是我不知道该使用哪种方式.

I believe I have to use the MemoryStream, but in what fashion is unknown to me.

推荐答案

我设法通过使用内存流来实现此目标,即:

I managed to achieve this by using a memorystream, i.e.:

        MemoryStream msFinger = new MemoryStream();
        bitmapCurrentframeRed.Save(msFinger, bitmapCurrentframeRed.RawFormat);
        redCamera.LoadImage(msFinger.ToArray());
        redFilter.GetComponent<Renderer>().material.mainTexture = redCamera;

使用bitmapCurrentframeRed作为位图,redCamera是texture2D,redFilter是GameObject(平面),用于查看我的输出.

With bitmapCurrentframeRed being a Bitmap,redCamera being a texture2D and redFilter being a GameObject(plane) used to view my output.

这篇关于在Unity中将位图转换为Texture2D的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 00:55