public static void SaveRGBArrayAsXYZ(this RgbArray rgbArray, string filePath, bool zeroCentered = false) { var delimeter = "\t"; var utf8WithoutBOM = new UTF8Encoding(false); using var writer = new StreamWriter(filePath, append: false, utf8WithoutBOM); for (int x = 0; x < rgbArray.Width; x++) { for (int y = 0; y < rgbArray.Height; y++) { String.Join(delimeter, ScaleCoordinate(x), ScaleCoordinate(y), ScaleValue(GetMagnitude(rgbArray.data[rgbArray.Height - y - 1][zeroCentered ? (x + rgbArray.Width / 2) % rgbArray.Width : x]))); } } }
public static void SaveRgbArrayAsBmpImage(this RgbArray rgbArray, string filePath, bool zeroCentered = false) { var width = rgbArray.Width; var height = rgbArray.Height; using var image = new Image <Rgb24>(width, height); for (var x = 0; x < width; x++) { for (var y = 0; y < height; y++) { var pixel = rgbArray.data[y][zeroCentered ? (x + width / 2 + width % 2) % width : x]; image[x, y] = new Rgb24(pixel.R, pixel.G, pixel.B); } } using var stream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite); image.SaveAsBmp(stream); }