title: How to use a color LUT in Qt QImage
body: <p>I have some legacy code that was writing to a NITF file to display some images. In the legacy code, it appears as if there was a LUT being used, and there was a section of code that wrote out a row at a time to the NITF file , and the values of that row were calculated like so:</p>
  
  <pre><code>// convert RGB to LUT values
  unsigned char *lutData = new unsigned char[numBytes/3];
  for (unsigned j = 0 ; j &lt; numBytes/3 ; j++)
      lutData[j] = (unsigned char) stuff;
  </code></pre>
  
  <p>Where data was my original array of unsigned chars.</p>
  
  <p>So now I am trying to take that data array and output it into a QImage in my GUI.</p>
  
  <p>It would seem to me in the NITF, there was a block of LUT data that was "rows x cols" in size, right? So I created an array of that lut data:</p>
  
  <pre><code>unsigned char *lutData = new unsigned char[imwidth * imheight];
  QImage *qi = new QImage(imwidth,imheight, QImage::Format_Indexed8);
  for (int i = 0 ; i &lt; imheight ; i++)
  {
               #pragma omp parallel for
                for (int j = 0 ; j &lt; imwidth ; j++)
                {
                       lutData[i*imwidth + j] = stuff;
                }
  }
  </code></pre>
  
  <p>and then I tried to populate the qimage like this:</p>
  
  <pre><code>   for (int i = 0 ; i &lt; imheight ; i++)
     {
                  #pragma omp parallel for
                   for (int j = 0 ; j &lt; imwidth ; j++)
                   {
                       qi-&gt;setPixel(j,i,qRgb(lutData[i*imwidth + j],lutData[i*imwidth + j],lutData[i*imwidth + j]));
                  }
     }
  </code></pre>
  
  <p>However, this seems to more or less just give me a grayscale image, instead of my actual data.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Thanks!</p>