I've to save an image with PalmPhoto api and I've an example in codewarrior
but I'm writing an application with pocketstudio. I don't be able to convert
this:

// CODEWARRIOR
typedef struct _ImageData
{
 UInt16 *imgH;
 UInt32 offset;
 UInt16 rowBytes;
 Coord  width;
 Coord height;
}ImageData;

#define Swap16(n) (((((UInt16) n) << 8) & 0xFF00) | ((((UInt16) n) >> 8) &
0x00FF))

Err PalmPhotoWriteCallBack(void *bufferP, UInt32 *sizeP, void *userDataP)
{
 //bufferP -> Pointer to the chunk of memory which is passed to the user
 //sizeP -> Pointer to the size of the buffer
 // userDataP -> Pointer which can be cast in any way by the user
 Err err = errNone;
 UInt32 size = *sizeP / 2;
 UInt16 *myBuffP = (UInt16 *)bufferP;
 ImageData *dataP = (ImageData *)userDataP;

 while(size--)
 {
  *myBuffP = Swap16(*dataP->imgH);
  dataP->imgH++;
  dataP->offset++;
  myBuffP++;
 }
 return err;
}

// POCKETSTUDIO

Type
  ImageData = Record
    imgH:Uint16;
    offset:UInt32;
    rowBytes:UInt16;
    width:Coord;
    height:Coord;
  end;
Type
  _ImageData = ^ImageData;

Function Swap16(n:UInt16):UInt16;
begin
  Result := ((((n shl 8) and $FF00) or ((n shr 8) and $00FF)));
end;

Function PalmPhotoWriteCallBack(bufferP: Pointer; var sizeP: UInt32;
userDataP: Pointer):Err;
Var size,x:UInt32;
    myBuffP:UInt16;
    dataP:_ImageData;
begin
  // bufferP -> Pointer to the chunk of memory which is passed to the user
  // sizeP -> Pointer to the size of the buffer
  // userDataP -> Pointer which can be cast in any way by the user

  Result := errNone;
  size := sizeP div 2;
  myBuffP := UInt16(bufferP);
  dataP := userDataP;

  for x := 0 to size - 1 do
  begin
    myBuffP := Swap16(dataP.imgH);   <<== The error is here I've to write
myBuff^ := Swap16(dataP.ImgH^) but make a compiler error
    dataP^.imgH := dataP^.imgH + 1;
    dataP^.offset := dataP^.offset + 1;
    myBuffP := myBuffP + 1;
  end;

end;





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

Reply via email to