Java Utililty Methods ByteBuffer Size

List of utility methods to do ByteBuffer Size

Description

The list of methods to do ByteBuffer Size are organized into topic(s).

Method

BooleanneedsThumbnail(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;
BufferedImagenewArgbBufferedImage(int width, int height)
Creates a new ARGB BufferedImage of the given width and height.
return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
booleanoverlapsPoints(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++) {
...
ByteBufferpack(List buffers, int elements, int size)
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();
BufferedImagerescaleImage(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();
...
ByteBufferrightSize(ByteBuffer in)
right Size
if (wrapsFullArray(in)) {
    return in;
return ByteBuffer.wrap(byteBufferToByteArray(in));
booleansameSize(BufferedImage im1, BufferedImage im2)
Return true if image has the same size
return (im1.getWidth() == im2.getWidth()) && (im1.getHeight() == im2.getHeight());
voidscanForDuplicates(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;
intsizeOfBytes(ByteBuffer bytes)
size Of Bytes
return 2 + bytes.remaining();
intsizeOfBytesMap(Map m)
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;