public void resize(int w, int h) throws IOException { // SCALE_SMOOTH 的缩略算法 生成缩略图片的平滑度的 优先级比速度高 生成的图片质量比较好 但速度慢 BufferedImage image = new BufferedImage(w, h,BufferedImage.TYPE_INT_RGB ); image.
*/publicvoidresize(int w,int h,String toPic)throws IOException{// SCALE_SMOOTH 的缩略算法 生成缩略图片的平滑度的 优先级比速度高 生成的图片质量比较好 但速度慢BufferedImage image=newBufferedImage(w,h,BufferedImage.TYPE_INT_RGB);image.getGraphics().drawImage(img,0,0,w,h,null);// 绘制缩小后...
SCALE_AREA_AVERAGING 使用 Area Averaging 图像缩放算法。 SCALE_DEFAULT 使用默认的图像缩放算法。 SCALE_FAST 选择一种图像缩放算法,在这种缩放算法中,缩放速度比缩放平滑度具有更高的优先级。 SCALE_REPLICATE 使用 ReplicateScaleFilter 类中包含的图像缩放算法。 SCALE_SMOOTH 选择图像平滑度比缩放速度具有更高优先级...
2 然后加载到image里:int w=bi.getWidth(),h=bi.getHeight();//获取原图片的宽和高然后设置 画布的长和宽,这个画布也就是用来呈现图像的Image image=bi.getScaledInstance(w, h, BufferedImage.SCALE_SMOOTH);//BufferedImage.SCALE_SMOOTH为设置 画面平滑 ,有很多种啦~~~3 然后我们再新建一个BufferedImag...
tag.getGraphics().drawImage(img.getScaledInstance(newWidth, newHeight, Image.SCALE_SMOOTH), 0, 0, null); 3、压缩速度 测试36MB的bmp图片(8192*6144)压缩成(160*120)的jpg的5KB图片,只需要2-3秒的时间。批量处理100张(1027*768)的bmp图像,转换成(120*80)的jpg图片总共只需要17秒。
SCALE_SMOOTH), 0, 0, Color.white,null); 试过后,没有用,进一步查看JDK官方与图片相关的API,没有提到特别的注意事项。 (3)google、Stack Overflow 提到是JDK的bug,但是在oracle官网提到图片失真是JDK1.4的bug,但是1.6已结修复了,而项目中用到的是JDK1.7. (4)百度,关键词:Java 压缩 图片后 表面变成红色 ...
SCALE_SMOOTH); BufferedImage tag = new BufferedImage(lwidth, lheight, BufferedImage.TYPE_INT_RGB); Graphics g = tag.getGraphics(); g.drawImage(image, 0, 0, null); // 绘制缩小后的图 g.dispose(); src = image; } // 插入LOGO Graphics2D graph = source.createGraphics(); int x = (...
scale(String srcImageFile, String result, int height, int width, boolean bb) { try { double ratio = 0.0; // 缩放比例 File f = new File(srcImageFile); BufferedImage bi = ImageIO.read(f); Image itemp = bi.getScaledInstance(width, height, bi.SCALE_SMOOTH);//bi...
;public JPanel jp=new JPanel(){Image img=Toolkit.getDefaultToolkit().getImage(System.getProperty("user.dir")+"\\src\\imagetext\\111.gif");Image tempimg1=img.getScaledInstance(141,106,Image.SCALE_SMOOTH);Image temping2=img.getScaledInstance(70, 53, Image.SCALE_SMOOTH);public void paint(...
newWidth, Image.SCALE_SMOOTH); } // This code ensures that all the pixels in the image are loaded. Image temp = new ImageIcon(resizedImage).getImage(); // Create the buffered image. BufferedImage bufferedImage = new BufferedImage(temp.getWidth(null), ...