private unsafe void TransferDataFormat1bppIndexed(BitmapData imgData, PixData pixData)
        {
            var height = imgData.Height;
            var width  = imgData.Width / 8;

            for (int y = 0; y < height; y++)
            {
                byte *imgLine = (byte *)imgData.Scan0 + (y * imgData.Stride);
                uint *pixLine = (uint *)pixData.Data + (y * pixData.WordsPerLine);

                for (int x = 0; x < width; x++)
                {
                    byte pixelVal = BitmapHelper.GetDataByte(imgLine, x);
                    PixData.SetDataByte(pixLine, x, pixelVal);
                }
            }
        }
Exemplo n.º 2
0
        private unsafe void TransferData16(PixData pixData, BitmapData imgData)
        {
            var imgFormat = imgData.PixelFormat;
            var height    = imgData.Height;
            var width     = imgData.Width;

            for (int y = 0; y < height; y++)
            {
                uint *  pixLine = (uint *)pixData.Data + (y * pixData.WordsPerLine);
                ushort *imgLine = (ushort *)imgData.Scan0 + (y * imgData.Stride);

                for (int x = 0; x < width; x++)
                {
                    ushort pixVal = (ushort)PixData.GetDataTwoByte(pixLine, x);

                    imgLine[x] = pixVal;
                }
            }
        }
        private unsafe void TransferDataFormat24bppRgb(BitmapData imgData, PixData pixData)
        {
            var imgFormat = imgData.PixelFormat;
            var height    = imgData.Height;
            var width     = imgData.Width;

            for (int y = 0; y < height; y++)
            {
                byte *imgLine = (byte *)imgData.Scan0 + (y * imgData.Stride);
                uint *pixLine = (uint *)pixData.Data + (y * pixData.WordsPerLine);

                for (int x = 0; x < width; x++)
                {
                    byte *pixelPtr = imgLine + x * 3;
                    byte  blue     = pixelPtr[0];
                    byte  green    = pixelPtr[1];
                    byte  red      = pixelPtr[2];
                    PixData.SetDataFourByte(pixLine, x, BitmapHelper.EncodeAsRGBA(red, green, blue, 255));
                }
            }
        }
        private unsafe void TransferDataFormat32bppArgb(BitmapData imgData, PixData pixData)
        {
            var imgFormat = imgData.PixelFormat;
            var height    = imgData.Height;
            var width     = imgData.Width;

            for (int y = 0; y < height; y++)
            {
                byte *imgLine = (byte *)imgData.Scan0 + (y * imgData.Stride);
                uint *pixLine = (uint *)pixData.Data + (y * pixData.WordsPerLine);

                for (int x = 0; x < width; x++)
                {
                    byte *pixelPtr = imgLine + (x << 2);
                    byte  blue     = *pixelPtr;
                    byte  green    = *(pixelPtr + 1);
                    byte  red      = *(pixelPtr + 2);
                    byte  alpha    = *(pixelPtr + 3);
                    PixData.SetDataFourByte(pixLine, x, BitmapHelper.EncodeAsRGBA(red, green, blue, alpha));
                }
            }
        }
Exemplo n.º 5
0
        private unsafe void TransferData32(PixData pixData, BitmapData imgData, int alphaMask)
        {
            var imgFormat = imgData.PixelFormat;
            var height    = imgData.Height;
            var width     = imgData.Width;

            for (int y = 0; y < height; y++)
            {
                byte *imgLine = (byte *)imgData.Scan0 + (y * imgData.Stride);
                uint *pixLine = (uint *)pixData.Data + (y * pixData.WordsPerLine);

                for (int x = 0; x < width; x++)
                {
                    var pixVal = PixColor.FromRgba(pixLine[x]);

                    byte *pixelPtr = imgLine + (x << 2);
                    pixelPtr[0] = pixVal.Blue;
                    pixelPtr[1] = pixVal.Green;
                    pixelPtr[2] = pixVal.Red;
                    pixelPtr[3] = (byte)(alphaMask | pixVal.Alpha); // Allow user to include alpha or not
                }
            }
        }