public CacheSequenceStream( ImageType<T> imageType ) { queueBoof = imageType.createArray(2); queueBuff = new BufferedImage[2]; for (int i = 0; i < 2; i++) { queueBoof[i] = imageType.createImage(1,1); queueBuff[i] = new BufferedImage(1,1,BufferedImage.TYPE_INT_RGB); } this.imageType = imageType; }
/** * */ public BufferedFileImageSequence(ImageType<T> type, BufferedImage[] orig) { this.type = type; this.orig = orig; images = type.createArray( orig.length ); for( int i = 0; i < orig.length; i++ ) { BufferedImage b = orig[i]; images[i] = type.createImage(b.getWidth(),b.getHeight()); ConvertBufferedImage.convertFrom(orig[i], images[i], true); } }
/** * Will load an image sequence with no modification. * * @param directory The directory containing the images. * @param suffix The suffix that the images have. */ public BufferedFileImageSequence(ImageType<T> type, File directory, String suffix) { this.type = type; if (!directory.isDirectory()) throw new IllegalArgumentException("directory must specify a directory"); String[] files = directory.list(new Filter(suffix)); List<String> listNames = new ArrayList<>(); for( String s : files ) { listNames.add(s); } Collections.sort(listNames); orig = new BufferedImage[ files.length ]; images = type.createArray( files.length ); int index = 0; for (String s : listNames) { BufferedImage b = orig[index] = UtilImageIO.loadImage(directory.getPath()+"/"+s); T a = images[index++] = type.createImage(b.getWidth(),b.getHeight()); ConvertBufferedImage.convertFrom(b, a, true); } }
/** * Initializes internal data structures based on the input image's size. Should be called each time a new image * is processed. * @param width Image width * @param height Image height */ @Override public void initialize(int width, int height) { // see if it has already been initialized if( bottomWidth == width && bottomHeight == height ) return; this.bottomWidth = width; this.bottomHeight = height; layers = imageType.createArray(getNumLayers()); double scaleFactor = getScale(0); if (scaleFactor == 1) { if (!saveOriginalReference) { layers[0] = imageType.createImage(bottomWidth, bottomHeight); } } else { layers[0] = imageType.createImage((int)Math.ceil(bottomWidth / scaleFactor), (int)Math.ceil(bottomHeight / scaleFactor)); } for (int i = 1; i < layers.length; i++) { scaleFactor = getScale(i); layers[i] = imageType.createImage((int)Math.ceil(bottomWidth / scaleFactor), (int)Math.ceil(bottomHeight / scaleFactor)); } }