Re: how to display image?? (except using cvShowImage)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: how to display image?? (except using cvShowImage)

Ed Elston
Anees, thanks for the code - works great.  One question is how can I
control the picture box size to match the image size instead of the
box remaining constant and the image sized to fit it?

Thanks, Ed

--- In [hidden email], "Anees" <mdaneespm@...> wrote:

>
> hope this will help you to display image
>
> ShowImage(IplImage * src, int ID)
> {
>  BYTE tmp[sizeof(BITMAPINFO)+255*4];
>  BITMAPINFO *bmi = (BITMAPINFO*)tmp;
>  memset(bmi, 0, sizeof(BITMAPINFO));
>  bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
>  bmi->bmiHeader.biWidth = src->width;
>  bmi->bmiHeader.biHeight = src->height;
>  bmi->bmiHeader.biPlanes = 1;
>  bmi->bmiHeader.biBitCount = 24;
>  bmi->bmiHeader.biCompression = BI_RGB;
>  bmi->bmiHeader.biSizeImage = src->width*src->height*1;
>  bmi->bmiHeader.biXPelsPerMeter = 0;
>  bmi->bmiHeader.biYPelsPerMeter = 0;
>  bmi->bmiHeader.biClrUsed = 0;
>  bmi->bmiHeader.biClrImportant = 0;
>  
>  ((DWORD*) bmi->bmiColors)[0] = 0x00FF0000; /* red mask*/
>  ((DWORD*) bmi->bmiColors)[1] = 0x0000FF00; /* green mask */
>  ((DWORD*) bmi->bmiColors)[2] = 0x000000FF; /* blue mask */
>  
>  
>  HWND hwndStill = NULL;
>  GetDlgItem(ID, &hwndStill);
>  RECT rc;
>  ::GetWindowRect(hwndStill, &rc);
>  int w = rc.right - rc.left;
>  int h = rc.bottom - rc.top;
>  HDC dc = ::GetDC(hwndStill);
>  
>  PAINTSTRUCT ps;
>  ::BeginPaint(hwndStill, &ps);
>  SetStretchBltMode(dc, COLORONCOLOR);
>  StretchDIBits(dc,0,0,w,h,0,0,src->width,src->height,src-
> >imageData,bmi,DIB_RGB_COLORS,SRCCOPY);
>  ::EndPaint(hwndStill, &ps);
>  ::ReleaseDC(hwndStill, dc);
> }
>
>
> --- In [hidden email], "toma_st" <toma_st@> wrote:
> >
> >
> > There was a thread not long (few weeks) ago about this. Search
for

> my
> > nick.
> >
> > --- In [hidden email], "Felix Fan" <fanengchangfelixfan@>
> > wrote:
> > >
> > > how to open an image by using an open file dialog ?
> > >
> > > Then display it on my picture box (not display in a specified
> window
> > > that create by cvNamedWindow).
> > >
> > > i can display many pictures in a new created window by using
> function
> > > cvloadimage , cvNameWindow and cvShowImage but i cant display
> image
> > > in my picture box that create by using vc++ 6.
> > >
> > > i don't want display image in many windows but only in 1
window .
> > >
> > > Do you all have any ideas??
> > >
> > > thanks for your reply !!
> > >
> >
>