 |
NOTE : This project is not currently in development and is totally unsupported. These pages are here for information only.
getThumbnail
Declaration
extern "C" status_t getThumbnail(BBitmap* &);
Description
This function is entirely optional. The function should download from the camera the thumbnail
for the current working image.
The function returns a status_t error code to indicate the success of the
operation. Any of the status_t error codes can be used, but it is suggested that
you stick to using B_NO_ERROR for success and B_ERROR for failure. The function is passed an
uninitialised BBitmap object. It is the responsibility of the plugin to allocate the necessary memory for the
thumbnail. The thumbnail can also be initialised to any dimensions, but should be B_RGB32 color space.
Example Implementation - Kodak DC210 Plugin
status_t getThumbnail(BBitmap* & bitmap)
{
//New up the bitmap, in this case to 96x72 pixels
bitmap = new BBitmap(BRect(0,0,95,71), B_RGB32);
int receivelength = 1024;
char* temp2;
//Send the command to get the thumbnail
ComPort->Write("\x66\x00", 2);
temp2 = (char*)(currentpicturenumber >> 8);
ComPort->Write(&temp2,1);
temp2 = (char*)(currentpicturenumber >> 0);
ComPort->Write(&temp2,1);
ComPort->Write("\x00",1);
ComPort->Write("\x00\x00\x1A",3);
//Allocate memory for the buffers
unsigned char *buffer = new unsigned char[receivelength];
unsigned char *buffer2 = new unsigned char[7000];
unsigned char *cfa = new unsigned char[3456];
unsigned char *rgb = new unsigned char[20736];
bool pending = true;
int z=0;
ComPort->Read(buffer,1);
while (buffer[0] == 0xf0)
ComPort->Read(buffer,1);
if (buffer[0] == 0xe2)
return(B_ERROR);
else if (buffer[0] == 0xd1)
{
do
{
//Read in thumbnail data into buffer
ComPort->Read(buffer,1);
while (buffer[0] == 0xf0)
ComPort->Read(buffer,1);
if (buffer[0] == 0x01)
{
pending = true;
receivepacket(buffer,receivelength, true);
memcpy(buffer2+z, buffer,receivelength);
z+=receivelength;
}
else
pending = false;
} while (pending);
if (buffer[0] == 0x00)
{
memcpy(cfa,buffer2, 3456);
//Convert into rgb from camera data
cfa2rgb(cfa, rgb, 96, 72);
//Put the data into the bitmap
SetBits(rgb, 20736, 0, B_RGB32);
snooze(50000);
return(B_NO_ERROR);
}
else
return(B_ERROR);
}
else
return(B_ERROR);
}
BDCP Developers Home Page
|
|
 |
|