(Picture picture, boolean horizontal, int[] seamIndices)
| 89 | // pixels over the calculate seam. Due to the lack of a copy |
| 90 | // constructor, it also alters the original picture. |
| 91 | public static Picture seamOverlay(Picture picture, boolean horizontal, int[] seamIndices) { |
| 92 | Picture overlaid = new Picture(picture.width(), picture.height()); |
| 93 | int width = picture.width(); |
| 94 | int height = picture.height(); |
| 95 | |
| 96 | for (int col = 0; col < width; col++) |
| 97 | for (int row = 0; row < height; row++) |
| 98 | overlaid.set(col, row, picture.get(col, row)); |
| 99 | |
| 100 | |
| 101 | // if horizontal seam, then set one pixel in every column |
| 102 | if (horizontal) { |
| 103 | for (int col = 0; col < width; col++) |
| 104 | overlaid.set(col, seamIndices[col], Color.RED); |
| 105 | } |
| 106 | |
| 107 | // if vertical, put one pixel in every row |
| 108 | else { |
| 109 | for (int row = 0; row < height; row++) |
| 110 | overlaid.set(seamIndices[row], row, Color.RED); |
| 111 | } |
| 112 | |
| 113 | return overlaid; |
| 114 | } |
| 115 | |
| 116 | } |
no test coverage detected