private ColorChannel ReduceChannel(ColorChannel channel, int factor) { int reducedHeight = channel.GetHeight() / factor; int reducedWidth = channel.GetWidth() / factor; ColorChannel result = new ColorChannel(reducedWidth, reducedHeight); for (int y = 0; y < reducedHeight; y++) { for (int x = 0; x < reducedWidth; x++) { int sum = 0; for (int blockY = y * factor; blockY < y * factor + factor; blockY++) { for (int blockX = x * factor; blockX < x * factor + factor; blockX++) { sum += (int)channel.GetPixel(blockX, blockY); } } result.SetPixel(x, y, (int)Math.Round(sum / (double)(factor * factor))); } } return(result); }
private RGBImageBuilder(ColorChannel red) { _imageWidth = red.GetWidth(); _imageHeight = red.GetHeight(); _red = new ColorChannel(GetRealWidth(), GetRealHeight()); _green = new ColorChannel(GetRealWidth(), GetRealHeight()); _blue = new ColorChannel(GetRealWidth(), GetRealHeight()); for (int i = 0; i < red.GetHeight(); i++) { for (int j = 0; j < red.GetWidth(); j++) { _red.SetPixel(j, i, red.GetPixel(j, i)); _green.SetPixel(j, i, red.GetPixel(j, i)); _blue.SetPixel(j, i, red.GetPixel(j, i)); } } }
private void FillPicture() { for (int y = 0; y < _picture.GetHeight(); y++) { for (int x = 0; x < _picture.GetWidth(); x++) { int value; value = (x + y * 8) % 256; _picture.SetPixel(x, y, value); } } }
public int GetWidth() { return(Channel1.GetWidth()); }