public void InitRGBromYUV() { var matrixMapR = new int[Height, Width]; var matrixMapG = new int[Height, Width]; var matrixMapB = new int[Height, Width]; for (int i = 0; i < Height; i++) { for (int j = 0; j < Width; j++) { var R = +YUVConverstionMatrix[0, 0] * YUVMatrix.Y[i, j] + YUVConverstionMatrix[1, 0] * (YUVMatrix.U[i, j] - 128) + YUVConverstionMatrix[2, 0] * (YUVMatrix.V[i, j] - 128); var G = +YUVConverstionMatrix[0, 1] * YUVMatrix.Y[i, j] + YUVConverstionMatrix[1, 1] * (YUVMatrix.U[i, j] - 128) + YUVConverstionMatrix[2, 1] * (YUVMatrix.V[i, j] - 128); var B = +YUVConverstionMatrix[0, 2] * YUVMatrix.Y[i, j] + YUVConverstionMatrix[1, 2] * (YUVMatrix.U[i, j] - 128) + YUVConverstionMatrix[2, 2] * (YUVMatrix.V[i, j] - 128); StabilizeColor(R, out matrixMapR[i, j]); StabilizeColor(G, out matrixMapG[i, j]); StabilizeColor(B, out matrixMapB[i, j]); } } RGBMatrix = new RGBColors() { R = matrixMapR, G = matrixMapG, B = matrixMapB, }; }
public PPM(string filename, int width, int height, int maxValue) { FileName = filename; Width = width; Height = height; MaxValue = maxValue; YUVMatrix = new YUVColors(); RGBMatrix = new RGBColors(); }
public static PPM ReadPPM(string file) { using (StreamReader reader = new StreamReader(Path.Combine(projectPath, file))) { if (reader.ReadLine() != "P3") { return(null); } int width, height; var ListForRatio = reader.ReadLine().Split(" ").ToList(); if (!int.TryParse(ListForRatio[0].Trim(), out width) || !int.TryParse(ListForRatio[1].Trim(), out height)) { return(null); } var matrixMapR = new int[height, width]; var matrixMapG = new int[height, width]; var matrixMapB = new int[height, width]; int maxValue; if (!int.TryParse(reader.ReadLine(), out maxValue)) { return(null); } //Read in the pixels for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { matrixMapR[i, j] = int.Parse(reader.ReadLine()); matrixMapG[i, j] = int.Parse(reader.ReadLine()); matrixMapB[i, j] = int.Parse(reader.ReadLine()); } } var colorsRGB = new RGBColors() { R = matrixMapR, G = matrixMapG, B = matrixMapB, }; return(new PPM(file, width, height, maxValue) { RGBMatrix = colorsRGB }); } }
public OperatorsResponse CreateOperatorResponse(List <OperatorEN> pOperators) { OperatorsResponse response = new OperatorsResponse(); Operators operators = new Operators(); operators.countryOperators = new List <CountryOperators>(); foreach (var countryOperatr in pOperators) { CountryOperators _countryOperator = new CountryOperators(); _countryOperator.operatorID = countryOperatr.OperatorID; _countryOperator.name = countryOperatr.Name; _countryOperator.brand = countryOperatr.Brand; _countryOperator.mnc = countryOperatr.Mnc; _countryOperator.operatorLogo = countryOperatr.OperatorLogo; _countryOperator.logoUrl = countryOperatr.LogoUrl; _countryOperator.logoVersion = countryOperatr.LogoVersion; _countryOperator.HexColor = countryOperatr.HEXColor; _countryOperator.RGBColor = countryOperatr.RGBColor; _countryOperator.Relevance = countryOperatr.Relevance; RGBColors rgbColor = new RGBColors(); if (!string.IsNullOrEmpty(countryOperatr.RGBColor)) { var codeColor = countryOperatr.RGBColor.Split(','); rgbColor.R = int.Parse(codeColor[0].ToString()); rgbColor.G = int.Parse(codeColor[1].ToString()); rgbColor.B = int.Parse(codeColor[2].ToString()); } _countryOperator.rgbColor = rgbColor; operators.countryOperators.Add(_countryOperator); } response.operators = operators; response.count = operators.countryOperators.Count; return(response); }