public static void CalculateAALayers(PhotonFileHeader photonFileHeader, List <PhotonFileLayer> layers, PhotonAaMatrix photonAaMatrix, Action <string> reportProgress) { var photonLayer = new PhotonLayer(photonFileHeader.GetResolutionX(), photonFileHeader.GetResolutionY()); int[,] source = new int[photonFileHeader.GetResolutionY(), photonFileHeader.GetResolutionX()]; int i = 0; foreach (var layer in layers) { List <BitArray> unpackedImage = layer.UnpackImage(photonFileHeader.GetResolutionX(), photonFileHeader.GetResolutionY()); reportProgress?.Invoke("Calculating AA for photon file layer " + i + "/" + photonFileHeader.GetNumberOfLayers()); for (int y = 0; y < photonFileHeader.GetResolutionY(); y++) { for (int x = 0; x < photonFileHeader.GetResolutionX(); x++) { source[y, x] = 0; } } for (int y = 0; y < unpackedImage.Count; y++) { BitArray currentRow = unpackedImage[y]; if (currentRow != null) { for (int x = 0; x < currentRow.Length; x++) { if (currentRow[x]) { source[y, x] = 255; } } } } // Calc int[,] target = photonAaMatrix.Calc(source); int aaTresholdDiff = 255 / photonFileHeader.GetAntiAliasingLevel(); int aaTreshold = 0; foreach (var aaFileLayer in layer.antiAliasLayers) { photonLayer.Clear(); aaTreshold += aaTresholdDiff; for (int y = 0; y < photonFileHeader.GetResolutionY(); y++) { for (int x = 0; x < photonFileHeader.GetResolutionX(); x++) { if (target[y, x] >= aaTreshold) { photonLayer.Supported(x, y); } } } aaFileLayer.SaveLayer(photonLayer); } i++; } photonLayer.UnLink(); }
public void CalculateAaLayers(Action <string> reportProgress, PhotonAaMatrix photonAaMatrix) { PhotonFileLayer.CalculateAALayers((PhotonFileHeader)iFileHeader, layers, photonAaMatrix, reportProgress); }