BitMiracle.LibTiff.Classic.Tiff.printField C# (CSharp) Method

printField() private static method

private static printField ( Stream fd, TiffFieldInfo fip, int value_count, object raw_data ) : void
fd Stream
fip TiffFieldInfo
value_count int
raw_data object
return void
        private static void printField(Stream fd, TiffFieldInfo fip, int value_count, object raw_data)
        {
            fprintf(fd, "  {0}: ", fip.Name);

            byte[] bytes = raw_data as byte[];
            sbyte[] sbytes = raw_data as sbyte[];
            short[] shorts = raw_data as short[];
            ushort[] ushorts = raw_data as ushort[];
            int[] ints = raw_data as int[];
            uint[] uints = raw_data as uint[];
            float[] floats = raw_data as float[];
            double[] doubles = raw_data as double[];
            string s = raw_data as string;

            for (int j = 0; j < value_count; j++)
            {
                if (fip.Type == TiffType.BYTE || fip.Type == TiffType.SBYTE)
                {
                    if (bytes != null)
                        fprintf(fd, "{0}", bytes[j]);
                    else if (sbytes != null)
                        fprintf(fd, "{0}", sbytes[j]);
                }
                else if (fip.Type == TiffType.UNDEFINED)
                {
                    if (bytes != null)
                        fprintf(fd, "0x{0:x}", bytes[j]);
                }
                else if (fip.Type == TiffType.SHORT || fip.Type == TiffType.SSHORT)
                {
                    if (shorts != null)
                        fprintf(fd, "{0}", shorts[j]);
                    else if (ushorts != null)
                        fprintf(fd, "{0}", ushorts[j]);
                }
                else if (fip.Type == TiffType.LONG || fip.Type == TiffType.SLONG)
                {
                    if (ints != null)
                        fprintf(fd, "{0}", ints[j]);
                    else if (uints != null)
                        fprintf(fd, "{0}", uints[j]);
                }
                else if (fip.Type == TiffType.RATIONAL ||
                    fip.Type == TiffType.SRATIONAL ||
                    fip.Type == TiffType.FLOAT)
                {
                    if (floats != null)
                        fprintf(fd, "{0}", floats[j]);
                }
                else if (fip.Type == TiffType.IFD)
                {
                    if (ints != null)
                        fprintf(fd, "0x{0:x}", ints[j]);
                    else if (uints != null)
                        fprintf(fd, "0x{0:x}", uints[j]);
                }
                else if (fip.Type == TiffType.ASCII)
                {
                    if (s != null)
                        fprintf(fd, "{0}", s);

                    break;
                }
                else if (fip.Type == TiffType.DOUBLE || fip.Type == TiffType.FLOAT)
                {
                    if (floats != null)
                        fprintf(fd, "{0}", floats[j]);
                    else if (doubles != null)
                        fprintf(fd, "{0}", doubles[j]);
                }
                else
                {
                    fprintf(fd, "<unsupported data type in printField>");
                    break;
                }

                if (j < value_count - 1)
                    fprintf(fd, ",");
            }

            fprintf(fd, "\r\n");
        }
Tiff