byte[]图片修改大小

private byte[] fixPic(byte[] bts){
try {

Image img=ImageIO.read(new ByteArrayInputStream(bts));
BufferedImage tag = new BufferedImage((int) 800, (int) 600, BufferedImage.TYPE_INT_RGB);
tag.getGraphics().drawImage(img.getScaledInstance(800, 600, Image.SCALE_SMOOTH), 0, 0, null);
ByteArrayOutputStream out=new ByteArrayOutputStream();
JPEGImageEncoder encoder =JPEGCodec.createJPEGEncoder(out);
encoder.encode(tag);
byte[] by= out.toByteArray();
out.close();
return by;
} catch (IOException e) {

e.printStackTrace();

return null;
}

}

你可能感兴趣的:(byte[])