iTextSharp.text.pdf.codec.BmpImage.Read24Bit C# (CSharp) Метод

Read24Bit() приватный Метод

private Read24Bit ( byte bdata ) : void
bdata byte
Результат void
        private void Read24Bit(byte[] bdata)
        {
            // Padding bytes at the end of each scanline
            int padding = 0;

            // width * bitsPerPixel should be divisible by 32
            int bitsPerScanline = width * 24;
            if ( bitsPerScanline%32 != 0) {
                padding = (bitsPerScanline/32 + 1)*32 - bitsPerScanline;
                padding = (int)Math.Ceiling(padding/8.0);
            }

            int imSize = ((width * 3 + 3) / 4 * 4) * height;
            // Read till we have the whole image
            byte[] values = new byte[imSize];
            int bytesRead = 0;
            while (bytesRead < imSize) {
                int r = inputStream.Read(values, bytesRead,
                imSize - bytesRead);
                if (r < 0)
                    break;
                bytesRead += r;
            }

            int l=0, count;

            if (isBottomUp) {
                int max = width*height*3-1;

                count = -padding;
                for (int i=0; i<height; i++) {
                    l = max - (i+1)*width*3 + 1;
                    count += padding;
                    for (int j=0; j<width; j++) {
                        bdata[l + 2] = values[count++];
                        bdata[l + 1] = values[count++];
                        bdata[l] = values[count++];
                        l += 3;
                    }
                }
            } else {
                count = -padding;
                for (int i=0; i<height; i++) {
                    count += padding;
                    for (int j=0; j<width; j++) {
                        bdata[l + 2] = values[count++];
                        bdata[l + 1] = values[count++];
                        bdata[l] = values[count++];
                        l += 3;
                    }
                }
            }
        }