我正在使用QTJambi,我需要将 BufferedImage 转换为 QPixmap 。
答案 0 :(得分:0)
我找到了一个解决方案:
public QPixmap convertBufferedImageToQPixmap(BufferedImage img){
QPixmap result = new QPixmap(new QSize(img.getWidth(),img.getHeight()));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
boolean foundWriter = ImageIO.write(img, "jpg", baos);
result.loadFromData(baos.toByteArray());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}