Hi all,
Now I am able to read the image using PalmPhotoImageRead API. Callback
function get called for several time with size = 16384.
Image I am trying to read is of size 54059. After comparing original image
and the data I am reading I found that only first part (16384 bytes) is
identical.
Following is the way I am reading the file.
///////////
UInt32 pos=0;
////////////////////////////////////////////////////////////////////////////
////////////////////
//Following is the callback code
////////////////////////////////////////////////////////////////////////////
////////////////////
Err PhotoReadCallBack(void* bufferP, UInt32* size, void *userDataP)
{
MemMove (userDataP+pos, bufferP, *size);
Pos += *size;
}
////////////////////////////////////////////////////////////////////////////
//////////////////////
//To read the image
////////////////////////////////////////////////////////////////////////////
//////////////////////
Err SendImage (int fp, UInt16 AppNetRefNum, UInt16 ref, PalmPhotoHandle
aHandle)
{
Err err;
Err errno;
Char* aMessage;
PalmPhotoReadWriteParam aReadParam;
PalmPhotoImageInfo aImageInfo;
Int32 timeout;
UInt32 bCount = 0;
Int16 num = 0;
Char * aLength = NULL;
timeout = SysTicksPerSecond()*1;
//Get image imformation
err = PalmPhotoGetImageInfo (ref, aHandle, &aImageInfo);
if (err != errNone)
return err;
//Creae http header
aMessage = (Char*) MemPtrNew (100);
MemSet (aMessage, 100, '\0');
//write HTTP header
StrCopy(aMessage, HTTPPrefix);
StrCat (aMessage, KCRLF);
NetLibSend(netRef, netFp, aMessage, StrLen(aMessage),
0,0,0,timeout,&err);
MemSet (aMessage, 100, '\0');
//write content type header
StrCopy(aMessage, KHeadContentType);
StrCat(aMessage, KColonSpace);
StrCat(aMessage, "image/jpg");//this is hard coded right now
StrCat(aMessage, KCRLF);
NetLibSend(netRef, netFp, aMessage, StrLen(aMessage),
0,0,0,timeout,&err);
MemSet (aMessage, 100, '\0');
//write content length header
StrCopy (aMessage, KHeadContentLength);
StrCat(aMessage, KColonSpace);
aLength = (Char*) MemPtrNew(maxStrIToALen+1);
aLength = StrIToA(aLength, aImageInfo.filesize);
StrCat (aMessage, aLength);
StrCat(aMessage, KCRLF);
StrCat(aMessage, KCRLF);
NetLibSend(netRef, netFp, aMessage, StrLen(aMessage),
0,0,0,timeout,&err);
MemSet (aMessage, 100, '\0');
MemPtrFree (aLength);
MemPtrFree (aMessage);
//write body
aReadParam.imageFormat = aImageInfo.fileFormat;
aReadParam.rwCallback = PhotoReadCallBack;
aReadParam.userDataP =MemPtrNew(aImageInfo.filesize);
//read image
err = PalmPhotoReadImage(ref, aHandle, &aReadParam);
while(bCount<=aImageInfo.filesize)
{
num = NetLibSend(netRef, netFp, (aReadParam.userDataP+bCount),
1536, 0,0,0,timeout,&err);
bCount += num;
}
MemPtrFree(aReadParam.userDataP);
return err;
}
Please help me on this.
Thanks and Regards,
Micky Menezes
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/