I am using QTJambi and I need to convert BufferedImage into QPixmap.
Asked
Active
Viewed 73 times
1 Answers
0
I have found a solution:
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;
}

kahonmlg
- 3,839
- 3
- 17
- 21