QImage to Image

Hello,

is there a way to turn a QImage into an Image ?

Kind Regards
Thomas

Comments

  • HI TTR572

    Assuming your are trying to save a QImage data into a image file, you can simply use the save function.

    #image is QImage
    image.save("file_path/file_name.png")
    

    If you like to show the image in you widget, you can use QLabel widget to hold thoes Pixels, and add the QLabel into you widget.

    #image is QImage
    imageLabel = RBA::QLabel.new()
    imageLabel.setPixmap(QPixmap::fromImage(image))
    #this turns Qimage into Pixel data
    
  • Hi RawrRanger,

    thanks for your suggestion. What I am trying to do is to transmit images from another process to KLayout via Shared Memory. I am asking the question, because I haven't found a method of the Image Class to read the image data from a byte stream, while with QImage, one can do such a thing. So I was wondering if there was a way to turn a QImage into an Image (of the Image Class), because the cell view's insert_image method only takes an instance of the Image Class as an input, but not a QImage.

    Kind Regards
    Thomas

  • Hi @TTR572,

    No, right now there is only the temp file approach or using (slow) pixelwise transfer.

    If you want creation from a bytestring or QImage or PixelBuffer (without Qt) raise a ticket on GitHub.

    Matthias

  • Hi Matthias,
    thanks for your feedback. I will continue to look for solutions.

    Kind Regards
    Thomas

  • I have created this PR to fix your problem: https://github.com/KLayout/klayout/pull/1436

    Matthias

Sign In or Register to comment.