Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Matrix operations
Forum Updated to NodeBB v4.3 + New Features

Matrix operations

Scheduled Pinned Locked Moved Solved General and Desktop
qmatrixqmatrix4x4qgenericmatrix
21 Posts 4 Posters 10.7k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • VRoninV VRonin

    QImage myMatrix(8,8,QImage::Format_Mono) will create a container of 8 by 8 bits (not bytes).

    • myMatrix.fill(0); to turn everything off.
    • Point: myMatrix.setPixel(0,0,1);
    • Line(1): for(int i=0;i<myMatrix.width();++i) myMatrix.setPixel(0,i,1);
    • Column(1): for(int i=0;i<myMatrix.height();++i) myMatrix.setPixel(i,0,1);
    • Border: for(int i=0;i<myMatrix.width();++i) {myMatrix.setPixel(0,i,1); myMatrix.setPixel(myMatrix.height()-1,i,1);} for(int i=0;i<myMatrix.height();++i) {myMatrix.setPixel(i,0,1); myMatrix.setPixel(i,myMatrix.width()-1,1);}
    • Column Shift(1): myMatrix=myMatrix.transformed(QTransform().translate(1,0));
    • Column Shift(-1): myMatrix=myMatrix.transformed(QTransform().translate(-1,0));
    • Line Shift(1): myMatrix=myMatrix.transformed(QTransform().translate(0,1));
    • Line Shift(-1): myMatrix=myMatrix.transformed(QTransform().translate(0,-1));
    • Rotate(1): myMatrix=myMatrix.transformed(QTransform().rotate(270));
    • Rotate(-1): myMatrix=myMatrix.transformed(QTransform().rotate(90));
    • Invert: myMatrix.invertPixels();
    D Offline
    D Offline
    doubitchou
    wrote on last edited by doubitchou
    #21

    @VRonin

    Great answer !, especially to be adapted to my needs. Anyway, I think I should try with Format_Indexed8 instead as I need to store the color values which requires more than a single bit:

    0 : off
    1 : Green
    2 : Red
    3 : Orange

    (Merci pour cette réponse)

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved