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. FromImage not Keeping Indexed Color Table

FromImage not Keeping Indexed Color Table

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 448 Views
  • 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.
  • qt27Q Offline
    qt27Q Offline
    qt27
    wrote on last edited by VRonin
    #1

    I am dealing with large 16-bit grayscale images. They are displayed at 8-bit where I have to be able to adjust contrast/brightness, add text labels, some basic forms like rectangles/lines/etc. To keep the memory footprint low I want to keep them as 8-bit rather than RGBA. However, when I do fromImage, my 8-bit data automatically seems to be converted to RGBA (judging by how much memory is being used up). How can I keep this as 8-bit data (or even 16-bit while allowing contrast/brightness adjustment)? Here is my code:

    QImage image(data, width, height, lineWidth, QImage::Format_Indexed8);
    QVector<QRgb> grayscaleTable;
    for (int i = 0; i < 256; i++)	grayscaleTable.push_back(qRgb(i, i, i));
    image.setColorTable(grayscaleTable);
    pixmap = scene->addPixmap(pixmap);
    setScene(scene);
    
    1 Reply Last reply
    0
    • m.sueM Offline
      m.sueM Offline
      m.sue
      wrote on last edited by
      #2

      Hi,
      QImages are for image processing: working with color tables, access to individual pixels etc. QPixmap on the other hand, is more for fast blitting to a screen. So, it uses the default color depth of your screen, which will probably be 32-bit.
      I would say: there is no way to use QPixmap with 16-bit color depth when you have a 32-bit screen.
      -Michael.

      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