1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
wxBitmap CamerasManager::getOneImage(Camera* myCam, int camPerLine, int numCam, bool save) {
Image rawImage;
wxSize PanelSize = frame->GetPanel2Size();
//this->SetPropertyCam();
//Retrieve an image
wxMessageBox(wxString::FromUTF8("Avant")); // le porgramme affiche 9 fois avant et plante au 10eme sans afficher apres
error = myCam->RetrieveBuffer(&rawImage);
wxMessageBox(wxString::FromUTF8("Apres"));
if (error != PGRERROR_OK) {
wxMessageBox(wxString::FromUTF8("RetrieveBuffer"));
}
unsigned char* data;
unsigned char* pData = rawImage.GetData();
if (save == true){
images[numCam].push_back(rawImage);
}
//Convert Image -> WxBitmap
int size = rawImage.GetDataSize();
data = (unsigned char*) malloc(size * 3);
int y = 0;
for (unsigned int i = 0; i < rawImage.GetCols() * rawImage.GetRows() * 3; i += 3) {
data[i] = pData[y];
data[i + 1] = pData[y];
data[i + 2] = pData[y];
y++;
}
wxImage img = wxImage(rawImage.GetCols(), rawImage.GetRows(), data, true);
if((img.GetWidth()+10)*camPerLine+10 >PanelSize.GetWidth()) {
int newWidth = PanelSize.GetWidth();
float ratio = float(newWidth)/float(img.GetWidth());
int newHeight = img.GetHeight()*ratio;
img.Rescale(newWidth/camPerLine-(10+10/camPerLine) ,newHeight/camPerLine-10);
}
if((img.GetHeight()+15)*camPerLine+15 >PanelSize.GetHeight()) {
int newHeight = PanelSize.GetHeight();
float ratio = float(newHeight)/float(img.GetHeight());
int newWidth = img.GetWidth()*ratio;
img.Rescale(newWidth/camPerLine-10,newHeight/camPerLine-(15+15/camPerLine) );
}
wxBitmap bmp(img);
free(data);
return bmp;
} |
Partager