private boolean planeEquals(Picture other, int plane) { int cw = color.compWidth[plane]; int ch = color.compHeight[plane]; int offA = other.getCrop() == null ? 0 : ((other.getCrop().getX() >> cw) + (other.getCrop().getY() >> ch) * (other.getWidth() >> cw)); int offB = crop == null ? 0 : ((crop.getX() >> cw) + (crop.getY() >> ch) * (width >> cw)); byte[] planeData = other.getPlaneData(plane); for (int i = 0; i < getCroppedHeight() >> ch; i++, offA += (other.getWidth() >> cw), offB += (width >> cw)) { for (int j = 0; j < getCroppedWidth() >> cw; j++) { if (planeData[offA + j] != data[plane][offB + j]) return false; } } return true; }
@Override public LoanerPicture filter(Picture picture, PixelStore store) { if (transform == null) { transform = ColorUtil.getTransform(picture.getColor(), outputColor); Logger.debug("Creating transform: " + transform); } LoanerPicture outFrame = store.getPicture(picture.getWidth(), picture.getHeight(), outputColor); outFrame.getPicture().setCrop(picture.getCrop()); transform.transform(picture, outFrame.getPicture()); return outFrame; }
public static BufferedImage toBufferedImage(Picture src) { if (src.getColor() != ColorSpace.BGR) { Picture bgr = Picture.createCropped(src.getWidth(), src.getHeight(), ColorSpace.BGR, src.getCrop()); if (src.getColor() == ColorSpace.RGB) { new RgbToBgr().transform(src, bgr); } else { Transform transform = ColorUtil.getTransform(src.getColor(), ColorSpace.RGB); transform.transform(src, bgr); new RgbToBgr().transform(bgr, bgr); } src = bgr; } BufferedImage dst = new BufferedImage(src.getCroppedWidth(), src.getCroppedHeight(), BufferedImage.TYPE_3BYTE_BGR); if (src.getCrop() == null) toBufferedImage(src, dst); else toBufferedImageCropped(src, dst); return dst; }
public static BufferedImage toBufferedImage(Picture src, DemuxerTrackMeta.Orientation orientation) { if (src.getColor() != ColorSpace.BGR) { Picture bgr = Picture.createCropped(src.getWidth(), src.getHeight(), ColorSpace.BGR, src.getCrop()); if (src.getColor() == ColorSpace.RGB) { new RgbToBgr().transform(src, bgr); } else { Transform transform = ColorUtil.getTransform(src.getColor(), ColorSpace.RGB); transform.transform(src, bgr); new RgbToBgr().transform(bgr, bgr); } src = bgr; } BufferedImage dst = new BufferedImage(src.getCroppedWidth(), src.getCroppedHeight(), BufferedImage.TYPE_3BYTE_BGR); if (src.getCrop() == null) toBufferedImage(src, dst); else toBufferedImageCropped(src, dst); if (orientation.equals(DemuxerTrackMeta.Orientation.D_90)) return rotate90ToRight(dst); else if (orientation.equals(DemuxerTrackMeta.Orientation.D_180)) return rotate180(dst); else if (orientation.equals(DemuxerTrackMeta.Orientation.D_270)) return rotate90ToLeft(dst); return dst; }