public static void CopySubBufferToInt32Array(BitmapBlenderBase buff, int mx, int my, int w, int h, int[] buffer)
        {
            //TODO: review here,
            //check pixel format for an image buffer before use
            //if mBuffer is not 32 bits ARGB => this may not correct

            int i = 0;

            int[] mBuffer = buff.raw_buffer32;
            for (int y = my; y < h; ++y)
            {
                //int xbufferOffset = buff.GetBufferOffsetXY(0, y);
                int xbuffOffset32 = buff.GetBufferOffsetXY32(0, y);

                for (int x = mx; x < w; ++x)
                {
                    //A R G B

                    int val = mBuffer[xbuffOffset32];

                    //TODO: A =?
                    byte r = (byte)((val >> 16) & 0xff); // mBuffer[xbufferOffset + 2];
                    byte g = (byte)((val >> 8) & 0xff);  // mBuffer[xbufferOffset + 1];
                    byte b = (byte)((val >> 0) & 0xff);  // mBuffer[xbufferOffset];


                    //xbufferOffset += 4;
                    xbuffOffset32++;
                    //
                    buffer[i] = b | (g << 8) | (r << 16);
                    i++;
                }
            }
            //int i = 0;
            //byte[] mBuffer = buff.m_ByteBuffer;
            //for (int y = my; y < h; ++y)
            //{
            //    int xbufferOffset = buff.GetBufferOffsetXY(0, y);
            //    for (int x = mx; x < w; ++x)
            //    {
            //        //A R G B
            //        byte r = mBuffer[xbufferOffset + 2];
            //        byte g = mBuffer[xbufferOffset + 1];
            //        byte b = mBuffer[xbufferOffset];
            //        xbufferOffset += 4;
            //        //
            //        buffer[i] = b | (g << 8) | (r << 16);
            //        i++;
            //    }
            //}
        }
Exemplo n.º 2
0
 public void SetTarget(PixelFarm.CpuBlit.PixelProcessing.BitmapBlenderBase target)
 {
     _target = target;
 }