Converting an array of Pixels to an image in C#

前端 未结 6 1550
孤城傲影
孤城傲影 2020-12-28 11:20

I have an array of int pixels in my C# program and I want to convert it into an image. The problem is I am converting Java source code for a program into equiva

6条回答
  •  囚心锁ツ
    2020-12-28 11:53

    MemoryImageSource's constructor's 3rd argument is an array of ints composed of argb values in that order

    The example in that page creates such an array by;

    pix[index++] = (255 << 24) | (red << 16) | blue;
    

    You need to decompose that integer array to a byte array (shift operator would be useful), but it should be in bgr order, for LockBits method to work.

提交回复
热议问题