Skip to content
QtWS25 Last Chance
  • Creating Widgets for QtCreator

    Unsolved Qt Creator and other tools matrix contribution library
    2
    0 Votes
    2 Posts
    186 Views
    jsulmJ
    If you want to contribute to Qt you should start here: https://wiki.qt.io/Qt_Contribution_Guidelines
  • Contert int matrix to QPixmap

    Unsolved General and Desktop matrix qpixmap scene
    2
    0 Votes
    2 Posts
    1k Views
    ?
    Hi! The way to convert your matrix to a QPixmap is to convert it to QImage first (e.g. using void QImage::setPixel(const QPoint &position, uint index_or_rgb)) and then convert the QImage to a QPixmap (using [static] QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags = Qt::AutoColor)).
  • Convert QImage into binary Matrix

    Unsolved General and Desktop qimage matrix convert
    11
    0 Votes
    11 Posts
    6k Views
    VRoninV
    slightly more refined solution using the fact that QImage uses "a matrix" internally QDataStream outStream(&outputFile); outStream << image.height()<< image.width(); /* You need this to recover the image size, if not needed remove*/ QImage testImage= image.convertToFormat(QImage::Format_Mono,Qt::MonoOnly); /* 1 bit= 1 pixel*/ testImage.invertPixels(); /* black is 1 and white is 0 normally, you need the opposite so invert*/ const int bytesInWidth = testImage.width()/8 + (testImage.width()%8>0 ? 1:0); /*This is image.width()/8 rounded up */ for(int i=0;i<testImage.height();++i) outStream.writeRawData((const char*)(testImage.constScanLine(i)),bytesInWidth);