System.Drawing.Bitmap.Convert_BGR_888_To_P_RGBA_8888 C# (CSharp) Method

Convert_BGR_888_To_P_RGBA_8888() private method

private Convert_BGR_888_To_P_RGBA_8888 ( IntPtr source, IntPtr destination, int scanLength ) : void
source IntPtr
destination IntPtr
scanLength int
return void
        void Convert_BGR_888_To_P_RGBA_8888(IntPtr source, IntPtr destination, int scanLength)
        {
            unsafe
            {
                byte* src = (byte*)source;
                byte* dest = (byte*)destination;

                byte temp = 0;
                byte alpha = 0;

                for (int sourceOffset = 0, destinationOffset = 0; sourceOffset < scanLength; sourceOffset+=3, destinationOffset+=4)
                {
                    alpha = 255;
                    temp = src [sourceOffset];  // save off blue
                    dest [destinationOffset] = (byte)(src [sourceOffset + 2]);  // move red back
                    dest [destinationOffset + 1] = (byte)(src [sourceOffset + 1]);
                    dest [destinationOffset + 2] = (byte)(temp);
                    dest [destinationOffset + 3] = alpha;
                }
            }
        }