private static void SaveScaledImage() { DirectoryInfo d = new DirectoryInfo(@"..\..\Images\pmstock\"); foreach (var file in d.GetFiles("*.png")) { var originalImage = new Bitmap(file.FullName); string fileName = file.Name; const string imageExtension = ".png"; //originalImage.Save(fileName + "-orig" + imageExtension, ImageFormat.Png); const int scaleSize = 3; var scaledImage = new xBRZScaler().ScaleImage(originalImage, scaleSize); scaledImage.Save(fileName, ImageFormat.Png); } }
private static void SaveScaledImage(int scaleFactor, string inputPath, string outputPath) { var scaledImage = new xBRZScaler().ScaleImage(new Bitmap(inputPath), scaleFactor); scaledImage.Save(outputPath); }
public void ShowDesign(DesignServer.Pattern pattern, System.Action confirm) { if (confirm == null && Cancel == null && Confirm == null && ConfirmImport == null) { return; } // we are coming from items if (confirm == null) { SelectedPattern = pattern; CancelPop.PopOut(); } if (CurrentPreview != null) { CurrentPreview.Dispose(); CurrentPreview = null; } if (CurrentUpscaledPreview != null) { CurrentUpscaledPreview.Dispose(); CurrentUpscaledPreview = null; } this.Pattern = pattern; this.Confirm = confirm; this.DesignName.Open(); this.DesignName.Text = Pattern.Name; this.CreatorName.text = Pattern.Creator; var t = (DesignPattern.TypeEnum)Pattern.Type; try { var acnhFileFormat = new ACNHFileFormat(pattern.Bytes); if (acnhFileFormat.IsPro) { DesignPattern = new ProDesignPattern(); DesignPattern.CopyFrom(acnhFileFormat); } else { DesignPattern = new SimpleDesignPattern(); DesignPattern.CopyFrom(acnhFileFormat); } CurrentPreview = DesignPattern.GetBitmap(); CurrentPreview.Apply(); CurrentPreview.Texture.filterMode = FilterMode.Point; CurrentPreview.Texture.wrapMode = TextureWrapMode.Clamp; CurrentUpscaledPreview = new TextureBitmap(CurrentPreview.Width * 4, CurrentPreview.Height * 4); int[] src = CurrentPreview.ConvertToInt(); int[] target = new int[CurrentUpscaledPreview.Width * CurrentUpscaledPreview.Height]; var scaler = new xBRZScaler(); scaler.ScaleImage(4, src, target, CurrentPreview.Width, CurrentPreview.Height, new xBRZNet.ScalerCfg(), 0, int.MaxValue); CurrentUpscaledPreview.FromInt(target); CurrentUpscaledPreview.Apply(); Previews.AllPreviews[DesignPattern.Type].SetTexture(CurrentUpscaledPreview.Texture); Previews.AllPreviews[DesignPattern.Type].Render(); PatternPreview.texture = CurrentPreview.Texture; DesignPreview.texture = Previews.AllPreviews[DesignPattern.Type].Camera.targetTexture; this.DesignType.text = DesignPatternInformation.Types[t].Name; this.DesignCode.text = "DE-" + pattern.Code; } catch (System.Exception e) { } StartCoroutine(ShowDesignCoroutine()); }