Created
October 20, 2010 13:31
-
-
Save undetected1/636404 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// shrinking an image size on any magnitude | |
BufferedImage image = changeImageWidth(image, image.getWidth() / 2); | |
ConvolveOp gaussianFilter = getGaussianBlurFilter(BLUR_SIZE, true); | |
image = gaussianFilter.filter(image, null); | |
gaussianFilter = getGaussianBlurFilter(BLUR_SIZE, false); | |
image = gaussianFilter.filter(image, null); | |
ColorTintFilter colorMixFilter = new ColorTintFilter(Color.WHITE, 0.4f); | |
image = colorMixFilter.filter(image, null); | |
//yet another image operations.... | |
// now bring it back!!! | |
image = changeImageWidth(image, image.getWidth() * 2); | |
public static BufferedImage changeImageWidth(BufferedImage image, int width) { | |
float ratio = (float) image.getWidth() / (float) image.getHeight(); | |
int height = (int) (width / ratio); | |
BufferedImage temp = new BufferedImage(width, height, | |
image.getType()); | |
Graphics2D g2 = temp.createGraphics(); | |
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, | |
RenderingHints.VALUE_INTERPOLATION_BILINEAR); | |
g2.drawImage(image, 0, 0, temp.getWidth(), temp.getHeight(), null); | |
g2.dispose(); | |
return temp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment