public static BufferedImage compress(BMPcontainer bmPcontainer) {
        int newWidth;
        int newHeight;

        double ar = bmPcontainer.getAspectRatio();
        if (ar > 1) {
            newWidth = 256;
            newHeight = (int) (newWidth / ar);
        } else {
            newHeight = 256;
            newWidth = (int) (newHeight * ar);
        }

        BufferedImage result = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_RGB);

        double widthStep = bmPcontainer.getWidth() / newWidth;
        double heightStep = bmPcontainer.getHeight() / newHeight;
        int sourceX = 0;
        int sourceY = 0;

        for (int y = 0; y < newHeight; y++) {
            for (int x = 0; x < newWidth; x++) {
                result.setRGB(x, y, bmPcontainer.get(sourceX, sourceY).getRGB());
                sourceX += widthStep;
            }
            sourceY += heightStep;
            sourceX = 0;
        }

        return result;
    }