001    /*
002    Copyright (c) 1996-2011, Damon Hart-Davis
003    All rights reserved.
004    
005    Redistribution and use in source and binary forms, with or without
006    modification, are permitted provided that the following conditions are
007    met:
008    
009      * Redistributions of source code must retain the above copyright
010        notice, this list of conditions and the following disclaimer.
011    
012      * Redistributions in binary form must reproduce the above copyright
013        notice, this list of conditions and the following disclaimer in the
014        documentation and/or other materials provided with the
015        distribution.
016    
017    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
018    IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
019    TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
020    PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
021    OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
022    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
023    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
024    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
025    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
026    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
027    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028    */
029    package org.hd.d.pg2k.svrCore.mediahandler;
030    
031    import org.hd.d.pg2k.svrCore.MIME.AbstractImageHandler;
032    import org.hd.d.pg2k.svrCore.MIME.ExhibitMIME;
033    
034    /**Basic handler for BMP file (MIME type image/bmp).
035     * Mainly relies on JAI/IIO support for encode/decode.
036     */
037    public final class bmp extends AbstractImageHandler
038        {
039        /**Get internal type of ExhibitMIME type; never null. */
040        public ExhibitMIME.ExhibitTypeParameters getExhibitType()
041            { return(ExhibitMIME.getParamsByType(ExhibitMIME.ET_BMP)); }
042    
043        /**Returns true if this can make thumbnail/sample exhibits for this type.
044         * Returns true because we should be able to make BMP thumbnails
045         * with the built-in imageIO support from JDK1.5 onwards.
046         */
047        @Override public boolean canMakeThumbnails()
048            { return(true); }
049    
050        /**Gather together thumbnail parameters. */
051        private static final AbstractImageHandler.ThumbnailParams thumbnailParams =
052            new ThumbnailParams(4, // Assume 32-bit in-memory RGB representation.
053                1,
054                100,
055                8, // 8 bits per pixel should be fine for a thumbnail.
056                8, // We ought to be able to force an 8-bit format at least...
057                256);
058    
059        /**Get ThumbnailParameters for BMP handler. */
060        @Override public AbstractImageHandler.ThumbnailParams getThumbnailParams()
061            { return(thumbnailParams); }
062    
063        // Inherit javadoc.
064        @Override protected int _reduceColoursQualityThreshold() { return(24); }
065        }