BitMiracle.Tiff2Pdf.T2P.sample_lab_signed_to_unsigned C# (CSharp) Method

sample_lab_signed_to_unsigned() private static method

private static sample_lab_signed_to_unsigned ( byte buffer, int samplecount ) : int
buffer byte
samplecount int
return int
        private static int sample_lab_signed_to_unsigned(byte[] buffer, int samplecount)
        {
            for (int i = 0; i < samplecount; i++)
            {
                if ((buffer[i * 3 + 1] & 0x80) != 0)
                    buffer[i * 3 + 1] = (byte)(0x80 + (sbyte)buffer[i * 3 + 1]); // cast to signed int is important
                else
                    buffer[i * 3 + 1] |= 0x80;

                if ((buffer[i * 3 + 2] & 0x80) != 0)
                    buffer[i * 3 + 2] = (byte)(0x80 + (sbyte)buffer[i * 3 + 2]);
                else
                    buffer[i * 3 + 2] |= 0x80;
            }

            return (samplecount * 3);
        }