BitMiracle.LibTiff.Classic.TiffRgbaImage.putRGBcontig8bitCMYKMaptile C# (CSharp) Method

putRGBcontig8bitCMYKMaptile() private static method

8-bit packed CMYK samples w/Map => RGB NB: The conversion of CMYK->RGB is *very* crude.
private static putRGBcontig8bitCMYKMaptile ( TiffRgbaImage img, int raster, int rasterOffset, int rasterShift, int x, int y, int width, int height, byte buffer, int offset, int bufferShift ) : void
img TiffRgbaImage
raster int
rasterOffset int
rasterShift int
x int
y int
width int
height int
buffer byte
offset int
bufferShift int
return void
        private static void putRGBcontig8bitCMYKMaptile(
            TiffRgbaImage img, int[] raster, int rasterOffset, int rasterShift,
            int x, int y, int width, int height, byte[] buffer, int offset, int bufferShift)
        {
            int samplesperpixel = img.samplesperpixel;
            byte[] Map = img.Map;
            bufferShift *= samplesperpixel;

            while (height-- > 0)
            {
                for (x = width; x-- > 0; )
                {
                    short k = (short)(255 - buffer[offset + 3]);
                    short r = (short)((k * (255 - buffer[offset])) / 255);
                    short g = (short)((k * (255 - buffer[offset + 1])) / 255);
                    short b = (short)((k * (255 - buffer[offset + 2])) / 255);
                    raster[rasterOffset] = PACK(Map[r], Map[g], Map[b]);
                    rasterOffset++;
                    offset += samplesperpixel;
                }

                offset += bufferShift;
                rasterOffset += rasterShift;
            }
        }