display array in a frame wnd



Hi,
I am using opencv wich is an image processing lib.
I would like to display in a CFrameWnd, images represented by an
array.(IplImage format)
pImg is the IplImage*

I have some difficulties to display the array.

First , I create CFramWnd,
CFrameWnd* pw ;
pw = new CFrameWnd() ;
pw->Create("NULL,"test") ;
pw->ShowWindow(SW_SHOW) ;
I get the window.

then
//Initialize the BMP display buffer
BITMAPINFO* bmi;
BITMAPINFOHEADER* bmih;
RGBQUAD* palette;
unsigned int buffer[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256];

bmi = (BITMAPINFO*)buffer;
bmih = &(bmi->bmiHeader);
memset(bmih, 0, sizeof(*bmih));
bmih->biSize = sizeof(BITMAPINFOHEADER);
bmih->biWidth = pImg->width;
bmih->biHeight = pImg->height;
bmih->biPlanes = 1;
bmih->biCompression = BI_RGB;
bmih->biBitCount = 8 * pImg->nChannels;
palette = bmi->bmiColors;
if (pColor->nChannels == 1)
{
for( int i = 0; i < 256; i++ )
{
palette[i].rgbBlue = palette[i].rgbGreen = palette[i].rgbRed
= (BYTE)i;
palette[i].rgbReserved = 0;
}
}

CPaintDC dc(pw);
CDC* pDC = &dc;

int res = StretchDIBits(
pDC->GetSafeHdc(), //dc
0, //x dest
0, //y dest
int(pImg->width), //x dest dims
int(pImg->height), //y dest dims
0, // src x
0, // src y
pImg->width, // src dims
pImg->height, // src dims
pImg->imageData, // array of DIB bits
(BITMAPINFO*)bmi, // bitmap information
DIB_RGB_COLORS, // RGB or palette indexes
SRCCOPY); // raster operation code

// Update Window, force View to redraw.
pw->RedrawWindow(
NULL, // handle to window
NULL, // update rectangle
RDW_INVALIDATE // handle to update region
);

I have no display of my image.
Where is the problem ?
Thenk you for your help

Jeff



.



Relevant Pages

  • Re: display array in a frame wnd
    ... I have read some articles on document/view architecture (I began with this ... I can display another window with a special menu dedicated ... All these different windows are subclasses of CFrameWnd. ...
    (microsoft.public.vc.mfc)
  • Re: display array in a frame wnd
    ... I have to display results. ... The window can be used in all the program thanks to the name "source image". ... CFrameWnd* pw; ... Why is this not in an OnPaint handler? ...
    (microsoft.public.vc.mfc)
  • CHtmlView not displaying anything
    ... I have created splitter window,one of the window is of type CFrameWnd which ... CFrameWnd window it does not display anything although OnDocumentComplete ... void CBrowserView::OnInitialUpdate ...
    (microsoft.public.vc.mfc)
  • Re: CDialog and CView ?
    ... When a user presses the Preview button, I wanna display a Customize Browser. ... I thought about writing a CFrameWnd and attach to it the CBrowserView, ... >> CView Dervied class). ...
    (microsoft.public.vc.mfc.docview)
  • Re: CDialog and CView ?
    ... When a user presses the Preview button, I wanna display a Customize Browser. ... I thought about writing a CFrameWnd and attach to it the CBrowserView, ... >> CView Dervied class). ...
    (microsoft.public.vc.mfc)