public int getCroppedHeight() { return crop == null ? height : crop.getHeight(); }
public int getCroppedHeight() { return crop == null ? height : crop.getHeight(); }
public Picture(int width, int height, byte[][] data, byte[][] lowBits, ColorSpace color, int lowBitsNum, Rect crop) { this.width = width; this.height = height; this.data = data; this.lowBits = lowBits; this.color = color; this.lowBitsNum = lowBitsNum; this.crop = crop; if (color != null) { for (int i = 0; i < color.nComp; i++) { int mask = 0xff >> (8 - color.compWidth[i]); if ((width & mask) != 0) throw new IllegalArgumentException("Component " + i + " width should be a multiple of " + (1 << color.compWidth[i]) + " for colorspace: " + color); if (crop != null && (crop.getWidth() & mask) != 0) throw new IllegalArgumentException("Component " + i + " cropped width should be a multiple of " + (1 << color.compWidth[i]) + " for colorspace: " + color); mask = 0xff >> (8 - color.compHeight[i]); if ((height & mask) != 0) throw new IllegalArgumentException("Component " + i + " height should be a multiple of " + (1 << color.compHeight[i]) + " for colorspace: " + color); if (crop != null && (crop.getHeight() & mask) != 0) throw new IllegalArgumentException("Component " + i + " cropped height should be a multiple of " + (1 << color.compHeight[i]) + " for colorspace: " + color); } } }
protected boolean cropNeeded() { return crop != null && (crop.getX() != 0 || crop.getY() != 0 || crop.getWidth() != width || crop.getHeight() != height); }
public PictureHiBD cropped() { if (crop == null || (crop.getX() == 0 && crop.getY() == 0 && crop.getWidth() == width && crop.getHeight() == height)) return this; PictureHiBD result = PictureHiBD.create(crop.getWidth(), crop.getHeight(), color); for (int plane = 0; plane < color.nComp; plane++) { if (data[plane] == null) continue; cropSub(data[plane], crop.getX() >> color.compWidth[plane], crop.getY() >> color.compHeight[plane], crop.getWidth() >> color.compWidth[plane], crop.getHeight() >> color.compHeight[plane], width >> color.compWidth[plane], result.data[plane]); } return result; }
public Picture cropped() { if (!cropNeeded()) return this; Picture result = Picture.create(crop.getWidth(), crop.getHeight(), color); if(color.planar) { for (int plane = 0; plane < data.length; plane++) { if (data[plane] == null) continue; cropSub(data[plane], crop.getX() >> color.compWidth[plane], crop.getY() >> color.compHeight[plane], crop.getWidth() >> color.compWidth[plane], crop.getHeight() >> color.compHeight[plane], width >> color.compWidth[plane], crop.getWidth() >> color.compWidth[plane], result.data[plane]); } } else { cropSub(data[0], crop.getX(), crop.getY(), crop.getWidth(), crop.getHeight(), width * color.nComp, crop.getWidth() * color.nComp, result.data[0]); } return result; }
public static void subImageWithFillPic8(Picture _in, Picture out, Rect rect) { int width = _in.getWidth(); int height = _in.getHeight(); ColorSpace color = _in.getColor(); byte[][] data = _in.getData(); for (int i = 0; i < data.length; i++) { subImageWithFill(data[i], width >> color.compWidth[i], height >> color.compHeight[i], out.getPlaneData(i), rect.getWidth() >> color.compWidth[i], rect.getHeight() >> color.compHeight[i], rect.getX() >> color.compWidth[i], rect.getY() >> color.compHeight[i]); } } }