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. Displaying an image on Rgb channel
Forum Updated to NodeBB v4.3 + New Features

Displaying an image on Rgb channel

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.5k Views 1 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.
  • T Offline
    T Offline
    TryDying
    wrote on last edited by
    #1

    Hi everybody ^^ I've been working on a project lately,dealing with image compression.for a primar task,i have to develop an application that shows and image,then display it on the red,green and blue channels.for now I managed to display the image itself seccessfuly,but i couldn't extract it on any of the Rgb channels.here's a piece of my code where i'm working on the red channel:

    @
    QImage im;
    im.load(//path of my image);
    QVector <QRgb> table=im.colorTable();
    for(int i=0;table.size();i++) {
    table[i]=qRed(table[i]);
    }
    im.setColorTable(table);
    QPixmap redvue;
    redvue= QPixmap::fromImage(im);
    QGraphicsScene *scene=new QGraphicsScene(m_ui->GraphicsScene);
    m_ui->GraphicsScene->setScene(scene);
    scene->addPixmap(redvue);
    @

    [EDIT: code formatting, please wrap in @-tags, Volker]

    1 Reply Last reply
    0
    • BilbonSacquetB Offline
      BilbonSacquetB Offline
      BilbonSacquet
      wrote on last edited by
      #2

      The problem is that you have probably an image in true color without color palette.

      To get the color, in such a case:

      @
      QImage im(//the path);

      QVector c[im.width()][im.height];

      for (int i = 0; i<im.width(); i++)
      for (int j=0; j<im.height(); j++)
      c[i][j] = qRed(im.pixel());

      ...
      @

      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