[SOLVED] QImage using pointer to valarray ?



  • Hello,

    I'm new to this Forum. In the context of loading and visualising scientific images in FITS files, as quick as possible, I am using valarray, used by the CCFITSIO library. The latter reads raw scientific images in these objects. From the QImage doc, and this specific overload :

    • QImage(uchar * data, int width, int height, Format format)

    I understand that QImage could take a pointer to some data in a buffer.

    Is there any way to get a pointer to, say, valarray<float> myValArray ? And give it to QImage, without making any intermediate copies ?

    At the moment, the compiler (VS2013) does not allow me to use
    &myValArray[0] in QImage. I assume this comes from my misunderstanding of either QImage and valArray objects.

    Thanks for your help.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    QImage doesn't support float AFAIK. You should rather write a QImageReader subclass that decodes your image data in something supported by QImage



  • @SGaist
    Thank you for your reply.

    Then, what should be the type of the array whose pointer can be sent to QImage(uchar *data,...) ?

    Thanks



  • Does QImage(uchar* data) means necessarily that i can only send char array, with numbers spanning from 0 to 255 ?

    Are there other Qt classes that support other types of image arrays that are to be displayed ?


  • Lifetime Qt Champion

    It can be something else as long as there's a reader that can translate it in a format QImage understands.

    QImage is the base image class, what can be done is to use OpenCV to convert your image data into something QImage can handle



  • @SGaist
    Ok, I just tried to rescaled my image array within an intensity between 0 to 255 and cast a uchar*, it's working now.

    Thanks


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.