public void RegisterExporter(IEnumerable <string> extensions, IImageExporter exporter) { foreach (string extension in extensions) { extensionExporterMap[extension] = exporter; } }
public PixelDataExporter(string fileName, int[] pixelData, int width, int height, Color[] paletteColors, IImageExporter imageExporter, string maskHex) : base(fileName, imageExporter, null, width, height) { this.paletteColors = paletteColors; this.pixelData = pixelData; maskColor = ColorUtils.HexToColor(maskHex); }
/// <param name="displayPrefix"> /// A descriptive name for the format, such as "OpenRaster". This will be displayed /// in the file dialog's filter. /// </param> /// <param name="extensions">A list of supported file extensions (for example, "jpeg" and "JPEG").</param> /// <param name="importer">The importer for this file format, or null if importing is not supported.</param> /// <param name="exporter">The exporter for this file format, or null if exporting is not supported.</param> public FormatDescriptor (string displayPrefix, string[] extensions, IImageImporter importer, IImageExporter exporter) { if (extensions == null || (importer == null && exporter == null)) { throw new ArgumentNullException ("Format descriptor is initialized incorrectly"); } this.Extensions = extensions; this.Importer = importer; this.Exporter = exporter; FileFilter ff = new FileFilter (); StringBuilder formatNames = new StringBuilder (); foreach (string ext in extensions) { if (formatNames.Length > 0) formatNames.Append (", "); string wildcard = string.Format ("*.{0}", ext); ff.AddPattern (wildcard); formatNames.Append (wildcard); } ff.Name = string.Format (Catalog.GetString ("{0} image ({1})"), displayPrefix, formatNames); this.Filter = ff; }
/// <param name="displayPrefix"> /// A descriptive name for the format, such as "OpenRaster". This will be displayed /// in the file dialog's filter. /// </param> /// <param name="extensions">A list of supported file extensions (for example, "jpeg" and "JPEG").</param> /// <param name="importer">The importer for this file format, or null if importing is not supported.</param> /// <param name="exporter">The exporter for this file format, or null if exporting is not supported.</param> public FormatDescriptor(string displayPrefix, string[] extensions, IImageImporter importer, IImageExporter exporter) { if (extensions == null || (importer == null && exporter == null)) { throw new ArgumentNullException("Format descriptor is initialized incorrectly"); } this.Extensions = extensions; this.Importer = importer; this.Exporter = exporter; FileFilter ff = new FileFilter(); StringBuilder formatNames = new StringBuilder(); foreach (string ext in extensions) { if (formatNames.Length > 0) { formatNames.Append(", "); } string wildcard = string.Format("*.{0}", ext); ff.AddPattern(wildcard); formatNames.Append(wildcard); } ff.Name = string.Format(Catalog.GetString("{0} image ({1})"), displayPrefix, formatNames); this.Filter = ff; }
public ColorPaletteExporter(string fileName, ColorChip colorChip, IImageExporter imageExporter) { fullFileName = fileName; this.colorChip = colorChip; this.imageExporter = imageExporter; }
public void Dispose() { exporter.Dispose(); engine = null; spriteChip = null; imageExporter = null; exporter = null; }
public ImageExporter(string fileName, IImageExporter imageExporter, Color[] colors, int width, int height) : base(fileName) { this.imageExporter = imageExporter; this.colors = colors; this.width = width; this.height = height; }
public SpriteExporter(string fileName, IEngine engine, IImageExporter imageExporter) { fullFileName = fileName; this.engine = engine; this.imageExporter = imageExporter; spriteChip = engine.spriteChip; var colorMapChip = engine.chipManager.GetChip(ColorMapParser.chipName, false) as ColorChip; colors = colorMapChip == null ? engine.colorChip.colors : colorMapChip.colors; }
public CustomPrintDialog(IImageExporter imageExporter) { InitializeComponent(); this.exportImages = imageExporter.ImageInfos.ToList().Select(info => info.Export()); var pageCollection = new ObservableCollection<PreviewPage>(); var pageCount = 1; foreach (var exportImage in this.exportImages) { pageCollection.Add(new PreviewPage() { BitmapSource = exportImage, PageNumber = pageCount}); pageCount++; } this.listBox.ItemsSource = pageCollection; }
public SpriteExporter(string fileName, IEngine engine, IImageExporter imageExporter, SpriteChip spriteChip = null) { fullFileName = fileName; this.engine = engine; this.imageExporter = imageExporter; this.spriteChip = spriteChip ?? engine.SpriteChip; // var colorMapChip = engine.GetChip(ColorMapParser.chipName, false) as ColorChip; colors = ColorUtils.ConvertColors(engine.ColorChip.hexColors, engine.ColorChip.maskColor, true); // TODO removing the color map chip dependency when exporting moving forward // colors = colorMapChip == null ? engine.ColorChip.colors : colorMapChip.colors; }
public CustomPrintDialog(IImageExporter imageExporter) { InitializeComponent(); this.exportImages = imageExporter.ImageInfos.ToList().Select(info => info.Export()); var pageCollection = new ObservableCollection <PreviewPage>(); var pageCount = 1; foreach (var exportImage in this.exportImages) { pageCollection.Add(new PreviewPage() { BitmapSource = exportImage, PageNumber = pageCount }); pageCount++; } this.listBox.ItemsSource = pageCollection; }
public TilemapExporter(string fileName, IEngine engine, IImageExporter imageExporter) : base(fileName, imageExporter) { this.engine = engine; }
public TilemapFlagExporter(string fileName, IEngine engine, IImageExporter imageExporter) : base(fileName, engine, imageExporter) { }
public PixelDataExporter(string fileName, int[] pixelData, int width, int height, IColor[] paletteColors, IImageExporter imageExporter) : base(fileName, imageExporter, null) { this.paletteColors = paletteColors; this.pixelData = pixelData; this.width = width; this.height = height; }
internal ImageExporterInfo(IImageExporter sourceImageExporter) { _sourceImageExporter = sourceImageExporter; }
protected override bool Setup() { ReadConfigs(); CreateTasks(); mMapExporter = new GorgonMapExporter() { atlasHeight = 4096, atlasWidth = 4096 }; mImageExporter = new PngImageExporter(); var setup = base.Setup(); var ptr = TextureManager.Singleton.CreateManual("RttTex", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, TextureType.TEX_TYPE_2D, 148, 148, 0, PixelFormat.PF_R8G8B8A8, (int)TextureUsage.TU_RENDERTARGET ); mRTT = ptr.GetBuffer().GetRenderTarget(); mRTVP = mRTT.AddViewport(mCamera); mRTVP.BackgroundColour = new ColourValue(0, 0, 0, 0); mRTVP.SetClearEveryFrame(true); mRTVP.OverlaysEnabled = false; //Calculate diagonal distance value //mPythDistance = (mDistance / Mogre.Math.Sqrt(2)); var altitude = new Degree(mCameraAngle); var angles = new float[] { 180f, // South 135f, // Southeast 90f, // East 45f, // Northeast 0f, // North -45f, // Northwest -90f, // West -135f, // Southwest }; mCameraDirections = new List <string> { "s", "se", "e", "ne", "n", "nw", "w", "sw" }; mCameraPositions = new List <Vector3>(); for (var i = 0; i < 8; i++) { float azimuth = angles[i]; string dirname = mCameraDirections[i]; Vector3 pos = getPosOnSphere(mDistance, new Degree(-azimuth), -altitude); mCameraPositions.Add(pos); Console.WriteLine("Determined camera pos: {0,2} is {1,5:F2},{2,5:F2},{3,5:F2}", dirname, pos.x, pos.y, pos.z); } /* * mCameraPositions = new List<Vector3> { * new Vector3(0, mDistance, mDistance), // Front / South * new Vector3(-mPythDistance, mDistance, mPythDistance), // Front-right / southwest * new Vector3(-mDistance, mDistance, 0), // Right / west * new Vector3(-mPythDistance, mDistance, -mPythDistance), // Back-right / northwest * new Vector3(0, mDistance, -mDistance), // Back / north * new Vector3(mPythDistance, mDistance, -mPythDistance), // Back-left / northeast * new Vector3(mDistance, mDistance, 0), // Left / east * new Vector3(mPythDistance, mDistance, mPythDistance), // Front-left / southeast * }; */ //CompositorManager.Singleton.AddCompositor(vp, "EdgeDetectCompositor", 0); //CompositorManager.Singleton.AddCompositor(rtvp, "EdgeDetectCompositor", 0); //CompositorManager.Singleton.SetCompositorEnabled(vp, "EdgeDetectCompositor", true); //CompositorManager.Singleton.SetCompositorEnabled(rtvp, "EdgeDetectCompositor", true); /*CompositorManager.Singleton.AddCompositor(vp, "Pixelate", 0); * CompositorManager.Singleton.AddCompositor(mRTVP, "Pixelate", 0); * CompositorManager.Singleton.SetCompositorEnabled(vp, "Pixelate", true); * CompositorManager.Singleton.SetCompositorEnabled(mRTVP, "Pixelate", true);*/ //CompositorManager.Singleton.AddCompositor(vp, "Normal", 0); //CompositorManager.Singleton.AddCompositor(rtvp, "Normal", 0); //CompositorManager.Singleton.SetCompositorEnabled(vp, "Normal", true); //CompositorManager.Singleton.SetCompositorEnabled(rtvp, "Normal", true); //CompositorManager.Singleton.AddCompositor(vp, "SMAA", 0); //CompositorManager.Singleton.AddCompositor(rtvp, "SMAA", 0); //CompositorManager.Singleton.SetCompositorEnabled(vp, "SMAA", true); //CompositorManager.Singleton.SetCompositorEnabled(rtvp, "SMAA", true); //CompositorManager.Singleton.AddCompositor(vp, "FXAA", 0); //CompositorManager.Singleton.AddCompositor(rtvp, "FXAA", 0); //CompositorManager.Singleton.SetCompositorEnabled(vp, "FXAA", true); //CompositorManager.Singleton.SetCompositorEnabled(rtvp, "FXAA", true); //Set up task scheduler imageTrimScheduler = new LimitedConcurrencyLevelTaskScheduler(3); imageTrimTaskFactory = new TaskFactory(imageTrimScheduler); imagePackScheduler = new LimitedConcurrencyLevelTaskScheduler(1); imagePackTaskFactory = new TaskFactory(imagePackScheduler); return(setup); }
public static int Launch(string[] args) { ProgramArguments arguments = ProgramArguments.Parse(args); if (arguments == null) { return((int)FailCode.FailedParsingArguments); } else { // make sure we have our list of exporters Exporters.Load(); // try to find matching exporters IImageExporter imageExporter = null; IMapExporter mapExporter = null; string imageExtension = Path.GetExtension(arguments.image).Substring(1).ToLower(); foreach (var exporter in Exporters.ImageExporters) { if (exporter.ImageExtension.ToLower() == imageExtension) { imageExporter = exporter; break; } } if (imageExporter == null) { Console.WriteLine("Failed to find exporters for specified image type."); return((int)FailCode.ImageExporter); } if (!string.IsNullOrEmpty(arguments.map)) { string mapExtension = Path.GetExtension(arguments.map).Substring(1).ToLower(); foreach (var exporter in Exporters.MapExporters) { if (exporter.MapExtension.ToLower() == mapExtension) { mapExporter = exporter; break; } } if (mapExporter == null) { Console.WriteLine("Failed to find exporters for specified map type."); return((int)FailCode.MapExporter); } } // compile a list of images List <string> images = new List <string>(); FindImages(arguments, images); // make sure we found some images if (images.Count == 0) { Console.WriteLine("No images to pack."); return((int)FailCode.NoImages); } // make sure no images have the same name if we're building a map if (mapExporter != null) { for (int i = 0; i < images.Count; i++) { string str1 = Path.GetFileNameWithoutExtension(images[i]); for (int j = i + 1; j < images.Count; j++) { string str2 = Path.GetFileNameWithoutExtension(images[j]); if (str1 == str2) { Console.WriteLine("Two images have the same name: {0} = {1}", images[i], images[j]); return((int)FailCode.ImageNameCollision); } } } } // generate our output ImagePacker imagePacker = new ImagePacker(); Bitmap outputImage; Dictionary <string, Rectangle> outputMap; // pack the image, generating a map only if desired int result = imagePacker.PackImage(images, arguments.pow2, arguments.sqr, arguments.mw, arguments.mh, arguments.pad, mapExporter != null, out outputImage, out outputMap); if (result != 0) { Console.WriteLine("There was an error making the image sheet."); return(result); } // try to save using our exporters try { if (File.Exists(arguments.image)) { File.Delete(arguments.image); } imageExporter.Save(arguments.image, outputImage); } catch (Exception e) { Console.WriteLine("Error saving file: " + e.Message); return((int)FailCode.FailedToSaveImage); } if (mapExporter != null) { try { if (File.Exists(arguments.map)) { File.Delete(arguments.map); } mapExporter.Save(arguments.map, outputMap); } catch (Exception e) { Console.WriteLine("Error saving file: " + e.Message); return((int)FailCode.FailedToSaveMap); } } } return(0); }
/// <summary> /// Registers <paramref name="exporter"/> that will be used for exporting images accepting all extensions that <paramref name="exporter"/> supports. /// </summary> /// <param name="exporter"></param> public void RegisterExporter(IImageExporter exporter) { RegisterExporter(exporter.GetSupportedExtensions(), exporter); }
public FontExporter(string fileName, IEngine engine, IImageExporter imageExporter) : base(fileName, engine, imageExporter, engine.fontChip) { }
public ImagePipeline(IImageLoader loader, IImageExporter exporter) { this.loader = loader; this.exporter = exporter; }
public static void Launch(string dir) { // make sure we have our list of exporters Exporters.Exporters.Load(); // try to find matching exporters IImageExporter imageExporter = null; IMapExporter mapExporter = null; string imageExtension = "png"; foreach (var exporter in Exporters.Exporters.ImageExporters) { if (exporter.ImageExtension.ToLower() == imageExtension) { imageExporter = exporter; break; } } string mapExtension = "txt"; foreach (var exporter in Exporters.Exporters.MapExporters) { if (exporter.MapExtension.ToLower() == mapExtension) { mapExporter = exporter; break; } } // compile a list of images List <string> images = new List <string>(); List <string> images_lowres = new List <string>(); List <string> images_highres = new List <string>(); foreach (string str in Directory.GetFiles(dir, "*.png")) { if (str.EndsWith(".small.png")) { images_lowres.Add(str.Substring(str.LastIndexOf(@"\") + 1).Replace(".small.png", "")); } else { images.Add(str); } } if (Directory.Exists(dir + "_huge")) { foreach (string str in Directory.GetFiles(dir + "_huge", "*.png")) { images_highres.Add(str.Substring(str.LastIndexOf(@"\") + 1).Replace(".png", "")); } } // generate our output ImagePacker imagePacker = new ImagePacker(); Bitmap outputImage; Dictionary <string, Rectangle> outputMap; // pack the image, generating a map only if desired int result = imagePacker.PackImage(images, true, false, 2048, 2048, 2, true, out outputImage, out outputMap); string sheetName = dir.Substring(dir.LastIndexOf(@"/") + 1); Bitmap bmpLowres = new Bitmap(outputImage, new Size(outputImage.Width / 2, outputImage.Height / 2)); Graphics gfxLowres = Graphics.FromImage(bmpLowres); gfxLowres.CompositingMode = CompositingMode.SourceCopy; Bitmap bmpHighres = new Bitmap(outputImage, new Size(outputImage.Width * 2, outputImage.Height * 2)); Graphics gfxHighres = Graphics.FromImage(bmpHighres); gfxHighres.CompositingMode = CompositingMode.SourceCopy; foreach (var m in outputMap) { if (m.Value.Width % 2 != 0) { Console.WriteLine("FATAL: width of " + m.Key + " is not div 2"); } if (m.Value.Height % 2 != 0) { Console.WriteLine("FATAL: width of " + m.Key + " is not div 2"); } string spriteName = m.Key.Substring(m.Key.LastIndexOf(@"\") + 1).Replace(".png", ""); if (images_lowres.Contains(spriteName)) { Bitmap spriteLowres = Bitmap.FromFile(m.Key.Replace(".png", ".small.png")) as Bitmap; gfxLowres.DrawImageUnscaledAndClipped(spriteLowres, new Rectangle(m.Value.X / 2, m.Value.Y / 2, m.Value.Width / 2, m.Value.Height / 2)); } Brush transparentBrush = new SolidBrush(Color.Transparent); if (images_highres.Contains(spriteName)) { Bitmap spriteHighres = Bitmap.FromFile(dir + "_huge\\" + spriteName + ".png") as Bitmap; if (spriteHighres.Width != m.Value.Width * 2 || spriteHighres.Height != m.Value.Height * 2) { Console.WriteLine("FATAL: dimensions of high res sprite " + m.Key + " do not match!"); } // wipe away any sprite gunk that bled into the padding region from the upscale. gfxHighres.FillRectangle(transparentBrush, new Rectangle(m.Value.X * 2 - 4, m.Value.Y * 2 - 4, m.Value.Width * 2 + 8, m.Value.Height * 2 + 8)); gfxHighres.DrawImageUnscaledAndClipped(spriteHighres, new Rectangle(m.Value.X * 2, m.Value.Y * 2, m.Value.Width * 2, m.Value.Height * 2)); } sb.AppendFormat(" textureLocations.Add(OsuTexture.{0}, new SpriteSheetTexture(\"{1}\", {2}, {3}, {4}, {5}));\r\n", spriteName, sheetName, m.Value.Left, m.Value.Top, m.Value.Width, m.Value.Height); } if (result != 0) { Console.WriteLine("There was an error making the image sheet for " + dir); return; } if (File.Exists(dir)) { File.Delete(dir); } imageExporter.Save(dir + "_960.png", outputImage); bmpLowres.Save(dir + "_480.png", ImageFormat.Png); bmpHighres.Save(dir + "_1920.png", ImageFormat.Png); }
protected override bool Setup() { ReadConfigs(); CreateTasks(); mMapExporter = new GorgonMapExporter() { atlasHeight = 4096, atlasWidth = 4096 }; mImageExporter = new PngImageExporter(); var setup = base.Setup(); var ptr = TextureManager.Singleton.CreateManual("RttTex", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, TextureType.TEX_TYPE_2D, 148, 148, 0, PixelFormat.PF_R8G8B8A8, (int)TextureUsage.TU_RENDERTARGET ); mRTT = ptr.GetBuffer().GetRenderTarget(); mRTVP = mRTT.AddViewport(mCamera); mRTVP.BackgroundColour = new ColourValue(0, 0, 0, 0); mRTVP.SetClearEveryFrame(true); mRTVP.OverlaysEnabled = false; //Calculate diagonal distance value //mPythDistance = (mDistance / Mogre.Math.Sqrt(2)); var altitude = new Degree(mCameraAngle); var angles = new float[]{ 180f, // South 135f, // Southeast 90f, // East 45f, // Northeast 0f, // North -45f, // Northwest -90f, // West -135f, // Southwest }; mCameraDirections = new List<string> { "s", "se", "e", "ne", "n", "nw", "w", "sw" }; mCameraPositions = new List<Vector3>(); for (var i = 0; i < 8; i++) { float azimuth = angles[i]; string dirname = mCameraDirections[i]; Vector3 pos = getPosOnSphere(mDistance, new Degree(-azimuth), -altitude); mCameraPositions.Add(pos); Console.WriteLine("Determined camera pos: {0,2} is {1,5:F2},{2,5:F2},{3,5:F2}", dirname, pos.x, pos.y, pos.z); } /* mCameraPositions = new List<Vector3> { new Vector3(0, mDistance, mDistance), // Front / South new Vector3(-mPythDistance, mDistance, mPythDistance), // Front-right / southwest new Vector3(-mDistance, mDistance, 0), // Right / west new Vector3(-mPythDistance, mDistance, -mPythDistance), // Back-right / northwest new Vector3(0, mDistance, -mDistance), // Back / north new Vector3(mPythDistance, mDistance, -mPythDistance), // Back-left / northeast new Vector3(mDistance, mDistance, 0), // Left / east new Vector3(mPythDistance, mDistance, mPythDistance), // Front-left / southeast }; */ //CompositorManager.Singleton.AddCompositor(vp, "EdgeDetectCompositor", 0); //CompositorManager.Singleton.AddCompositor(rtvp, "EdgeDetectCompositor", 0); //CompositorManager.Singleton.SetCompositorEnabled(vp, "EdgeDetectCompositor", true); //CompositorManager.Singleton.SetCompositorEnabled(rtvp, "EdgeDetectCompositor", true); /*CompositorManager.Singleton.AddCompositor(vp, "Pixelate", 0); CompositorManager.Singleton.AddCompositor(mRTVP, "Pixelate", 0); CompositorManager.Singleton.SetCompositorEnabled(vp, "Pixelate", true); CompositorManager.Singleton.SetCompositorEnabled(mRTVP, "Pixelate", true);*/ //CompositorManager.Singleton.AddCompositor(vp, "Normal", 0); //CompositorManager.Singleton.AddCompositor(rtvp, "Normal", 0); //CompositorManager.Singleton.SetCompositorEnabled(vp, "Normal", true); //CompositorManager.Singleton.SetCompositorEnabled(rtvp, "Normal", true); //CompositorManager.Singleton.AddCompositor(vp, "SMAA", 0); //CompositorManager.Singleton.AddCompositor(rtvp, "SMAA", 0); //CompositorManager.Singleton.SetCompositorEnabled(vp, "SMAA", true); //CompositorManager.Singleton.SetCompositorEnabled(rtvp, "SMAA", true); //CompositorManager.Singleton.AddCompositor(vp, "FXAA", 0); //CompositorManager.Singleton.AddCompositor(rtvp, "FXAA", 0); //CompositorManager.Singleton.SetCompositorEnabled(vp, "FXAA", true); //CompositorManager.Singleton.SetCompositorEnabled(rtvp, "FXAA", true); //Set up task scheduler imageTrimScheduler = new LimitedConcurrencyLevelTaskScheduler(3); imageTrimTaskFactory = new TaskFactory(imageTrimScheduler); imagePackScheduler = new LimitedConcurrencyLevelTaskScheduler(1); imagePackTaskFactory = new TaskFactory(imagePackScheduler); return setup; }
public ImageExporter(string fileName, IImageExporter imageExporter, IColor[] colors = null) : base(fileName) { this.imageExporter = imageExporter; this.colors = colors; }
/// <summary> /// Registers <paramref name="exporter"/> that will be used for exporting images with <paramref name="extension"/> /// </summary> /// <param name="extension">Supported extension</param> /// <param name="exporter"></param> public void RegisterExporter(string extension, IImageExporter exporter) { RegisterExporter(new List <string> { extension }, exporter); }