⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 图片.txt

📁 收集到的一些J2ME资料。。 包括图片的角度翻转。。A*算法和一些其他文章
💻 TXT
字号:
import java.awt.Image;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class DisposeIMG {
    public DisposeIMG() {
    }

    public static String getFixedBoundIcon(String filePath, int height,
            int width) {
        double Ratio = 0.0; // 缩放比例
        File F = new File(filePath);
        if (!F.isFile()) {
            return " is not image file error in getFixedBoundIcon!";
        }

        BufferedImage Bi = null;
        try {
            Bi = ImageIO.read(F);
        } catch (IOException ex1) {
            return "read error!";
        }
        if ((Bi.getHeight() > height) || (Bi.getWidth() > width)) {
            if (Bi.getHeight() > Bi.getWidth()) {
                Ratio = (new Integer(height)).doubleValue() / Bi.getHeight();
            } else {
                Ratio = (new Integer(width)).doubleValue() / Bi.getWidth();
            }
            File ThF = new File(filePath + "_" + height + "_" + width);

            Image Itemp = Bi.getScaledInstance(width, height,
                    BufferedImage.SCALE_SMOOTH);

            AffineTransformOp op = new AffineTransformOp(AffineTransform
                    .getScaleInstance(Ratio, Ratio), null);
            Itemp = op.filter(Bi, null);
            try {
                ImageIO.write((BufferedImage) Itemp, "jpg", ThF);
            } catch (Exception ex) {
                return "错误";
            }
        }
        return "修改成功";
    }

    public static void main(String[] atge) {
        System.out.println(DisposeIMG.getFixedBoundIcon("F:/20057.jpg", 166,
                132));
    }
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -