tags:

views:

327

answers:

2

I am trying to convert java qt QImage to BufferedImage using the following code, but it does't work

QImage image = map.toImage();

byte buf[] = image.copyOfBytes();

    InputStream in = new ByteArrayInputStream(buf);
    try {
        BufferedImage img = javax.imageio.ImageIO.read(in);
              File file = new File("newimage.bmp");
            ImageIO.write(img, "bmp", file);

    } catch (Exception e) {
    }
A: 

hi, have you found the answer to this problem ? this interest me too

i would like to display a QImage on a AWT Canvas

A: 

http://wiki.qtjambi.info/Converting_java.awt.Image_to_QImage Method on the link above does it the other way around. It converts an Image to a QImage, I'm guessing it shouldn't be too hard to reverse the logic and do it the other way around.

I will however warn you in advance that it isn't exactly fast.. I'll update the page if I find a faster way.