Well, my Pascal is very rusty, but..
In your declaration of the ImageData structure type, shouldn't imgH be
a pointer (imgH : ^UInt16)? If it's not supposed to be a pointer,
where are you storing the image between callbacks?
Also, in both algorithms, the swapping seems backwards. Right now it
looks like:
inputBuffer = Swap(storageBuffer);
shouldn't it be:
storageBuffer = Swap(inputBuffer);
Where did you get your CodeWarrior example from? It seems a bit wonky
- for example, the capture callback function is defined like this in
the PalmCameraLib API:
typedef Err CamLibCaptureCallbackFunc(void *bufP, UInt32 size, void *userDataP)
but for some reason, your example has the 2nd parameter being a
pointer. Have you successfully tried running the CodeWarrior example?
Adrien.
Friday, June 4, 2004, 7:39:01 AM, you wrote:
SC> I've to save an image with PalmPhoto api and I've an example in codewarrior
SC> but I'm writing an application with pocketstudio. I don't be able to convert
SC> this:
SC> // CODEWARRIOR
SC> typedef struct _ImageData
SC> {
SC> UInt16 *imgH;
SC> UInt32 offset;
SC> UInt16 rowBytes;
SC> Coord width;
SC> Coord height;
SC> }ImageData;
SC> #define Swap16(n) (((((UInt16) n) << 8) & 0xFF00) | ((((UInt16) n) >> 8) &
SC> 0x00FF))
SC> Err PalmPhotoWriteCallBack(void *bufferP, UInt32 *sizeP, void *userDataP)
SC> {
SC> //bufferP -> Pointer to the chunk of memory which is passed to the user
SC> //sizeP -> Pointer to the size of the buffer
SC> // userDataP -> Pointer which can be cast in any way by the user
SC> Err err = errNone;
SC> UInt32 size = *sizeP / 2;
SC> UInt16 *myBuffP = (UInt16 *)bufferP;
SC> ImageData *dataP = (ImageData *)userDataP;
SC> while(size--)
SC> {
SC> *myBuffP = Swap16(*dataP->imgH);
SC> dataP->imgH++;
SC> dataP->offset++;
SC> myBuffP++;
SC> }
SC> return err;
SC> }
SC> // POCKETSTUDIO
SC> Type
SC> ImageData = Record
SC> imgH:Uint16;
SC> offset:UInt32;
SC> rowBytes:UInt16;
SC> width:Coord;
SC> height:Coord;
SC> end;
SC> Type
SC> _ImageData = ^ImageData;
SC> Function Swap16(n:UInt16):UInt16;
SC> begin
SC> Result := ((((n shl 8) and $FF00) or ((n shr 8) and $00FF)));
SC> end;
SC> Function PalmPhotoWriteCallBack(bufferP: Pointer; var sizeP: UInt32;
SC> userDataP: Pointer):Err;
SC> Var size,x:UInt32;
SC> myBuffP:UInt16;
SC> dataP:_ImageData;
SC> begin
SC> // bufferP -> Pointer to the chunk of memory which is passed to the user
SC> // sizeP -> Pointer to the size of the buffer
SC> // userDataP -> Pointer which can be cast in any way by the user
SC> Result := errNone;
SC> size := sizeP div 2;
SC> myBuffP := UInt16(bufferP);
SC> dataP := userDataP;
SC> for x := 0 to size - 1 do
SC> begin
SC> myBuffP := Swap16(dataP.imgH); <<== The error is here I've to write
SC> myBuff^ := Swap16(dataP.ImgH^) but make a compiler error
SC> dataP^.imgH := dataP^.imgH + 1;
SC> dataP^.offset := dataP^.offset + 1;
SC> myBuffP := myBuffP + 1;
SC> end;
SC> end;
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/