Example #1
0
bool
ImageWidget :: setImage(QImage& image, const cv::Mat3b& im)
{
    bool geometryUpdated = false;

    if (image.isNull()
            || image.width() != im.cols
            || image.height() != im.rows)
    {
        image = QImage(im.cols, im.rows, QImage::Format_RGB32);
        geometryUpdated = true;
    }

    for (int r = 0; r < im.rows; ++r)
    {
        QRgb* ptr = (QRgb*) image.scanLine(r);
        const uchar* cv_ptr = im.ptr(r);
        for (int i = 0; i < im.cols; ++i)
        {
            int rgb = 0xff << 24;
            rgb |= (*cv_ptr++);
            rgb |= ((*cv_ptr++) << 8);
            rgb |= ((*cv_ptr++) << 16);
            *ptr++ = rgb;
        }
    }

    return geometryUpdated;
}
Example #2
0
void ImageWidget :: setImage(const cv::Mat3b& im)
{
    if (m_image.width() != im.cols
      || m_image.height() != im.rows)
    m_image = QImage(im.cols, im.rows, QImage::Format_RGB32);

  for (int r = 0; r < im.rows; ++r)
  {
    QRgb* ptr = (QRgb*) m_image.scanLine(r);
    const uchar* cv_ptr = im.ptr(r);
    for (int i = 0; i < im.cols; ++i)
    {
      int rgb = 0xff << 24;
      rgb |= (*cv_ptr++);
      rgb |= ((*cv_ptr++) << 8);
      rgb |= ((*cv_ptr++) << 16);
      *ptr++ = rgb;
    }
  }
  update();
}