/// <summary> /// Creates rgb data for the specified image. </summary> /// <param name="img"> image to cretae rgb data for </param> public FractionRgbData(Image img) { width = img.Width; height = img.Height; //JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java: //ORIGINAL LINE: redValues = new double[height][width]; redValues = RectangularArrays.ReturnRectangularDoubleArray(height, width); //JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java: //ORIGINAL LINE: greenValues = new double[height][width]; greenValues = RectangularArrays.ReturnRectangularDoubleArray(height, width); //JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java: //ORIGINAL LINE: blueValues = new double[height][width]; blueValues = RectangularArrays.ReturnRectangularDoubleArray(height, width); flattenedRgbValues = new double[width * height * 3]; populateRGBArrays(img); }
/// <summary> /// Fills the rgb arrays from image </summary> /// <param name="image"> image to get rgb data from </param> protected internal void populateRGBArrays(Image image) { int color; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { color = image.getPixel(x, y); double red = ((double)Color.getRed(color)) / 256d; redValues[y][x] = red; flattenedRgbValues[(y * width + x)] = red; double green = ((double)Color.getGreen(color)) / 256d; greenValues[y][x] = green; flattenedRgbValues[(width * height + y * width + x)] = green; double blue = ((double)Color.getBlue(color)) / 256d; blueValues[y][x] = blue; flattenedRgbValues[(2 * width * height + y * width + x)] = blue; } } }