简体   繁体   中英

How to render a pixel matrix directly into a wpf element?

So, I'm developing a small program in C# that involves rendering a structure. I started by using Graphics() but because of certain limitations and for the sake of learning, I created my own 3D engine class (or sort of).

That class stores and manipulates the pixels in a matrix of:

public class pixel {
        public Color cor = new Color();
        public int z = Int32.MinValue;
    }

where z is used for visibility check.

Now that I've checked the results (by creating a bitmap file from the matrix), I want to draw and manipulate that matrix directly into a element in my WPF. So i want to know if there's a simple way to do this.

I'm very fresh on all this, so if there is something that i might be missing please tell me, sometimes i don't know what i should really search for.

After trying some different approaches, i ended up storing the data in the matrix in a different way.

My current solution is to draw directly on a Bitmap (that can be easily passed to a PictureBox control) and at the same time store additional info in a matrix the same size as the Bitmap.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM