try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
Iterator it = ImageIO.getImageWritersByMIMEType("image/jpeg");
ImageWriter iw = it.hasNext() ? (ImageWriter) it.next() : null;
iw.setOutput(ios);
iw.write(new IIOImage(bi, null, null)); // BufferedImage bi
iw.dispose();
OutputStream os = socket.getOutputStream(); // Socket socket
baos.writeTo(os);
} catch (IOException ex) {
}
參考:
ImageWriter (Java 2 Platform SE 5.0)
JavaWorld@TW Java論壇 - Graphics2D產生的文字字型要如何改變?
MyChat 數位男女 - 請問在jScrollPane的圖片另存新檔的程式碼錯誤?
全站熱搜