hi,

I'm using palmOnePhoto library for creating jpeg images and also creating 
thumbnails, previously I'm using the pnoJpeg lib for that purpose, but this 
palmOnePhoto is much faster than that.. but there is one problem I'm getting is 
that, its converting my pictures in a negative like images, not actually 
negative some sort of color changes .. I'm using the device with 8 bit depth. i 
tried by changing the screen mode and make it to 16bit ,then its clear 
picture.. but changing the color depth cause my device crashing some times.. is 
there any way to get clear picture in my 8 bit application..
plz help me to solve this... here I'm including the part where I'm using the 
PalmOnePhoto conversions. spot me if there any prob in my code..

Err err=0;
    UInt16 pLibRefNum;
   
    PalmPhotoCreateParam     createParam;
    PalmPhotoReadWriteParam writeParam;
    ImageData                 imageD;        //Structure Type UInt16 
*imgH;UInt32 offset;UInt16 rowBytes;Coord width;Coord height;
    UInt32                    density = 0;
    PalmPhotoHandle            addedPhotoHandleP = NULL,newPhotoH = NULL;
    FormType                *frmP = NULL;
    Int16                    photoWidth;
    Int16                    photoHeight;
    UInt16                    rowBytes;
    FileHand                newF;
    Int32                    fileSize,op,temFileSize,size;
    Int8                    *buf;
    Char                    s[30];
    UInt8                    depth=0;
    BitmapPtr                bmpP;
    Int16                    width,height;
    UInt16                    rowByte;
    WinHandle                bwinH,temH;
   
    depth = BmpGetBitDepth(bmpPtr);
    if(depth!=16)
    {
        BmpGetDimensions(bmpPtr,&width,&height,&rowByte);
        bmpP = BmpCreate(width,height,16,NULL,&err);
        bwinH = WinCreateBitmapWindow(bmpP,&err);
        temH = WinSetDrawWindow(bwinH);
        WinDrawBitmap(bmpPtr,0,0);
        bmpPtr = WinGetBitmap(bwinH);
        bwinH = WinSetDrawWindow(temH);
        WinDeleteWindow(bwinH,true);
        //BmpDelete(bmpP);
    }
    imageD.imgH = (UInt16 *)BmpGetBits(bmpPtr);
    imageD.offset = 0;
   
    err = SysLibFind(PalmPhotoLibName, &pLibRefNum);

    if(err)
        err = SysLibLoad(PalmPhotoLibTypeID, PalmPhotoLibCreatorID, 
&pLibRefNum);

    if(!err)
        PalmPhotoLibOpen(pLibRefNum);
                     
    BmpGetDimensions(bmpPtr,&photoWidth,&photoHeight,&rowBytes);
   
    WinScreenGetAttribute(winScreenDensity, &density);
    FileDelete(0, "palmLibTemp.jpg");
        createParam.fileLocation.fileLocationType = palmPhotoStreamLocation;
        StrCopy(createParam.fileLocation.file.StreamFile.name, 
"palmLibTemp.jpg");
        createParam.fileLocation.file.StreamFile.type = 0;
        createParam.fileLocation.file.StreamFile.creator = 0;
       
        if(density == kDensityDouble)
        {
            createParam.imageInfo.width = photoWidth ;//320;//
            createParam.imageInfo.height =photoHeight; //320;//
        }
        else
        {
            createParam.imageInfo.width = photoWidth;
            createParam.imageInfo.height = photoHeight;
        }
       
        createParam.imageInfo.bitsPerPixel = 16;
        createParam.imageInfo.fileFormat = palmPhotoJPEGFileFormat;
        createParam.imageInfo.imageQuality=palmPhotoHighestQuality;
        // Create a new image and get the photo handle
        newPhotoH = PalmPhotoCreateImage(pLibRefNum, &createParam, &err);
   
    MemSet(&writeParam, sizeof(PalmPhotoReadWriteParam), 0);
   
    writeParam.imageFormat = palmPhotoRGB565FileFormat;
    writeParam.rwCallback = PalmPhotoWriteCallBack;
    writeParam.userDataP = &imageD;
    err = PalmPhotoWriteImage(pLibRefNum, newPhotoH, &writeParam);
    PalmPhotoCloseImage(pLibRefNum, newPhotoH);
   
    PalmPhotoLibClose(pLibRefNum);
    SysLibRemove(pLibRefNum);


Display part  
 
void displayJpeg(Coord x,Coord y,Coord mWidth,Coord mHeight)
{
    PalmPhotoHandle photoH = NULL;
    PalmPhotoFileLocation fileLocation;
    UInt32 density = 0;
    Err err;
    PalmPhotoDisplayParam displayParam;
    RectangleType displayRect;
    Coord width=160, height=120;
   
    PalmPhotoImageInfo imageInfo;
    BitmapType *tmpbitmapP = NULL;
    UInt16 pLibRefNum;
   
   
   
    err = SysLibFind(PalmPhotoLibName, &pLibRefNum);

    if(err)
        err = SysLibLoad(PalmPhotoLibTypeID, PalmPhotoLibCreatorID, 
&pLibRefNum);

    if(!err)
        PalmPhotoLibOpen(pLibRefNum);

    fileLocation.fileLocationType = palmPhotoStreamLocation;
    fileLocation.file.StreamFile.type = 0;
    fileLocation.file.StreamFile.creator = 0;

    StrCopy(fileLocation.file.StreamFile.name, "palmLibTemp.jpg");
    photoH = PalmPhotoOpenImage(pLibRefNum, &fileLocation,&err);

    err = PalmPhotoGetImageInfo(pLibRefNum, photoH, &imageInfo);

    if ((!err) && (photoH))
    {
        if (!err)
        {
            displayRect.topLeft.x = x;
            displayRect.topLeft.y = y;


            if(density == kDensityDouble)
            {
                displayRect.extent.x = mWidth*2;//width;
                displayRect.extent.y = mHeight*2;//height;
            }
            else
            {
                displayRect.extent.x = mWidth ;
                displayRect.extent.y = mHeight;
            }


            displayParam.winH = NULL;
            displayParam.rect = displayRect;
            displayParam.displayCallback = NULL;
            displayParam.userDataP = NULL;

            err = PalmPhotoDisplayImage(pLibRefNum, photoH, &displayParam);
        }
    }
   
    PalmPhotoCloseImage(pLibRefNum, photoH);
   
    PalmPhotoLibClose(pLibRefNum);
    SysLibRemove(pLibRefNum);

}

Sumesh..

-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/

Reply via email to