public void ValidateImportTesting(string output) { var dd33 = new RawImageParams { height = height, width = width, heightScaleMultiplier = 8, zeroOffset = -269 }; var test = RawImage.LoadGrayscale16($"{output}_hm", dd33); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { if (test[i, j] != Heightmap[i, j]) { var dd = test[i, j]; var dd2 = Heightmap[i, j]; { } } } } RawImage.SaveMap($"{output}_rawr", test, HeightMin, ColorDepth.Gray16); }
public static void SaveRawMetadataToJson(string path, int width, int height, int zeroOffset) { var rawParams = new RawImageParams { width = width, height = height, zeroOffset = zeroOffset }; var jsonText = JsonConvert.SerializeObject(rawParams); File.WriteAllText($"{path}.json", jsonText); }
/// <summary> /// Saves texture placemnt map /// </summary> /// <param name="output"></param> /// <param name="texturePlacement"></param> public static float[,] LoadGrayscale16(string path, RawImageParams rawParams) { var pathFix = path.EndsWith(".raw") ? path : $"{path}.raw"; var reader = new BinaryReader(File.Open(pathFix, FileMode.Open, FileAccess.Read)); var padding = 1; var image = new float[rawParams.height + padding, rawParams.width + padding]; for (int i = image.GetLength(0) - 1 - padding; i >= 0; i--) { for (int j = 0; j < image.GetLength(1) - padding; j++) { var pix = reader.ReadUInt16(); image[i, j] = (pix / rawParams.heightScaleMultiplier) + rawParams.zeroOffset; } } reader.Dispose(); return(image); }