Exemple #1
0
 public static bool SupportsFile(InputParameters parameters)
 {
     return(GetFormat(parameters.InputFormat, parameters.InputFileName) != null);
 }
Exemple #2
0
 public bool SupportsFile(InputParameters parameters)
 {
     return(EngineInternal.SupportsFile(parameters));
 }
Exemple #3
0
        public static FileInfo GetInfo(InputParameters parameters)
        {
            Stream inStream = null;

            try
            {
                using (var b = Platform.Instance.ThreadStart())
                {
                    inStream = parameters.InputStream;
                    if (inStream == null)
                    {
                        inStream = File.OpenRead(parameters.InputFileName);
                    }

                    var inFormat = GetFormat(parameters.InputFormat, parameters.InputFileName);
                    if (inFormat == null)
                    {
                        throw new PabloException(string.Format("Error: Cannot find format to use for file '{0}'", parameters.InputFileName));
                    }

                    using (var sourceDoc = inFormat.Info.Create(Platform.Instance))
                    {
                        sourceDoc.Info.SetOption("animation", "false");
                        sourceDoc.Info.SetOption("autoresize", "true");
                        using (var sourceHandler = sourceDoc.CreateHandler())
                        {
                            var formatId = sourceDoc.Info.OptionID ?? sourceDoc.Info.ID;
                            if (parameters.Options != null)
                            {
                                foreach (var option in sourceDoc.Info.Options)
                                {
                                    var optionId = string.Format("{0}-{1}", formatId, option.ID);
                                    var val      = parameters.Options.FirstOrDefault(r => string.Equals(r.Name, optionId, StringComparison.OrdinalIgnoreCase));
                                    if (val != null)
                                    {
                                        sourceDoc.Info.SetOption(option.ID, val.Value);
                                    }
                                }
                            }

                            sourceDoc.FileName = parameters.InputFileName;
                            sourceDoc.Load(inStream, inFormat, sourceHandler);

                            sourceHandler.Zoom = parameters.Zoom;
                            var drawSize = sourceHandler.DrawSize;
                            if (parameters.MaxWidth != null && drawSize.Width > parameters.MaxWidth.Value)
                            {
                                sourceHandler.Zoom = (float)parameters.MaxWidth.Value / (float)sourceHandler.Size.Width;
                            }

                            drawSize = sourceHandler.DrawSize;
                            return(new FileInfo {
                                ImageWidth = drawSize.Width, ImageHeight = drawSize.Height
                            });
                        }
                    }
                }
            }
            finally
            {
                if (inStream != null && parameters.InputStream == null)
                {
                    inStream.Dispose();
                }
            }
        }
Exemple #4
0
 public FileInfo GetInfo(InputParameters parameters)
 {
     return(EngineInternal.GetInfo(parameters));
 }