public static BufferedImage obrot(BufferedImage in,int param) {
        BufferedImage out = new BufferedImage(in.getWidth(),in.getHeight(),in.getType());
        int width,height;
        width = out.getWidth();
        height = out.getHeight();
        int r,g,b;
        
        double x,y;
        double minX,maxX,minY,maxY;
        minX=minY=0;
        maxX=width-1;
        maxY=height-1;
        
        for (int i = 1; i < width-1; i++) {
            for (int j = 1; j < height-1; j++) {
                // Tu wypełnij właściwym kodem   
                x = Math.cos(Math.toRadians(param))*i-Math.sin(Math.toRadians(param))*j;
                y = Math.sin(Math.toRadians(param))*i+Math.cos(Math.toRadians(param))*j;
                
                if(x<minX) minX=x;
                if(x>maxX) maxX=x;
                if(y<minY) minY=y;
                if(y>maxY) maxY=y;
            }
        }
        
        System.out.println("X od "+minX+" do "+maxX);
        System.out.println("Y od "+minY+" do "+maxY);
        
        int wymiarX = (int)maxX+Math.abs((int)minX)+10; //zaokraglenia
        int wymiarY = (int)maxY+Math.abs((int)minY)+10; //zaokraglenia
        
        System.out.println("Wymiar obrazka :"+wymiarX+"x"+wymiarY);
        
        out = new BufferedImage(wymiarX,wymiarY,in.getType());
        int roznicaX = wymiarX - in.getWidth()+5;
        int roznicaY = wymiarY - in.getHeight()+5;
        
        for (int i = 1; i < width-1; i++) {
            for (int j = 1; j < height-1; j++) {
                // Tu wypełnij właściwym kodem   
                x = Math.cos(Math.toRadians(param))*i-Math.sin(Math.toRadians(param))*j;
                y = Math.sin(Math.toRadians(param))*i+Math.cos(Math.toRadians(param))*j;
                
                out.setRGB(Math.abs((int)(x)),Math.abs((int)(y)),in.getRGB(i, j));
            }
        }
        return out;
    }