here is my code to capture an image. i used  the palmonephotolib..

Err WindowPreview (UInt16 albID)
{
        UInt32                                          i;
        Err                                                     err = 0;
        UInt16                                          *bits;
        UInt16                                          index = 0;
        BitmapType                              *bitmapP;
        
        /** 4 testing **/
        Char                                            *msg = "";
        Int                                                     x = 0, y = 0;
        WinHandle                                       winH = NULL;
        
        /** 4 display **/
        RectangleType                           jpegAreaRectangle; // = {{0,0}, 
{0,0}};
        UInt32                                          density = 0;
        
        /** from the photo lib **/
        PalmPhotoHandle                         photoH;
        PalmPhotoCaptureParamV2         captureParam;
        PalmPhotoCaptureResolution SupportedResolutions;
        
        UInt32                                          photoWidth; 
        UInt32                                          photoHeight;
        void    *                                       p_buffer = NULL;
        
        
        //InfoMsg(p_fileName);
        
        // setup callframes
        MemSet(&captureParam, sizeof(PalmPhotoCaptureParamV2), 0);
        
        captureParam.fileLocation.fileLocationType = palmPhotoStreamLocation;
        captureParam.fileLocation.reserved = 0;
        
        captureParam.fileLocation.file.StreamFile.type = 'Foto';
        captureParam.fileLocation.file.StreamFile.creator = 'Foto';
        StrCopy(captureParam.fileLocation.file.StreamFile.name, "sample.jpg"); 
        
        SupportedResolutions = 
PalmPhotoGetSupportedCaptureResolutionsV3(PhotoLibRefNum , 
palmPhotoMediaTypePhoto);
                
        captureParam.imageInfo.width = 320;     //previewWidth;
        captureParam.imageInfo.height = 240;    //previewHeight;
        captureParam.imageInfo.bitsPerPixel = 16;
        captureParam.imageInfo.filesize = 0;
        captureParam.imageInfo.fileFormat = palmPhotoJPEGFileFormat;
        captureParam.imageInfo.imageQuality = palmPhotoHighQuality;
        
        captureParam.captureCallback = NULL;
    captureParam.userDataP = NULL;

        
        /** capture photo **/
        photoH = PalmPhotoCaptureImageV2(PhotoLibRefNum, &captureParam);

        if (photoH == NULL)
        {       
                err = PalmPhotoGetLastErrV2(PhotoLibRefNum);
        
                if  ((err) && ( err != palmPhotoLibErrUserCancel ))
                {       ErrorMsg("Error Writing Photo");
                        goto Done;      
                }
                else if (err == palmPhotoLibErrUserCancel)  // --> user press 
the cancel button on the camera
                        goto Done;
        }
        
        // add image to photo album
    err = PalmPhotoAddImageV2(PhotoLibRefNum, PALM_PHOTO_ALBUM_ALL, photoH, 
NULL);

    if (err != errNone) 
    {   ErrorMsg("Error adding image");
        goto Done;
        }
        
    // done with image
    err = PalmPhotoCloseImageV2(PhotoLibRefNum, photoH);
    if (err != errNone) 
        goto Done;
        
Done:
        //InfoMsg("delete file");
      //FileDelete(0,createParam.fileLocation.file.StreamFile.name);
        PalmPhotoCloseImageV2(PhotoLibRefNum, photoH);
        FrmGotoForm(PictureMainForm);
        return err;     

}


i get an error on the AddImage.. part. what seems to be wrong in my code? 
please help. i've been posting for a month.

thanks everyone!

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

Reply via email to