Hi, I've spend all day to try jpegARMlet with pockstudio but nothing good
I've write this function only to load an image but I've the some error when
I try to save an image displayed on screen:

Type
   MyUserData = record
     ftrMemory:Pointer;
     myPtrFree:Pointer;
     myFileWriter:Pointer;
     myFileReader:Pointer;
     errorMessager:Pointer;
     width:UInt16;
     height:UInt16;
     xOffset:UInt16;
     yOffset:UInt16;
     RGB:UInt16;
   end;

Procedure myPtrFree(ptr:Pointer);
begin
  MemPtrFree(ptr);
end;

Procedure myFileReader(buf:Pointer;buflength:UInt32;Read_:Uint32);
begin
  VFSFileRead(fp, buflength, buf,read_);
end;

Procedure myFileWriter(buf:Pointer;buflength:UInt32;written:Uint32);
begin
  VFSFileWrite(fp, buflength, buf, written); //note that fp is a global
end;

Procedure errorMessager(msg:PChar);
begin
  ShowMessage(msg);
end;

Function PceNativeCallfunction(const emulStateP: Pointer; userData68KP:
Pointer; call68KFuncP: Call68KFuncType): UInt32;
begin
  MemHandleLock( userData68KP);   <<====== PROBABLY ERROR
  Result := 0;
end;

Function CaricaImg:Err;
Var volRefNum:UInt16;
    volIterator,nRis,screenDepth:UInt32;
    oData:MyUserData;
    mh:MemHandle;
    armlet:Pointer;
    bitmapData:Pointer;
    bmpP:BitmapPtr;
    bmp3:BitmapPtrV3;
begin
  screenDepth := 16;
  volIterator := vfsIteratorStart;
  Result := VFSVolumeEnumerate(volRefNum, volIterator);
  if Result <> 0 then
    ShowMessage('Scheda non inserita')
  else
  begin
    Result := VFSFileOpen(volRefNum,'/2.jpg',vfsModeRead ,fp);
    if Result <> 0 then
      ShowMessage('Immagine non creata')
    else
    begin
     //Open the VFS file for reading

     //allocate feature memory, where we will put the
     //decoded image. But this will have to be done
     //from the armlet because we won't know the size
     //ahead of time
      Result := FtrPtrNew(Rsc('WTSN'),0,320*320*sizeof(UInt16), bitmapData);
      DmSet(bitmapData, 0, 320*320*sizeof(UInt16), 0);

      MemSet(@oData,SizeOf(MyUserData),0);
      oData.myPtrFree:[EMAIL PROTECTED];
      oData.myFileReader:[EMAIL PROTECTED];
      oData.ftrMemory:=bitmapData;
      oData.errorMessager:[EMAIL PROTECTED];
      oData.width:=320;
      oData.height:=320;

      // call the ARMlet
      mh := DmGetResource(Rsc('ARMC'), 9000);
      nRis := PceNativeCall(PceNativeCallfunction, @oData);  <<=== ERROR
HERE FATAL EXCEPTION

      MemHandleUnlock(mh);
      DmReleaseResource(mh);
      VFSFileClose(fp);
      WinScreenMode(winScreenModeSet,Nil, Nil, screenDepth, Nil);
      bmpP := BmpCreate(320, 320, 16, Nil, Result);

      bmp3:=BmpCreateBitmapV3(bmpP,kDensityDouble,bitmapData,Nil);
      if (bmp3 <> nil) then
      begin
  WinDrawBitmap(BitmapPtr(bmp3),0,0);
  BmpDelete(BitmapPtr(bmp3));
  BmpDelete(BitmapPtr(bmpP));
      end;
    end;
  end;
end;


"Adrien Regimbald" <[EMAIL PROTECTED]> ha scritto nel messaggio
news:[EMAIL PROTECTED]
>From the CamLibCaptureCallbackFunc callback, you are passed data in
through bufP. The callback may be used multiple times, so you need to
save your buffer data incrementally. You know that capture is complete
when your callback gets called with a size specified as zero. At this
point, you could simply write your data to a file with the VFS
functions and have a BMP file. Probably you'd want to be saving this
as a JPEG though. In the application I'm working on, we use the
jpegARMlet library (which has been posted on this newsgroup a few
times) to encode the data as a JPG file. The jpegARMlet library comes
with a few examples which would show you how to write the data to a
file using the library. As you know, the new SDK that came out with
the Zire 72 now exposes the PhotoAPI to do this with Palm native
functionality, but I haven't tried it using this method yet. It'd be
nice to try it out, but there are too many other things to get done to
invest time in switching to a new encoding technique when the current
one already works.

Adrien.

Tuesday, June 8, 2004, 10:12:55 AM, you wrote:


SC> "Adrien Regimbald" <[EMAIL PROTECTED]> ha scritto nel messaggio
SC> news:[EMAIL PROTECTED]
>> I'm afraid that I was a bit mixed up. I thought you were trying to
>> save a photo from the camera.
SC> Yes I'm trying to save a photo from a camera, but first I've tried to
open
SC> an jpg image and save it and it's all ok, now I've a lot of problem to
save
SC> a photo from a camera, when the image is on the screen I don't know how
can
SC> I save it.
SC> Also the example CameraV2 from pamOneSdk don't save the image but only
SC> capture it, so have you an idea how save it?

SC> Thanks






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

Reply via email to