Re: Image display

"Augusto_Roman" <[email protected]> Mon, 05 Aug 2002 08:46:17 -0000
Newsgroups gmane.comp.video.image-magick.windows
Message-ID <[email protected]>
--- In imagemagick@y..., "jlchappell" <jlchappell@y...> wrote:
> I find that the example method of displaying an image in the NT 
> program that's supplied is rather slow. Does anyone have a fast way 
> of displaying a changing image?
> 
> Jerry

I use the following, and it's reasonably fast:
(fast enough for a document manipulation program, not games/video)

if (m_Image_isValid)  // I keep track of this myself
{
        // Get the image dimensions and a pointer to the pixels
	const Geometry& imsz = m_Image.size();
	const PixelPacket* ppix = m_Image.getConstPixels( 0 , 0 , 
imsz.width() , imsz.height() );

        // Construct a BITMAPINFO object that describes the
        // pointer to the pixels
	BITMAPINFO bmi;
	bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
	bmi.bmiHeader.biWidth = imsz.width();
	bmi.bmiHeader.biHeight = -imsz.height();
	bmi.bmiHeader.biPlanes = 1;
	bmi.bmiHeader.biBitCount = 32;
	bmi.bmiHeader.biCompression = BI_RGB;
	bmi.bmiHeader.biSizeImage = 0;
	bmi.bmiHeader.biXPelsPerMeter = 1;
	bmi.bmiHeader.biYPelsPerMeter = 1;
	bmi.bmiHeader.biClrUsed = 0;
	bmi.bmiHeader.biClrImportant = 0;
        // bmi.bmiColors is unused

        // Get the client window size
        // (because I want to fill the whole client area)
	CRect win;
	GetClientRect(win);

	// Set fast and color-friendly stretch mode
	::SetStretchBltMode( *pDC, COLORONCOLOR );
	::StretchDIBits( *pDC,
		0,0,win.Width(),win.Height(),     // target rect 
(x,y,w,h)
		0,0,imsz.width(),imsz.height(),   // rect within 
source image (x,y,w,h)
		ppix,&bmi,DIB_RGB_COLORS,SRCCOPY);
}



To unsubscribe from this group, send an email to:
[email protected]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/