title: Convert Leptonica Pix Object to QPixmap ( or other image object )
body: <p>I'm using the Leptonica Library to process some pictures. After that I want to show them in my QT GUI. Leptonica is using their own format Pix for the images, while QT is using their own format QPixmap. At the moment the only way for me is to save the pictures after processing as a file ( like bmp ) and then load them again with a QT function call. Now I want to convert them in my code, so I dont need to take the detour with saving them on the filesystem. Any ideas how to do this?</p>
  
  <p>Best Regards</p>
  
  <p>// edit:</p>
  
  <p>Okay as already suggested I tried to convert the PIX* to a QImage.
  The PIX* is defined like this:</p>
  
  <p><a href="http://tpgit.github.com/Leptonica/pix_8h_source.html" rel="nofollow">http://tpgit.github.com/Leptonica/pix_8h_source.html</a></p>
  
  <pre><code>struct Pix
  {
    l_uint32             w;           /* width in pixels                   */
    l_uint32             h;           /* height in pixels                  */
    l_uint32             d;           /* depth in bits                     */
    l_uint32             wpl;         /* 32-bit words/line                 */
    l_uint32             refcount;    /* reference count (1 if no clones)  */
    l_int32              xres;        /* image res (ppi) in x direction    */
                                      /* (use 0 if unknown)                */
    l_int32              yres;        /* image res (ppi) in y direction    */
                                      /* (use 0 if unknown)                */
    l_int32              informat;    /* input file format, IFF_*          */
    char                *text;        /* text string associated with pix   */
    struct PixColormap  *colormap;    /* colormap (may be null)            */
    l_uint32            *data;        /* the image data                    */
  };
  </code></pre>
  
  <p>while QImage offers me a method like this:</p>
  
  <p><a href="http://developer.qt.nokia.com/doc/qt-4.8/qimage.html#QImage-7" rel="nofollow">http://developer.qt.nokia.com/doc/qt-4.8/qimage.html#QImage-7</a></p>
  
  <pre><code>QImage ( const uchar * data, 
      int width, 
      int height, 
      int bytesPerLine, 
      Format format )
  </code></pre>
  
  <p>I assume I cant just copy the data from the PIX to the QImage when calling the constructor. I guess I need to fill the QImage Pixel by Pixel, but actually I dont know how? Do I need to loop through all the coordinates? How do I regard the bit depth? Any ideas here?</p>