private static void adjustQualityFromImage(Map<String, Float> pFormatQuality, BufferedImage pImage) {
        // NOTE: The values are all made-up. May need tuning.

        // If pImage.getColorModel() instanceof IndexColorModel
        //    JPEG qs*=0.6
        //    If NOT binary or 2 color index
        //        WBMP qs*=0.5
        // Else
        //    GIF qs*=0.02
        //    PNG qs*=0.9 // JPEG is smaller/faster
        if (pImage.getColorModel() instanceof IndexColorModel) {
            adjustQuality(pFormatQuality, FORMAT_JPEG, 0.6f);

            if (pImage.getType() != BufferedImage.TYPE_BYTE_BINARY ||  ((IndexColorModel) pImage.getColorModel()).getMapSize() != 2) {
                adjustQuality(pFormatQuality, FORMAT_WBMP, 0.5f);
            }
        }
        else {
            adjustQuality(pFormatQuality, FORMAT_GIF, 0.01f);
            adjustQuality(pFormatQuality, FORMAT_PNG, 0.99f); // JPEG is smaller/faster
        }

        // If pImage.getColorModel().hasTransparentPixels()
        //    JPEG qs*=0.05
        //    WBMP qs*=0.05
        //    If NOT transparency == BITMASK
        //        GIF qs*=0.8
        if (ImageUtil.hasTransparentPixels(pImage, true)) {
            adjustQuality(pFormatQuality, FORMAT_JPEG, 0.009f);
            adjustQuality(pFormatQuality, FORMAT_WBMP, 0.009f);

            if (pImage.getColorModel().getTransparency() != Transparency.BITMASK) {
                adjustQuality(pFormatQuality, FORMAT_GIF, 0.8f);
            }
        }
    }
private static void adjustQualityFromImage ( Map < String , Float > pFormatQuality , BufferedImage pImage ) { if ( pImage . getColorModel ( ) instanceof IndexColorModel ) { adjustQuality ( pFormatQuality , FORMAT_JPEG , 0.6f ) ; if ( pImage . getType ( ) != BufferedImage . TYPE_BYTE_BINARY || ( ( IndexColorModel ) pImage . getColorModel ( ) ) . getMapSize ( ) != 2 ) { adjustQuality ( pFormatQuality , FORMAT_WBMP , 0.5f ) ; } } else { adjustQuality ( pFormatQuality , FORMAT_GIF , 0.01f ) ; adjustQuality ( pFormatQuality , FORMAT_PNG , 0.99f ) ; } if ( ImageUtil . hasTransparentPixels ( pImage , true ) ) { adjustQuality ( pFormatQuality , FORMAT_JPEG , 0.009f ) ; adjustQuality ( pFormatQuality , FORMAT_WBMP , 0.009f ) ; if ( pImage . getColorModel ( ) . getTransparency ( ) != Transparency . BITMASK ) { adjustQuality ( pFormatQuality , FORMAT_GIF , 0.8f ) ; } } }
Adjusts source quality settings from image properties.

@param pFormatQuality the format to quality mapping
@param pImage the image