/// <summary> /// set indices in such a way that no pixels are removed from either side /// </summary> /// <param name="imgIndex"></param> /// <param name="img"></param> /// <param name="indices"></param> public static void SetUnOptimizedValues(int imgIndex, AddTexImageInfo img, OptimizedImgParams[] indices) { for (var y = 0; y < img.Height; y++) { indices[imgIndex].XLimitsAtYIndices[y] = new MinAndMaxIndices { Min = 0, Max = img.Width - 1 } } ; }
/// <summary> /// saves modified individual textures to separate files in the provided folder location /// helps in debugging /// </summary> /// <param name="optimizedImgParams"></param> /// <param name="img"></param> private static void DebugSaveIndicesForImageFile(OptimizedImgParams optimizedImgParams, AddTexImageInfo img) { if (string.IsNullOrWhiteSpace(DebugFolderLocation)) { return; } var sourceBitmap = img.ImageBitmap; var debugImage = new Bitmap(sourceBitmap.Width, sourceBitmap.Height); for (var y = 0; y < optimizedImgParams.XLimitsAtYIndices.Length; y++) { for (var x = optimizedImgParams.XLimitsAtYIndices[y].Min; x <= optimizedImgParams.XLimitsAtYIndices[y].Max; x++) { var pixelColor = sourceBitmap.GetPixel(x, y); debugImage.SetPixel(x, y, pixelColor); } } debugImage.Save(string.Format(@"{0}\ImgWidthOptimizer_{1}.png", DebugFolderLocation, DateTime.Now.Ticks)); }