ITeye博客

robot.createScreenCapture(this.screenBounds);

xiaguangme · 2012-08-13 07:45 · 编程语言 · Markdown

Java code

import com.sun.image.codec.jpeg.*;

    public static byte[] getCompressedImageAWT(BufferedImage image) {
        byte[] imageData = null;
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(baos);
            encoder.encode(image);
            imageData = baos.toByteArray();
        } catch (IOException

 ex) {
            ex.printStackTrace();
        }
        return imageData;
    }


BufferedImage capturedImage = robot.createScreenCapture(this.screenBounds);

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。