Guest User

Untitled

a guest
Jun 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. // shrinking an image size on any magnitude
  2. BufferedImage image = changeImageWidth(image, image.getWidth() / 2);
  3. ConvolveOp gaussianFilter = getGaussianBlurFilter(BLUR_SIZE, true);
  4. image = gaussianFilter.filter(image, null);
  5. gaussianFilter = getGaussianBlurFilter(BLUR_SIZE, false);
  6. image = gaussianFilter.filter(image, null);
  7. ColorTintFilter colorMixFilter = new ColorTintFilter(Color.WHITE, 0.4f);
  8. image = colorMixFilter.filter(image, null);
  9. //yet another image operations....
  10. // now bring it back!!!
  11. image = changeImageWidth(image, image.getWidth() * 2);
  12.  
  13.  
  14.  
  15. public static BufferedImage changeImageWidth(BufferedImage image, int width) {
  16. float ratio = (float) image.getWidth() / (float) image.getHeight();
  17. int height = (int) (width / ratio);
  18.  
  19. BufferedImage temp = new BufferedImage(width, height,
  20. image.getType());
  21. Graphics2D g2 = temp.createGraphics();
  22. g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
  23. RenderingHints.VALUE_INTERPOLATION_BILINEAR);
  24. g2.drawImage(image, 0, 0, temp.getWidth(), temp.getHeight(), null);
  25. g2.dispose();
  26.  
  27. return temp;
  28. }
Add Comment
Please, Sign In to add comment