Java - HalfFlipH / HalfFlipW


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  1. public BufferedImage halfFlipW(BufferedImage bi)
  2. {
  3. int width = bi.getWidth();
  4. int height = bi.getHeight();
  5.  
  6. BufferedImage biFlip = new BufferedImage(width, height, bi.getType());
  7.  
  8. for(int i=0; i<width; i++)
  9. for(int j=0; j<height/2; j++)
  10. {
  11. biFlip.setRGB(i, j, bi.getRGB(i, j));
  12. biFlip.setRGB(i, (height-1)-j, bi.getRGB(i, j));
  13. }
  14.  
  15. return biFlip;
  16. }
  17.  
  18.  
  19. public BufferedImage halfFlipH(BufferedImage bi)
  20. {
  21. int width = bi.getWidth();
  22. int height = bi.getHeight();
  23.  
  24. BufferedImage biFlip = new BufferedImage(width, height, bi.getType());
  25.  
  26. for(int i=0; i<width/2; i++)
  27. for(int j=0; j<height; j++)
  28. {
  29. biFlip.setRGB(i, j, bi.getRGB(i, j));
  30. biFlip.setRGB((width-1)-i, j, bi.getRGB(i, j));
  31. }
  32.  
  33. return biFlip;
  34. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.