List of utility methods to do ByteBuffer Size
Boolean | needsThumbnail(BufferedImage image, int newSize) Check if an image should is large enough to warrant creation of a thumbnail. int width = image.getWidth(); int height = image.getHeight(); return newSize < width && newSize < height; |
BufferedImage | newArgbBufferedImage(int width, int height) Creates a new ARGB BufferedImage of the given width and height. return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); |
boolean | overlapsPoints(BufferedImage inImage, int inX, int inY, int inWidth, int inHeight, Color inTextColour) Tests whether there are any dark pixels in the image within the specified x,y rectangle final int BRIGHTNESS_LIMIT = 80; final int textRGB = inTextColour.getRGB(); final int textLow = textRGB & 255; final int textMid = (textRGB >> 8) & 255; final int textHigh = (textRGB >> 16) & 255; try { for (int x = 0; x < inWidth; x++) { for (int y = 0; y < inHeight; y++) { ... |
ByteBuffer | pack(List Utility method to pack bytes into a byte buffer from a list of ByteBuffers ByteBuffer result = ByteBuffer.allocate(2 + size); result.putShort((short) elements); for (ByteBuffer bb : buffers) { result.putShort((short) bb.remaining()); result.put(bb.duplicate()); return (ByteBuffer) result.flip(); |
BufferedImage | rescaleImage(BufferedImage img, int targetWidth, int targetHeight, Object hint) Convenience method that returns a scaled instance of the provided BufferedImage . if (img == null) throw new NullPointerException("Invalid (null) image specified"); BufferedImage tmp = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = tmp.createGraphics(); if (hint != null) g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint); g2.drawImage(img, 0, 0, targetWidth, targetHeight, null); g2.dispose(); ... |
ByteBuffer | rightSize(ByteBuffer in) right Size if (wrapsFullArray(in)) { return in; return ByteBuffer.wrap(byteBufferToByteArray(in)); |
boolean | sameSize(BufferedImage im1, BufferedImage im2) Return true if image has the same size return (im1.getWidth() == im2.getWidth()) && (im1.getHeight() == im2.getHeight());
|
void | scanForDuplicates(BufferedImage leftImage, BufferedImage[] images, int i, int[] order, int width, int height) scan For Duplicates for (int j = i + 1; j < images.length; j++) { BufferedImage right = images[j]; if (right != null) { if (isDataEqual(leftImage, right, width, height)) { order[j] = i; |
int | sizeOfBytes(ByteBuffer bytes) size Of Bytes return 2 + bytes.remaining();
|
int | sizeOfBytesMap(Map size Of Bytes Map int size = 2; for (Map.Entry<String, ByteBuffer> entry : m.entrySet()) { size += sizeOfString(entry.getKey()); size += sizeOfBytes(entry.getValue()); return size; |