Esempio n. 1
0
        public static void Main(string[] args)
        {
            Converter c = new Converter();
            c.m_testFriendly = g_testFriendly;

            int argn = 0;
            for (; argn < args.Length; argn++)
            {
                string arg = args[argn];
                if (arg[0] != '-')
                    break;

                string optarg = null;
                if (argn < (args.Length - 1))
                    optarg = args[argn + 1];

                arg = arg.Substring(1);
                switch (arg[0])
                {
                    case 'b':
                        c.m_processByBlock = true;
                        break;

                    case 'c':
                        if (optarg == "none")
                            c.m_compression = Compression.NONE;
                        else if (optarg == "packbits")
                            c.m_compression = Compression.PACKBITS;
                        else if (optarg == "lzw")
                            c.m_compression = Compression.LZW;
                        else if (optarg == "jpeg")
                            c.m_compression = Compression.JPEG;
                        else if (optarg == "zip")
                            c.m_compression = Compression.DEFLATE;
                        else
                        {
                            usage();
                            return;
                        }

                        argn++;
                        break;

                    case 'r':
                    case 't':
                        c.m_rowsPerStrip = int.Parse(optarg, CultureInfo.InvariantCulture);
                        argn++;
                        break;

                    case 'n':
                        c.m_noAlpha = true;
                        break;

                    case '?':
                        usage();
                        return;
                }
            }

            if (args.Length - argn < 2)
            {
                usage();
                return;
            }

            using (Tiff outImage = Tiff.Open(args[args.Length - 1], "w"))
            {
                if (outImage == null)
                    return;

                for (; argn < args.Length - 1; argn++)
                {
                    using (Tiff inImage = Tiff.Open(args[argn], "r"))
                    {
                        if (inImage == null)
                            return;

                        do
                        {
                            if (!c.tiffcvt(inImage, outImage) || !outImage.WriteDirectory())
                                return;
                        } while (inImage.ReadDirectory());
                    }
                }
            }
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            Converter c = new Converter();
            c.m_testFriendly = g_testFriendly;

            int argn = 0;
            for (; argn < args.Length; argn++)
            {
                string arg = args[argn];
                if (arg[0] != '-')
                    break;

                string optarg = null;
                if (argn < (args.Length - 1))
                    optarg = args[argn + 1];

                arg = arg.Substring(1);
                switch (arg[0])
                {
                    case 'b':
                        c.m_processByBlock = true;
                        break;

                    case 'c':
                        if (optarg == "none")
                            c.m_compression = Compression.NONE;
                        else if (optarg == "packbits")
                            c.m_compression = Compression.PACKBITS;
                        else if (optarg == "lzw")
                            c.m_compression = Compression.LZW;
                        else if (optarg == "jpeg")
                            c.m_compression = Compression.JPEG;
                        else if (optarg == "zip")
                            c.m_compression = Compression.DEFLATE;
                        else
                        {
                            usage();
                            return;
                        }

                        argn++;
                        break;

                    case 'r':
                    case 't':
                        c.m_rowsPerStrip = int.Parse(optarg, CultureInfo.InvariantCulture);
                        argn++;
                        break;

                    case 'n':
                        c.m_noAlpha = true;
                        break;

                    case '?':
                        usage();
                        return;
                }
            }

            if (args.Length - argn < 2)
            {
                usage();
                return;
            }

            using (Tiff outImage = Tiff.Open(args[args.Length - 1], "w"))
            {
                if (outImage == null)
                    return;

                for (; argn < args.Length - 1; argn++)
                {
                    using (Tiff inImage = Tiff.Open(args[argn], "r"))
                    {
                        if (inImage == null)
                            return;

                        do
                        {
                            if (!c.tiffcvt(inImage, outImage) || !outImage.WriteDirectory())
                                return;
                        } while (inImage.ReadDirectory());
                    }
                }
            }
        }