Sets pixels that are within roi and part of the mask to the foreground color. Does nothing if the mask is not the same size as the ROI.
(ImageProcessor mask)
| 219 | /** Sets pixels that are within roi and part of the mask to the foreground |
| 220 | color. Does nothing if the mask is not the same size as the ROI. */ |
| 221 | public void fill(ImageProcessor mask) { |
| 222 | if (mask==null) |
| 223 | {fill(); return;} |
| 224 | int roiWidth=this.roiWidth, roiHeight=this.roiHeight; |
| 225 | int roiX=this.roiX, roiY=this.roiY; |
| 226 | if (mask.getWidth()!=roiWidth||mask.getHeight()!=roiHeight) { |
| 227 | mask = getMask(); |
| 228 | if (mask==null||mask.getWidth()!=roiWidth||mask.getHeight()!=roiHeight) |
| 229 | return; |
| 230 | } |
| 231 | byte[] mpixels = (byte[])mask.getPixels(); |
| 232 | for (int y=roiY, my=0; y<(roiY+roiHeight); y++, my++) { |
| 233 | int i = y * width + roiX; |
| 234 | int mi = my * roiWidth; |
| 235 | for (int x=roiX; x<(roiX+roiWidth); x++) { |
| 236 | if (mpixels[mi++]!=0) |
| 237 | pixels[i] = (byte)fgColor; |
| 238 | i++; |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | public int getPixel(int x, int y) { |
| 244 | if (x>=0 && x<width && y>=0 && y<height) |
no test coverage detected