public PixelMapper2D(int width, int height, PixelOrders pixelOrder) { this.width = width; this.height = height; this.lookupX = new int[width * height]; this.lookupY = new int[width * height]; this.lookupXY = new int[width, height]; this.streamOutput = new byte[width * height * 3]; PopulateFromPixelOrder(pixelOrder); }
private void PopulateFromPixelOrder(PixelOrders pixelOrder) { int pos = 0; var populate = new Action <int, int, int>((x, y, p) => { this.lookupX[p] = x; this.lookupY[p] = y; this.lookupXY[x, y] = p; }); if (pixelOrder == PixelOrders.HorizontalLineTopLeft) { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { populate(x, y, pos); pos++; } } } else if (pixelOrder == PixelOrders.HorizontalSnakeTopLeft) { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { populate(x, y, pos); pos++; } if (++y < height) { for (int x = width - 1; x >= 0; x--) { populate(x, y, pos); pos++; } } } } else { throw new NotImplementedException(); } }
private void PopulateFromPixelOrder(PixelOrders pixelOrder) { int pos = 0; var populate = new Action<int, int, int>((x, y, p) => { this.lookupX[p] = x; this.lookupY[p] = y; this.lookupXY[x, y] = p; }); if (pixelOrder == PixelOrders.HorizontalLineTopLeft) { for (int y = 0; y < height; y++) for (int x = 0; x < width; x++) { populate(x, y, pos); pos++; } } else if (pixelOrder == PixelOrders.HorizontalSnakeTopLeft) { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { populate(x, y, pos); pos++; } if (++y < height) { for (int x = width - 1; x >= 0; x--) { populate(x, y, pos); pos++; } } } } else throw new NotImplementedException(); }