display array in a frame wnd
- From: "J-F Portala" <jfportala@xxxxxxx>
- Date: Wed, 5 Sep 2007 10:52:57 +0200
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
.
- Follow-Ups:
- Re: display array in a frame wnd
- From: Joseph M . Newcomer
- Re: display array in a frame wnd
- Prev by Date: Re: Adding Qoutation mark " to CString
- Next by Date: Re: Adding Qoutation mark " to CString
- Previous by thread: Adding Qoutation mark " to CString
- Next by thread: Re: display array in a frame wnd
- Index(es):
Relevant Pages
|