How could I handle gray bitmap raw data? Could you help me please?



  • Dear guys,

    I am receiving gray bitmap raw data from device to *void value. Then I need to show bitmap data using label control.

    I will show you code.
    @
    typedef enum tagIBScanUImageFormat
    {
    IBSU_IMG_FORMAT_GRAY, ///< Gray scale image
    IBSU_IMG_FORMAT_RGB24, ///< 24 bit RGB color image
    IBSU_IMG_FORMAT_RGB32, ///< True color RGB image
    IBSU_IMG_FORMAT_UNKNOWN ///< Format not set or unknown
    }
    IBSU_ImageFormat;

    /// Container to hold image data together with meta information.
    typedef struct tagIBSU_ImageData
    {
    void* Buffer; ///< Pointer to image buffer
    DWORD Width; ///< Image horizontal size
    DWORD Height; ///< Image vertical size
    double ResolutionX; ///< Horizontal image resolution (in PPI)
    double ResolutionY; ///< Vertical image resolution (in PPI)
    double FrameTime; ///< Image acquisition time (in seconds)\n
    ///< This value contains the time taken for acquisition
    ///< from device (excluding processing time).
    int Pitch; ///< Image line pitch (in Bytes).\n
    /// Positive values indicate top down line order,
    /// Negative values mean bottom up line order
    BYTE BitsPerPixel; ///< Number of Bits per pixel
    IBSU_ImageFormat Format; ///< Image color format
    BOOL IsFinal; ///< Marks image as finally processed\n
    /// A value of "FALSE" disqualifies image for further processing.
    /// (e.g. interim or preprocessed result images)
    // int PollingTimeForGetImag; /// For Polling time for getting image

    }
    IBSU_ImageData;
    @
    Above is struct for image data from device.
    And
    @
    void* Buffer;
    @
    is buffer for raw data from device.

    Then, I used c++ library to get raw data from device.

    So, how could I see this gray bitmap raw data at label control?

    I used "StretchDIBits" function in my other MFC appliction.
    Is there any function like a "StretchDIBits" function?

    Thanks,



  • It's easy. supposing that each pixel has a 24 bits depth, then you can do:

    @
    pixmap = QPixmap::fromImage(QImage((const uchar *) IBSU_ImageData.Buffer,
    IBSU_ImageData.ResolutionX,
    IBSU_ImageData.ResolutionX,
    QImage::Format_RGB888));

    label.setPixmap(pixmap);
    @



  • Thank you!!


Log in to reply
 

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