Hi all,
I'm using Yves Piguet's JpegLib and I'm facing the following problem:

I capture an image with the treo's camera. Then I store it in a sd card with JpegLibCreateDataVFS. The problem is: if I create the image descriptor with JpegLibCreateImageDescrPtr using 3 as the number of components (RGB) the resulting image is made of small tiles of the original image (about 9x smaller, but only the first 3 tiles are displayed in the image). If the number of components is 1 (grayscale) the image is fine.

I think the problem is the way I'm feeling the pixels array. My original image is 16 bit depth and the image to encode is stored in a UInt8 array.

I'm doing this:

UInt16       * bits;
UInt8* img_data;
BitmapType  * bitmapP;
UInt32 tam;

JpegLibImageDescr image;
JpegLibData data;
JpegLibEncodeOptions eopt;


bitmapP = BmpCreate (previewWidth, previewHeight, previewDepth, 0, &err);

tam = previewWidth * previewHeight;
tam*=2;
err = CameraLibPreview (gLibRefNum, bits, kCameraImageFormatRGB16, previewWidth, previewHeight);


if (! err){
   img_data = MemPtrNew(tam);
   for (i = 0; i < previewWidth * previewHeight; i++){
       img_data[i] = ((UInt8)(bits[i]>>8) & 0xFF);
       img_data[i+1] = ((UInt8)bits[i] & 0xFF);

}
error = VFSFileOpen(volRefNum, path, vfsModeCreate | vfsModeReadWrite, &fr);
JpegLibCreateImageDescrPtr(jpegLibRef, &image, previewWidth, previewHeight, 3, img_data); // if I change 3 to 1 I get a grayscale image properly displayed (in a viewer).
// 3 generates a 3 x 3 tiled image but only the first row is displayed. Any other value makes the app crash.


/* Establece las opciones */
JpegLibCreateEncOptions(jpegLibRef, &eopt);
JpegLibSetEncOptQuality(jpegLibRef, &eopt, 80);
JpegLibSetEncOptProgressive(jpegLibRef, &eopt, 0);
JpegLibCreateDataVFS(jpegLibRef, &data, fr);
error = JpegLibWrite(jpegLibRef, &image, &eopt, &data);
VFSFileClose(fr);



Any clue of what am I doing wrong? as I said before, there is no problem when I encode the image as grayscale, only when I store it as RGB.


I hope someone can help me identify the problem.

Miguel

--
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/

Reply via email to