I have interesting question about load image in picture control of MFC. I have a form that can resize. I do it using the method of Mark Ransom. I write that method in CResizableDialog.cpp
. To used it, in my class I used
class CFace_Recognition_MFCDlg : public CResizableDialog
And my form have a picture control form with IDC_IMG
is
CStatic pic1;
void CFace_Recognition_MFCDlg::DoDataExchange(CDataExchange* pDX)
{
CResizableDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_IMG, pic1);
}
Finally, I using opencv to read image and convert it to bmp. Then display it into picture control by code
IplImage *img;
IplImage *resize;
img=cvLoadImage("phongcanh.jpg",CV_INTER_LINEAR);
if(img==0){
exit(0);
}
resize = cvCreateImage(cvSize(400,300),img->depth, img->nChannels);
cvResize(img, resize, 1);
pic1.SetBitmap(IplImage2DIB(resize));
cvReleaseImage(&img);
The function IplImage2DIB works well. But I cannot show the image into the picture control. I check and I find that the problem in the function
CResizableDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_IMG, pic1);
But I don't know how to edit it. Because I am working with a resizeable form. Could you help me to fix it? Thanks