I have a 'pbm' image whose content is loaded into a IMAGE object which is defined as below.
My problem current is how to plot this picture on a MFC dialog (I current want to draw it on the MFC dialog). My code below does not generate any result.
struct header {
int nr, nc; /* Rows and columns in the image */
int oi, oj; /* Origin */
};
/* The IMAGE data structure */
struct image {
struct header *info; /* Pointer to header */
unsigned char **data; /* Pixel values */
};
void CSampleDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
char* lpszPathName = "TESTPAGE.PBM";
IMAGE image = Input_PBM(lpszPathName);
for(int i=0; i< image->info->nc; i++){
for(int j=0; j< image->info->nr; j++){
unsigned char pixel = image->data[j][i];
//pixel value is either 0 or 1..
dc.SetPixel(i,j,pixel); //PLOT The whole image....
}
}
Invalidate(0);
}
HRESULT CSampleDlg::OnButtonOK(IHTMLElement* /*pElement*/)
{
OnPaint();
return S_OK;
}
In the OnPaint(), i called dc->setPixel(..) to redraw the whole image by drawing each pixel. But the dialog does not change...
Aucun commentaire:
Enregistrer un commentaire