コード例 #1
0
        public ImageConverterManager()
        {
            formats = new List <FormatDescriptor> ();

            // Create all the formats supported by Gdk
            foreach (var format in Pixbuf.Formats)
            {
                string   formatName          = format.Name.ToLowerInvariant();
                string   formatNameUpperCase = formatName.ToUpperInvariant();
                string[] extensions;

                switch (formatName)
                {
                case "jpeg":
                    extensions = new string[] { "jpg", "jpeg", "JPG", "JPEG" };
                    break;

                case "tiff":
                    extensions = new string[] { "tif", "tiff", "TIF", "TIFF" };
                    break;

                default:
                    extensions = new string[] { formatName, formatNameUpperCase };
                    break;
                }

                GdkPixbufFormat importer = new GdkPixbufFormat(format.Name.ToLowerInvariant());
                IImageExporter  exporter;

                if (formatName == "jpeg")
                {
                    exporter = importer = new JpegFormat();
                }
                else if (formatName == "tga")
                {
                    exporter = new TgaExporter();
                }
                else if (format.IsWritable)
                {
                    exporter = importer;
                }
                else
                {
                    exporter = null;
                }

                RegisterFormat(new FormatDescriptor(formatName, formatNameUpperCase, extensions, importer, exporter));
            }

            // Create all the formats we have our own importers/exporters for
            OraFormat oraHandler = new OraFormat();

            RegisterFormat(new FormatDescriptor("ora", "OpenRaster", new string[] { "ora" }, oraHandler, oraHandler));
        }
コード例 #2
0
        public ImageConverterManager()
        {
            formats = new List<FormatDescriptor> ();

            // Create all the formats supported by Gdk
            foreach (var format in Pixbuf.Formats) {
                string formatName = format.Name.ToLowerInvariant ();
                string formatNameUpperCase = formatName.ToUpperInvariant ();
                string[] extensions;

                switch (formatName) {
                    case "jpeg":
                        extensions = new string[] { "jpg", "jpeg", "JPG", "JPEG" };
                        break;
                    case "tiff":
                        extensions = new string[] { "tif", "tiff", "TIF", "TIFF" };
                        break;
                    default:
                        extensions = new string[] { formatName, formatNameUpperCase };
                        break;
                }

                GdkPixbufFormat importer = new GdkPixbufFormat (format.Name.ToLowerInvariant ());
                IImageExporter exporter;

                if (formatName == "jpeg")
                    exporter = importer = new JpegFormat ();
                else if (formatName == "tga")
                    exporter = new TgaExporter ();
                else if (format.IsWritable)
                    exporter = importer;
                else
                    exporter = null;

                RegisterFormat (new FormatDescriptor (formatName, formatNameUpperCase, extensions, importer, exporter));
            }

            // Create all the formats we have our own importers/exporters for
            OraFormat oraHandler = new OraFormat ();
            RegisterFormat (new FormatDescriptor ("ora", "OpenRaster", new string[] { "ora" }, oraHandler, oraHandler));
        }
コード例 #3
0
ファイル: FileActions.cs プロジェクト: linuxmhall/Pinta
        private void FillFormats()
        {
            foreach (var format in Pixbuf.Formats) {
                string formatName = format.Name.ToLowerInvariant ();
                string[] extensions = (formatName == "jpeg") ? new string[] { "jpg", "jpeg" } : new string[] { formatName };
                GdkPixbufFormat importer = new GdkPixbufFormat (format.Name.ToLowerInvariant ());
                IImageExporter exporter;

                if (formatName == "jpeg")
                    exporter = importer = new JpegFormat ();
                else if (formatName == "tga")
                    exporter = new TgaExporter ();
                else if (format.IsWritable)
                    exporter = importer;
                else
                    exporter = null;

                formats.Add (new FormatDescriptor (formatName, formatName.ToUpperInvariant(), extensions, importer, exporter));
            }

            OraFormat oraHandler = new OraFormat ();
            formats.Add (new FormatDescriptor ("ora", "OpenRaster", new string[] { "ora" }, oraHandler, oraHandler));

            foreach (var fd in formats) {
                foreach (var ext in fd.Extensions) {
                    formatsByExt.Add (string.Format (".{0}", ext), fd);
                }
            }
        }