I had a program i originally wrote in C#, but I need it to run on linux now. So I've been porting it to c++ to use the QT GUI. It's almost done say for 1 thing. I have a few biometeric libraries (fingerprint, palm, and facial) that are used for authentication.

I have those 3 working for the most part. One thing I do in the c# version is show the captured image from the biometeric readers. Problem is I really suck and Image processing and converting formats. Both the Palm and Fingerprint scanners return a raw 8bpp image (no headers). Where as the Facial recognition library is a Jpeg format.

In my c# version I convert the 8bpp images to jpegs using this function:
Qt Code:
  1. public byte[] CreateRawJpegFrom8BPP(byte[] bytes, int width, int height)
  2. {
  3. byte[] rgbBytes = new byte[bytes.Length * 3];
  4.  
  5. for (int i = 0; i <= bytes.Length - 1; i++)
  6. {
  7. rgbBytes[(i * 3)] = bytes[i];
  8. rgbBytes[(i * 3) + 1] = bytes[i];
  9. rgbBytes[(i * 3) + 2] = bytes[i];
  10. }
  11. Bitmap bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb);
  12.  
  13. BitmapData data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
  14.  
  15. for (int i = 0; i <= bmp.Height - 1; i++)
  16. {
  17. long s = data.Scan0.ToInt64();
  18. int l = data.Stride;
  19.  
  20. IntPtr p = new IntPtr(data.Scan0.ToInt64() + data.Stride * i);
  21. System.Runtime.InteropServices.Marshal.Copy(rgbBytes, i * bmp.Width * 3, p, bmp.Width * 3);
  22. }
  23.  
  24. bmp.UnlockBits(data);
  25.  
  26. System.IO.MemoryStream ms = new System.IO.MemoryStream();
  27. bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
  28. byte[] byteImage = ms.ToArray();
  29. ms.Close();
  30. ms.Dispose();
  31.  
  32. return byteImage ;
  33. }
To copy to clipboard, switch view to plain text mode 

Now I sure if I could get the Image data into a QImage I could figure out the rest.
I've tired:
Qt Code:
  1. /* For refences this is teh structure format.
  2. typedef struct dpfpdd_image_info {
  3. unsigned int size; /**< size of the structure */
  4. unsigned char* image_data; /**< image data */
  5. unsigned int image_size; /**< size of the image data */
  6. unsigned int width; /**< width of the captured image */
  7. unsigned int height; /**< height of the captured image */
  8. unsigned int res; /**< resolution of the captured image */
  9. unsigned int bpp; /**< pixel depth of the captured image */
  10.  
  11. } DPFPDD_IMAGE_INFO;
  12. */
  13.  
  14. QImage* img = new QImage(pImageInfo.width, pImageInfo.height, QImage::Format_Indexed8);
  15. img->fromData(pImageInfo.image_data, pImageInfo.image_size);
To copy to clipboard, switch view to plain text mode 

I then try to save it off as a Bitmap to look at it, but i'm told it's not a proper bitmap file.

So i'm not sure if i am even close to the direction on loading this image data into a Qimage.

Any direction would be great. I've been searching around all day, but just have not had much of any luck.