I use this in a treo 650 with code warrior 9
static Err WindowPreview (void)
{
Err err = 0;
Char Aux[200];
// New library stuff
CamLibBitmapInfoType info;
CamLibCaptureType capture;
CamLibSettingType captureFormat;
PhotoCaptureInfo captureInfo;
captureFormat.type = kCamLibCaptureDataFormatRGB565;
CamLibControl(gLibRefNum, kCamLibCtrlCaptureFormatSet, (void *)
&captureFormat);
captureFormat.type = kCamLibImageSizeQVGA;
CamLibControl(gLibRefNum, kCamLibCtrlCaptureSizeSet,&captureFormat);
CamLibControl(gLibRefNum, kCamLibCtrlCaptureGetBitmapInfo, (void *)
&info);
captureInfo.winH = WinCreateOffscreenWindow(info.width/2,
info.height/2, nativeFormat, &err);
captureInfo.bufferP = (unsigned char *)
BmpGetBits(WinGetBitmap(captureInfo.winH));
capture.userDataP = &captureInfo;
capture.callbackP = PhotoCaptureCallback;
CamLibControl(gLibRefNum, kCamLibCtrlCapture, &capture);
StrCopy(Aux,sIdTrabajo);
StrCat(Aux,"_");
SavePhoto(gLibRefNum2,captureInfo.winH, 160, 120,&iCantFotos,Aux);
WinDeleteWindow(captureInfo.winH, true);
return err;
}
Err SavePhoto(UInt16 libRefNum, WinHandle backBufferWinH, UInt32 photoWidth,
UInt32 photoHeight,Int *Cant,Char *IdTrab)
{
PalmPhotoCreateParam createParam;
PalmPhotoReadWriteParam writeParam;
ImageData imageD;
UInt32 density = 0;
Err err = errNone;
PalmPhotoHandle *addedPhotoHandleP = NULL;
PalmPhotoHandle newPhotoH=NULL;
FormType *frmP = NULL;
FileRef fr=0;
UInt16 volRefNum = 0;
UInt32 volIterator = vfsIteratorStart;
Char Aux[10];
Char Ruta[300];
StrCopy(Ruta,"/Fotos.img/");
StrCat(Ruta,IdTrab);
StrIToA(Aux,*Cant);
StrCat(Ruta,Aux);
StrCat(Ruta,".jpg");
*Cant=*Cant+1;
Int y=*Cant;
// Get the bitmap associated with the window
BitmapType *bmpP = WinGetBitmap(backBufferWinH);
WinDrawBitmap(bmpP,0,20);
err = VFSVolumeEnumerate(&volRefNum, &volIterator);
VFSDirCreate(volRefNum,"/Fotos.img/");
// Get the bits associated with the bitmap
imageD.imgH = (UInt16 *)BmpGetBits(bmpP);
imageD.offset = 0;
WinScreenGetAttribute(winScreenDensity, &density);
if(!newPhotoH)
{
createParam.fileLocation.fileLocationType =
palmPhotoVFSLocation;
StrCopy(createParam.fileLocation.file.VFSFile.name, Ruta);
*Cant++;
createParam.fileLocation.file.VFSFile.volumeRef = volRefNum;
if(density == kDensityDouble)
{
createParam.imageInfo.width = photoWidth << 1;
createParam.imageInfo.height = photoHeight << 1;
}
else
{
createParam.imageInfo.width = photoWidth;
createParam.imageInfo.height = photoHeight;
}
createParam.imageInfo.bitsPerPixel = 16;
createParam.imageInfo.fileFormat = palmPhotoJPEGFileFormat;
// Create a new image and get the photo handle
newPhotoH = PalmPhotoCreateImage(libRefNum, &createParam,
&err);
}
MemSet(&writeParam, sizeof(PalmPhotoReadWriteParam), 0);
writeParam.imageFormat = palmPhotoRGB565FileFormat;
writeParam.rwCallback = PalmPhotoWriteCallBack;
writeParam.userDataP = &imageD;
err = PalmPhotoWriteImage(libRefNum, newPhotoH, &writeParam);
// Image is closed
PalmPhotoCloseImage(libRefNum, newPhotoH);
VFSFileClose(fr);
return err;
}
-----Mensaje original-----
De: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] En nombre de [EMAIL PROTECTED]
Enviado el: Domingo, 14 de Mayo de 2006 10:45 p.m.
Para: Palm Developer Forum
Asunto: Do anyody can Help me with Creating JPEG file from an
OffScreenWindow
I am Writing some code to capture Pen locus on an OffscreenWindow, and this
OffscreenWindow is 144*2400 and is only black and white.
I need to convert it into a file stream of JPEG format, but I donot got any
idea how to make it as well as I should handle it to my master in two weeks.
Do anybody can help me, give me some code, tell me the step to achieve etc.
I really appreciate.
Thank you so much.
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
--
Este mensaje ha sido analizado en busca de virus y otros contenidos
peligrosos, y se considera que est limpio.
--
Este mensaje ha sido analizado en busca de virus y otros contenidos peligrosos,
y se considera que está limpio.
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/