中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

圖片縮放的Java類

2018-07-20    來源:open-open

容器云強(qiáng)勢上線!快速搭建集群,上萬Linux鏡像隨意使用
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;

import com.jhlabs.image.AbstractBufferedImageOp;

/**
 * Scales an image using the area-averaging algorithm, which can't be done with AffineTransformOp.
 */
public class MyScaleFilter extends AbstractBufferedImageOp {

    private int width;
    private int height;

    /**
     * Construct a ScaleFilter.
     */
    public MyScaleFilter() {
        this(32, 32);
    }

    /**
     * Construct a ScaleFilter.
     * @param width the width to scale to
     * @param height the height to scale to
     */
    public MyScaleFilter( int width, int height ) {
        this.width = width;
        this.height = height;
    }

    public BufferedImage filter( BufferedImage src, BufferedImage dst ) {
        if ( dst == null ) {
            ColorModel dstCM = src.getColorModel();
            dst = new BufferedImage(dstCM, 
                dstCM.createCompatibleWritableRaster( width, height ), 
                dstCM.isAlphaPremultiplied(), null);
        }

        Image scaleImage = src.getScaledInstance( width, height, Image.SCALE_SMOOTH );
        Graphics2D g = dst.createGraphics();
        g.drawImage( scaleImage, 0, 0, width, height, null );
        g.dispose();

        return dst;
    }

    public String toString() {
        return "Distort/Scale";
    }

}

標(biāo)簽: isp

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:java實(shí)現(xiàn)截屏程序

下一篇:利用注解將JDBC結(jié)果集轉(zhuǎn)成Java對象