在Android中使用缓冲图像

我正尝试使用https://github.com/fadihatem/AppIconsGenerator/blob/master/src/AppIconsGenerator.java中的以下代码段在android平台上创建android启动器图标

private static void createAndroidIcons(final String path,final String fileName) throws IOException {
        List<Point> launchIcons= Arrays.asList(new Point(1024,500),new Point(180,120));
        List<Integer> appIcons=Arrays.asList(48,72,96,144,512);
        List<String> appIconsFolders=Arrays.asList("drawable-mdpi/","drawable-hdpi/","drawable-xhdpi/","drawable-xxhdpi/",".");
        File androidDir=new File(path+"Android/");
        androidDir.mkdir();

        BufferedImage originalImage = ImageIO.read(new File(path+fileName+".png"));
        int type = originalImage.getType() == 0? BufferedImage.TYPE_INT_ARGB : originalImage.getType();

        for(int i=0;i<appIcons.size();i++){
            File appIconsDir=new File(androidDir.getabsolutePath()+"/"+appIconsFolders.get(i));
            appIconsDir.mkdir();
            BufferedImage resizeImagePng = resizeImage(originalImage,type,appIcons.get(i),appIcons.get(i));
            if(!appIconsFolders.get(i).equals(".")){
                ImageIO.write(resizeImagePng,"png",new File(androidDir.getabsolutePath()+"/"+appIconsFolders.get(i)+"ic_launcher.png"));
            }else{
                ImageIO.write(resizeImagePng,new File(androidDir.getabsolutePath()+"/"+"ic_launcher-web.png"));
            }
        };

        for(Point p : launchIcons){
            BufferedImage resizeImagePng = resizeImage(originalImage,p.x,p.y);
            ImageIO.write(resizeImagePng,new File(androidDir.getabsolutePath()+"/"+fileName+"-"+p.x+"-"+p.y+".png"));
        };
    }

我知道缓冲图像类文件是AWT库的一部分,并不存在于android中。我需要使用android的Bitmap类来相应地更改我的代码,或者是否有其他方法可以做到这一点?

wuxiuhao 回答:在Android中使用缓冲图像

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2768924.html

大家都在问