Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static BufferedImage sclae2(BufferedImage img, int w2, int h2){
- int w1 = img.getWidth();
- int h1 = img.getHeight();
- BufferedImage output = new BufferedImage(w2, h2, BufferedImage.TYPE_INT_RGB);
- double x_ratio = (double)w1/w2;
- double y_ratio = (double)h1/h2;
- for(int i=0; i<w2; i++){
- for (int j = 0; j < h2; j++) {
- int rgb = img.getRGB((int)Math.floor(i*x_ratio), (int)Math.floor(j*y_ratio));
- output.setRGB(i, j, rgb);
- }
- }
- return output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement