Java ByteBuffer Size chooseAppropriateTileSize(BufferedImage image)

Here you can find the source of chooseAppropriateTileSize(BufferedImage image)

Description

choose Appropriate Tile Size

License

Open Source License

Declaration

public static int chooseAppropriateTileSize(BufferedImage image) 

Method Source Code


//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.awt.Component;

import java.awt.image.BufferedImage;

public class Main {
    public static int chooseAppropriateTileSize(BufferedImage image) {
        int width = image.getWidth();
        int height = image.getHeight();
        int tileSize = (int) (Math.sqrt(Math.sqrt(width * height)) * 1.5);
        return tileSize;
    }/*from  w w w . jav  a  2s . c  om*/

    public static int chooseAppropriateTileSize(Component component) {
        int width = component.getWidth();
        int height = component.getHeight();

        if (width == 0)
            throw new IllegalStateException("Component width is 0");
        if (height == 0)
            throw new IllegalStateException("Component height is 0");

        int tileSize = (int) (Math.sqrt(Math.sqrt(width * height)) * 1.5);
        return tileSize;
    }
}

Related

  1. addToStringBuilder(StringBuilder sb, ByteBuffer buffer, int size)
  2. calcSize(ByteBuffer buffer)
  3. check(ByteBuffer buffer, int size)
  4. checkBounds(BufferedImage image, int xStart, int yStart, int width, int height)
  5. checkBufferSize(ByteBuffer buf, int elementSize)
  6. collidesWithImage(BufferedImage image, int x, int y, int width, int height, boolean pixelPerfect)
  7. convolve(final BufferedImage image, float[] elements, int theWidth, int theHeight)
  8. cover(BufferedImage source, File to, Image cover, int width, int height, int sourceTop, int sourceLeft, int sourceWidth, int sourceHeight)
  9. cutAndScaleToRoundSquare(BufferedImage src, int size, int radius)