コード例 #1
0
ファイル: Dib.cpp プロジェクト: bngabonziza/miktex
void
Dib::Render (/*[in]*/ HDC	hdc,
	     /*[in]*/ int	x,
	     /*[in]*/ int	y,
	     /*[in]*/ int	cx,
	     /*[in]*/ int	cy)
{
  if (cx < 0)
  {
    cx = GetWidth();
  }
  if (cy < 0)
  {
    cy = GetHeight();
  }
  SetStretchBltMode (hdc, COLORONCOLOR);
  if (StretchDIBits(hdc,
    x,
    y,
    cx,
    cy,
    0,
    0,
    GetWidth(),
    GetHeight(),
    GetBits(),
    GetBitmapInfo(),
    DIB_RGB_COLORS,
    SRCCOPY)
      == GDI_ERROR)
  {
    FATAL_WINDOWS_ERROR ("StretchDIBits", 0);
  }
}
コード例 #2
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM w, LPARAM l)
{
	HDC hdc;// = GetDC(hwnd);
	PAINTSTRUCT ps;
	RECT rect;
	BITMAPINFO bmi;
	ZeroMemory(&bmi, sizeof(BITMAPINFO));
	bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
	bmi.bmiHeader.biPlanes = 1;
	bmi.bmiHeader.biBitCount = 24;
	bmi.bmiHeader.biCompression = BI_RGB;
	switch (msg) {
	case WM_DESTROY:
		PostQuitMessage(1);
		break;
	case WM_PAINT: {
		hdc=BeginPaint(hwnd,&ps);
		//GetWindowRect(hwnd,&rect);
		//RedrawWindow(hwnd,&rect,0,0);
		if(num==vs.length-1)exit(0);
		readjpeg(vs.strs[num++], &img);
		bmi.bmiHeader.biWidth = img.Width;
		bmi.bmiHeader.biHeight = img.Height;
		//SetDIBitsToDevice(hdc, 0, 0, img.Width, img.Height,0, 0, 0, img.Height, img.Data, &bmi, DIB_RGB_COLORS);
		SetStretchBltMode(hdc,STRETCH_HALFTONE);//注意第二个参数会影响显示质量
		StretchDIBits(hdc, 0, 0, img.Width/2, img.Height/2,0, 0,img.Width,img.Height, img.Data, &bmi, DIB_RGB_COLORS,SRCCOPY);
		free(img.Data);
		EndPaint(hwnd,&ps);
	}
	break;
	default:
		return DefWindowProc(hwnd, msg, w, l);
	}
	return 0;
}
コード例 #3
0
//
// DrawDib uses StretchDIBits to display the bitmap.
void CDIBitmap :: DrawDIB( CDC* pDC, int x, int y, int width, int height ) {
    ASSERT( pDC );
    HDC     hdc = pDC->GetSafeHdc();

	CPalette * pOldPal = 0;

	if( m_pPal ) {
		pOldPal = pDC->SelectPalette( m_pPal, FALSE );
		pDC->RealizePalette();
		// Make sure to use the stretching mode best for color pictures
		pDC->SetStretchBltMode(COLORONCOLOR);
	}

    if( m_pInfo )
        StretchDIBits( hdc,
                       x,
                       y,
                       width,
                       height,
                       0,
                       0,
                       GetWidth(),
                       GetHeight(),
                       GetPixelPtr(),
                       GetHeaderPtr(),
                       DIB_RGB_COLORS,
                       SRCCOPY );
	
	if( m_pPal )
		pDC->SelectPalette( pOldPal, FALSE );
}
コード例 #4
0
ファイル: cldib_core.cpp プロジェクト: devkitPro/grit
/*!	\param hdc	Destination DC.
*	\param rectDest	Destination rectangle. If NULL, the DIB's 
*	  dimensions are used.
*	\param dib	DIB to blit.
*	\param rectSrc	Source rectangle. If NULL, the DIB's 
*	  dimensions is used.
*	\param flags	Blit flags.
*	\note	Tested for top-down and bottom-up DIB's
*/
int dib_to_hdc(HDC hdc, const RECT *rectDst, 
			CLDIB *dib, const RECT *rectSrc, DWORD flags)
{
	RECT dstR, srcR;
	int dibHa= dib_get_height(dib);

	if(rectDst == NULL)
		SetRect(&dstR, 0, 0, dib_get_width(dib), dibHa);
	else
		CopyRect(&dstR, rectDst);

	if(rectSrc == NULL)
		SetRect(&srcR, 0, 0, dib_get_width(dib), dibHa);
	else
		CopyRect(&srcR, rectSrc);

	int srcW= srcR.right-srcR.left, srcH= srcR.bottom-srcR.top;
	int dstW= dstR.right-dstR.left, dstH= dstR.bottom-dstR.top;

	SetStretchBltMode(hdc, COLORONCOLOR);
	return StretchDIBits( hdc, 
		dstR.left, dstR.bottom, dstW, -dstH, 
		srcR.left, dibHa-srcR.top, srcW, -srcH, 
		dib_get_img(dib), dib_get_info(dib), 
		DIB_RGB_COLORS, flags);	
}
コード例 #5
0
ファイル: UIWebkit.cpp プロジェクト: cuijinquan/duibrowser
void CWebkitUI::DoPaint(HDC hDC, const RECT& rcPaint)
{
    if ((hDC == NULL) || (raster_ == NULL) || (bitmap_bits_ == NULL) || !finish_layout_)
        return;

    if( !::IntersectRect(&m_rcPaint, &rcPaint, &m_rcItem) ) return;

    if (did_first_layout_ && bitmap_bits_ != NULL && finish_layout_)
    {
        for (int i = 0; i < bitmap_header_info_.biHeight; ++i)
        {
            memcpy_s(bitmap_bits_ + (bitmap_header_info_.biWidth * i * 4), \
                     bitmap_header_info_.biSizeImage / bitmap_header_info_.biHeight, \
                     (LPBYTE)view_->GetSurface()->GetData() + (bitmap_header_info_.biWidth * i * 4), \
                     (bitmap_header_info_.biWidth * 4));
        }
    }
    else if (bitmap_bits_ != NULL)
    {
        DWORD dwScreenX = GetSystemMetrics(SM_CXSCREEN);
        DWORD dwScreenY = GetSystemMetrics(SM_CYSCREEN);
        dwScreenX = static_cast<DWORD>((dwScreenX + 3) / 4 * 4);
        memset(bitmap_bits_, 0xFF, dwScreenX * dwScreenY * 4);
    }

    ::SetStretchBltMode(hDC, COLORONCOLOR);
    BITMAPINFOHEADER bmiHeader = bitmap_header_info_;
    bmiHeader.biHeight = -bmiHeader.biHeight;
    StretchDIBits(hDC, m_rcItem.left, m_rcItem.top, m_rcItem.right - m_rcItem.left, m_rcItem.bottom - m_rcItem.top,
                  0, 0, bitmap_header_info_.biWidth, bitmap_header_info_.biHeight, bitmap_bits_, (LPBITMAPINFO)&bmiHeader, DIB_RGB_COLORS, SRCCOPY);
}
コード例 #6
0
ファイル: mcivideograbber.cpp プロジェクト: Bjoernke/livecode
Bool CWinVideoGrabber::Draw(int twidth,int theight, HDC hdcMem)
{
	if (!inited) return False;
	HGLOBAL videodib = NULL;
	char *dibdata = NULL;
	char *dibbits = NULL;
	BITMAPINFO *pbmp;
	Bool res = False;
	capEditCopy(videowindow); // Copy the frame in the clipboard as a DIB
	OpenClipboard(parentwindow);
	if (IsClipboardFormatAvailable(CF_DIB)){
		videodib=GetClipboardData(CF_DIB);
		dibdata = (char *)GlobalLock(videodib);
		pbmp = (BITMAPINFO *)dibdata;
		int tsourcewidth  = pbmp->bmiHeader.biWidth;
		int tsourceheight = pbmp->bmiHeader.biHeight;
		int palentries = pbmp->bmiHeader.biClrUsed;
		int bitcount = pbmp->bmiHeader.biBitCount;
		int lenrgb = 0;
		if (bitcount < 24) {
			if (palentries == 0)
				palentries = (1 << bitcount);
			lenrgb = palentries * sizeof(RGBQUAD);
		}
		dibbits = (char *)(dibdata + sizeof(BITMAPINFOHEADER) + lenrgb);
		StretchDIBits(hdcMem,0,0,twidth,theight,0,0,tsourcewidth,tsourceheight,
			(BITMAPINFO *)dibbits, pbmp, DIB_RGB_COLORS,SRCCOPY);
		GlobalUnlock(videodib);
		res = True;
	}
	CloseClipboard();
	return res;
}
コード例 #7
0
ファイル: ColorButton.cpp プロジェクト: OmerMor/SciCompanion
BOOL CreateDCCompatiblePattern(RGBQUAD color1, RGBQUAD color2, CDC *pDC, CBitmap *pbm)
{
    RGBQUAD HatchBits[16] = { color1, color1, color2, color2, color1, color1, color2, color2, 
                              color2, color2, color1, color1, color2, color2, color1, color1 };
    BITMAPINFO bmi = { 0 };
    bmi.bmiHeader.biSize = sizeof(BITMAPINFO);
    bmi.bmiHeader.biBitCount = 32;
    bmi.bmiHeader.biCompression = BI_RGB;
    bmi.bmiHeader.biWidth = 4;
    bmi.bmiHeader.biHeight = 4;
    bmi.bmiHeader.biPlanes = 1;

    CDC dcMem;
    BOOL bRet = dcMem.CreateCompatibleDC(pDC);
    if (bRet)
    {
        bRet = pbm->CreateCompatibleBitmap(pDC, 4, 4);
        if (bRet)
        {
            HGDIOBJ hObj = dcMem.SelectObject(pbm);
            bRet = StretchDIBits((HDC)dcMem, 0, 0, 4, 4, 0, 0, 4, 4, HatchBits, &bmi, DIB_RGB_COLORS, SRCCOPY);
            dcMem.SelectObject(hObj);
        }        
    }
    return bRet;
}
コード例 #8
0
static void
gdi_softpipe_present(struct pipe_screen *screen,
                     struct pipe_surface *surface,
                     HDC hDC)
{
    struct softpipe_texture *texture;
    struct gdi_softpipe_buffer *buffer;
    BITMAPINFO bmi;

    texture = softpipe_texture(surface->texture);
                                               
    buffer = gdi_softpipe_buffer(texture->buffer);

    memset(&bmi, 0, sizeof(BITMAPINFO));
    bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    bmi.bmiHeader.biWidth = texture->stride[surface->level] / pf_get_size(surface->format);
    bmi.bmiHeader.biHeight= -(long)surface->height;
    bmi.bmiHeader.biPlanes = 1;
    bmi.bmiHeader.biBitCount = pf_get_bits(surface->format);
    bmi.bmiHeader.biCompression = BI_RGB;
    bmi.bmiHeader.biSizeImage = 0;
    bmi.bmiHeader.biXPelsPerMeter = 0;
    bmi.bmiHeader.biYPelsPerMeter = 0;
    bmi.bmiHeader.biClrUsed = 0;
    bmi.bmiHeader.biClrImportant = 0;

    StretchDIBits(hDC,
                  0, 0, surface->width, surface->height,
                  0, 0, surface->width, surface->height,
                  buffer->data, &bmi, 0, SRCCOPY);
}
コード例 #9
0
ファイル: Raster.cpp プロジェクト: JackJone/opencv
/*======================================================================================*/
int CRaster::Draw(CDC* pDC, RECT , RECT) 
{
    HDC         hDC;
    CPalette*   oldPal;

    oldPal  = 0;

    hDC     =   pDC->m_hDC;
    if(pal) {
        oldPal  =   pDC->SelectPalette(pal, TRUE);
    }/* if */

    pDC->SetStretchBltMode(COLORONCOLOR);

    StretchDIBits(  hDC, 
                    XDest,          YDest, 
                    DestWidth,      DestHeight,
                    XSrc,           YSrc,
                    SrcWidth,       SrcHeight,
                    imgData,        imgInfo,
                    DIB_RGB_COLORS, SRCCOPY);

    if(pal) {
        pDC->SelectPalette(oldPal, TRUE);
    }/* if */

    return 1;
}/* CRaster::Draw */
コード例 #10
0
ファイル: Raster.cpp プロジェクト: JackJone/opencv
int CRaster::Draw(CDC* pDC, POINT point,SIZE size) 
{
    HDC         hDC;
    CPalette*   oldPal;

    oldPal  = 0;

    hDC     =   pDC->m_hDC;
    if(pal) {
        oldPal  =   pDC->SelectPalette(pal, TRUE);
    }/* if */

    pDC->SetStretchBltMode(COLORONCOLOR);

    StretchDIBits(  hDC, 
                    point.x,        point.y, 
                    size.cx,        size.cy,
                    XSrc,           YSrc,
                    SrcWidth,       SrcHeight,
                    imgData,        imgInfo,
                    DIB_RGB_COLORS, SRCCOPY);

    if(pal) {
        pDC->SelectPalette(oldPal, TRUE);
    }/* if */

    return 1;
}/* CRaster::Draw */
コード例 #11
0
void COriginalImg::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here	
	
	CWnd *pWnd = GetDlgItem(IDC_ORGIMG);
	if (pWnd==NULL)
	{
		MessageBox("error!");
		return;
	}
	CRect rect;
	pWnd->GetWindowRect(&rect);
	ScreenToClient(&rect);
	pWnd->MoveWindow(rect.left, rect.top, m_width, m_height, true);	
	CPaintDC pdc(pWnd);	
	::SetStretchBltMode(pdc, COLORONCOLOR);
	//show  image
	BITMAPINFOHEADER *bmpinfo = (BITMAPINFOHEADER *)(imgBuf + sizeof(BITMAPFILEHEADER));
	LPBITMAPINFO lpbmp = new BITMAPINFO;
	ZeroMemory(lpbmp, sizeof(BITMAPINFO));
	lpbmp->bmiHeader = *bmpinfo;
	StretchDIBits(pdc.GetSafeHdc(),  0,  0, m_width,  m_height,  0,  0,  m_width,  m_height, grayBuf,  lpbmp,  DIB_RGB_COLORS,  SRCCOPY);  
	// Do not call CDialog::OnPaint() for painting messages
}
コード例 #12
0
ファイル: win32_tiny.cpp プロジェクト: ClaytronG/tinyrenderer
static void Win32_AspectBlt( HDC hdc, win32BackBuffer_t *buffer, int width, int height ) {
	if ( height == 0 ) {
		height = 1;
	}
	if ( width == 0 ) {
		width = 1;
	}
	float scale = 1.f;
	int scaledWidth = buffer->width;
	int scaledHeight = buffer->height;
	if ( width < height ) {
		scaledWidth = width;
		scale = ( ( ( float ) width / ( float ) buffer->width ) + 0.5f );
		scaledHeight = ( int ) ( ( scale * ( float ) buffer->height ) + 0.5f );
	} else {
		scaledHeight = height;
		scale = ( ( ( float ) height / ( float ) buffer->height ) + 0.5f );
		scaledWidth = ( int ) ( ( scale * ( float ) buffer->width ) + 0.5f );
	}
	int x = ( int ) ( ( ( width - scaledWidth ) / 2.f ) + 0.5f );
	int y = ( int ) ( ( ( height - scaledHeight ) / 2.f ) + 0.5f );
	PatBlt( hdc, 0, 0, width, height, WHITENESS );
	PatBlt( hdc, x, y, scaledWidth, scaledHeight, BLACKNESS );
	StretchDIBits( hdc,
		x, y, scaledWidth, scaledHeight,
		0, 0, buffer->width, buffer->height,
		buffer->memory, &buffer->bitmapInfo,
		DIB_RGB_COLORS, SRCCOPY );
	/*PatBlt( hdc, 0, 0, x, y, WHITENESS );
	PatBlt( hdc, x + scaledWidth, y + scaledHeight, width - x, height - y, WHITENESS );*/
}
コード例 #13
0
ファイル: RenderWindow.cpp プロジェクト: RazielXT/RayTrace
LRESULT CALLBACK WinProc(HWND hWnd, UINT Msg,
	WPARAM wParam, LPARAM lParam)
{
	switch (Msg)
	{
	case WM_CREATE:
		break;
	case WM_DESTROY:
		PostQuitMessage(WM_QUIT);
		break;
	case WM_PAINT:
	{
		HDC dc = GetDC(hWnd);

		BITMAPINFO info;
		ZeroMemory(&info, sizeof(BITMAPINFO));
		info.bmiHeader.biBitCount = 24;
		info.bmiHeader.biWidth = w;
		info.bmiHeader.biHeight = h;
		info.bmiHeader.biPlanes = 1;
		info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
		info.bmiHeader.biSizeImage = 0;
		info.bmiHeader.biCompression = BI_RGB;

		StretchDIBits(dc, 0, 0, w, h, 0, 0, w, h, buf, &info, DIB_RGB_COLORS, SRCCOPY);
		ReleaseDC(hWnd, dc);
	}
	break;
	default:
		return DefWindowProc(hWnd, Msg, wParam, lParam);
	}
	return 0;
}
コード例 #14
0
ファイル: imageview.cpp プロジェクト: b2kguga/CodesAndNotes
void KImageCanvas::UponDrawPage(HDC hDC, const RECT * rcPaint, int width, int height, int pageno)
{
	if ( (m_pPicture==NULL) && (m_pPicture->m_pBMI==NULL) )
		return;

	int sw   = m_pPicture->GetWidth();
	int sh   = m_pPicture->GetHeight();
	
	int dpix = sw * ONEINCH / width;
	int dpiy = sh * ONEINCH / height;
	
	int dpi  = max(dpix, dpiy);

	int dispwidth  = sw * ONEINCH / dpi;
	int dispheight = sh * ONEINCH / dpi;
	
	SetStretchBltMode(hDC, STRETCH_HALFTONE);

	int x = ( width- dispwidth)/2;
	int y = (height-dispheight)/2;

	if ( StretchJPEG(hDC, x, y, dispwidth, dispheight, 
				m_pPicture->m_pJPEG, m_pPicture->m_nJPEGSize, sw, sh ) )
		return;

	StretchDIBits(hDC, x, y, dispwidth, dispheight, 0, 0, sw, sh, 
		m_pPicture->m_pBits, m_pPicture->m_pBMI, DIB_RGB_COLORS, SRCCOPY);
}
コード例 #15
0
ファイル: kguipc.cpp プロジェクト: CarlHuff/kgui
/* image is pre-rotated if landscape mode is selected */
void kGUIPrintJobWin::PrintSurface(kGUIDrawSurface *surface)
{
	int sw,sh;
	kGUIColor *bitmap;
	BITMAPINFO bmpi;

	bitmap=surface->GetSurfacePtrABS(0,0);
	sw=surface->GetWidth();
	sh=surface->GetHeight();

	if(m_error==true)	/* some error occured previously, abort */
		return;

	bmpi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
	bmpi.bmiHeader.biWidth = sw;
	bmpi.bmiHeader.biHeight = -sh;
	bmpi.bmiHeader.biPlanes = 1;
	bmpi.bmiHeader.biBitCount = WINBPP;
	bmpi.bmiHeader.biCompression = BI_RGB;
	bmpi.bmiHeader.biSizeImage = 0;
	bmpi.bmiHeader.biXPelsPerMeter = 0;
	bmpi.bmiHeader.biYPelsPerMeter = 0;
	bmpi.bmiHeader.biClrUsed = 0;
	bmpi.bmiHeader.biClrImportant = 0;

	StretchDIBits(m_pdc,
		m_lmp,m_tmp,		//upper left destination
		m_dw,m_dh,			//destination width/height
		0, 0,				// upper left of source
 		sw, sh,				// source rectangle size
		bitmap, &bmpi, DIB_RGB_COLORS,SRCCOPY);
}
コード例 #16
0
	void CDicomViewerView::DrawDicomImage(CDC* pDC)
	{
		CRect clientRect;
		this->GetClientRect(&clientRect);
		int nWidth=clientRect.Width(),nHeight=clientRect.Height();
		CDC MemDC; //首先定义一个显示设备对象
		CBitmap MemBitmap;//定义一个位图对象
		//随后建立与屏幕显示兼容的内存显示设备
		MemDC.CreateCompatibleDC(NULL);
		//这时还不能绘图,因为没有地方画 ^_^
		//下面建立一个与屏幕显示兼容的位图,至于位图的大小嘛,可以用窗口的大小
		MemBitmap.CreateCompatibleBitmap(pDC,nWidth,nHeight);
		//将位图选入到内存显示设备中
		//只有选入了位图的内存显示设备才有地方绘图,画到指定的位图上
		CBitmap *pOldBit=MemDC.SelectObject(&MemBitmap);
		//先用背景色将位图清除干净,这里我用的是白色作为背景
		//你也可以用自己应该用的颜色
		MemDC.FillSolidRect(0,0,nWidth,nHeight,RGB(0,0,0));
		CDicomViewerDoc* pDoc = GetDocument();
		if(pDoc->m_pDicomImage != 0){
			E_DecompressionColorSpaceConversion opt_decompCSconversion = EDC_photometricInterpretation;
			E_UIDCreation opt_uidcreation = EUC_default;
			E_PlanarConfiguration opt_planarconfig = EPC_default;

			OFBool opt_verbose = OFFalse;
			DJDecoderRegistration::registerCodecs(
				opt_decompCSconversion,
				opt_uidcreation,
				opt_planarconfig,
				opt_verbose);
			//根据传输语法构造 DicomImage 从 fstart 帧开始一共 fcount 帧
			DicomImage *pDicomImg = pDoc->m_pDicomImage;//new DicomImage(pDoc->m_pFilePathName);
			//DicomImage *pNewDicomImg = pDicomImg->createScaledImage((const unsigned long)1024,1024);
			LPBITMAPINFOHEADER m_lpBMIH = (LPBITMAPINFOHEADER) new char [sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256];
			m_lpBMIH->biSize = sizeof(BITMAPINFOHEADER);
			m_lpBMIH->biWidth = pDicomImg->getWidth(); 
			m_lpBMIH->biHeight = pDicomImg->getHeight();
			m_lpBMIH->biPlanes = 1;
			m_lpBMIH->biBitCount = 24;
			m_lpBMIH->biCompression = BI_RGB;
			m_lpBMIH->biSizeImage = 0;
			m_lpBMIH->biXPelsPerMeter = 0;
			m_lpBMIH->biYPelsPerMeter = 0;
			pDicomImg->setWindow(pDoc->m_dCurrentWindowCenter, pDoc->m_dCurrentWindowWidth);
			//得到 DICOM文件第 frame 的 DIB数据(假设是 24 位的)
			unsigned long bufSize = 0;
			void* m_pDicomDibits;
			bufSize =pDicomImg->createWindowsDIB(m_pDicomDibits, bufSize, 0, 24, 1, 1);

			double originalX = (clientRect.Width() - m_lpBMIH->biWidth)/2;
			double originalY = (clientRect.Height() - m_lpBMIH->biHeight)/2;
			StretchDIBits (MemDC.GetSafeHdc(),originalX,originalY, m_lpBMIH->biWidth, m_lpBMIH ->biHeight,0,0,m_lpBMIH->biWidth,m_lpBMIH->biHeight,
				m_pDicomDibits, (LPBITMAPINFO) m_lpBMIH,DIB_RGB_COLORS,SRCCOPY);
			delete m_pDicomDibits;
		}
		//将内存中的图拷贝到屏幕上进行显示
		pDC->BitBlt(0,0,nWidth,nHeight,&MemDC,0,0,SRCCOPY);
		MemBitmap.DeleteObject();
		MemDC.DeleteDC();
	}
コード例 #17
0
ファイル: FolderLib.cpp プロジェクト: OLR-xray/OLR-3.0
void DrawBitmap(HDC hdc, const Irect& r, u32* data, u32 w, u32 h)
{
    BITMAPINFO  	bmi;
    bmi.bmiHeader.biSize 		= sizeof(BITMAPINFOHEADER);
    bmi.bmiHeader.biWidth 		= w;
    bmi.bmiHeader.biHeight 		= h;
    bmi.bmiHeader.biPlanes 		= 1;
    bmi.bmiHeader.biBitCount 		= 32;
    bmi.bmiHeader.biCompression 	= BI_RGB;
    bmi.bmiHeader.biSizeImage 		= 0;
    bmi.bmiHeader.biXPelsPerMeter 	= 0;
    bmi.bmiHeader.biYPelsPerMeter 	= 0;
    bmi.bmiHeader.biClrUsed 		= 0;
    bmi.bmiHeader.biClrImportant 	= 0;

    SetMapMode		(hdc,	MM_ANISOTROPIC	);
    SetStretchBltMode(hdc,	HALFTONE		);
    int err 		= StretchDIBits	(       hdc,
                                                r.x1, r.y1, (r.x2-r.x1), (r.y2-r.y1),
    					        0, 0, w, h, data, &bmi,
                    				DIB_RGB_COLORS, SRCCOPY);
    if (err==GDI_ERROR){
    	Log("!StretchDIBits - Draw failed.");
    }
}
コード例 #18
0
ファイル: rlefile.c プロジェクト: mingpen/OpenNT
BOOL RleFile_Draw(RLEFILE *prle, HDC hdc, int iFrame, int x, int y)
{
    BOOL f;

    if (prle == NULL || prle->pMovie == NULL)
        return FALSE;

    if (prle->hpal)
    {
        SelectPalette(hdc, prle->hpal, FALSE);
        RealizePalette(hdc);
    }

    if (f = RleFile_Seek(prle, iFrame))
    {
        if (prle->cbFrame > 0)
        {
            StretchDIBits(hdc,
                    x, y, prle->Width, prle->Height,
                    0, 0, prle->Width, prle->Height,
                    prle->pFrame, (LPBITMAPINFO)&prle->bi,
                    DIB_RGB_COLORS, SRCCOPY);
        }
    }

    return f;
}
コード例 #19
0
ファイル: mciqtz.c プロジェクト: GranPC/wine
/******************************************************************************
 *              MCIAVI_mciUpdate            [internal]
 */
static DWORD MCIQTZ_mciUpdate(UINT wDevID, DWORD dwFlags, LPMCI_DGV_UPDATE_PARMS lpParms)
{
    WINE_MCIQTZ *wma;
    DWORD res = 0;

    TRACE("%04x, %08x, %p\n", wDevID, dwFlags, lpParms);

    if(!lpParms)
        return MCIERR_NULL_PARAMETER_BLOCK;

    wma = MCIQTZ_mciGetOpenDev(wDevID);
    if (!wma)
        return MCIERR_INVALID_DEVICE_ID;

    if (dwFlags & MCI_DGV_UPDATE_HDC) {
        LONG state, size;
        BYTE *data;
        BITMAPINFO *info;
        HRESULT hr;
        RECT src, dest;
        LONG visible = OATRUE;

        res = MCIERR_INTERNAL;
        IMediaControl_GetState(wma->pmctrl, -1, &state);
        if (state == State_Running)
            return MCIERR_UNSUPPORTED_FUNCTION;
        /* If in stopped state, nothing has been drawn to screen
         * moving to pause, which is needed for the old dib renderer, will result
         * in a single frame drawn, so hide the window here */
        IVideoWindow_get_Visible(wma->vidwin, &visible);
        if (wma->parent)
            IVideoWindow_put_Visible(wma->vidwin, OAFALSE);
        /* FIXME: Should we check the original state and restore it? */
        IMediaControl_Pause(wma->pmctrl);
        IMediaControl_GetState(wma->pmctrl, -1, &state);
        if (FAILED(hr = IBasicVideo_GetCurrentImage(wma->vidbasic, &size, NULL))) {
            WARN("Could not get image size (hr = %x)\n", hr);
            goto out;
        }
        data = HeapAlloc(GetProcessHeap(), 0, size);
        info = (BITMAPINFO*)data;
        IBasicVideo_GetCurrentImage(wma->vidbasic, &size, (LONG*)data);
        data += info->bmiHeader.biSize;

        IBasicVideo_GetSourcePosition(wma->vidbasic, &src.left, &src.top, &src.right, &src.bottom);
        IBasicVideo_GetDestinationPosition(wma->vidbasic, &dest.left, &dest.top, &dest.right, &dest.bottom);
        StretchDIBits(lpParms->hDC,
              dest.left, dest.top, dest.right + dest.left, dest.bottom + dest.top,
              src.left, src.top, src.right + src.left, src.bottom + src.top,
              data, info, DIB_RGB_COLORS, SRCCOPY);
        HeapFree(GetProcessHeap(), 0, data);
        res = 0;
out:
        if (wma->parent)
            IVideoWindow_put_Visible(wma->vidwin, visible);
    }
    else if (dwFlags)
        FIXME("Unhandled flags %x\n", dwFlags);
    return res;
}
コード例 #20
0
ファイル: PreViewView.cpp プロジェクト: kooyou/screen_capture
void CPreViewView::OnDraw(CDC* pDC)
{
	CDocument* pDoc = GetDocument();
	// TODO: 在此添加绘制代码

	BITMAPINFO bitmapInfo = { 0 };


	bitmapInfo.bmiHeader.biSize			= sizeof(BITMAPINFOHEADER);
	bitmapInfo.bmiHeader.biWidth		= m_bmpRect.Width();
	bitmapInfo.bmiHeader.biHeight		= -(int)m_bmpRect.Height();
	bitmapInfo.bmiHeader.biCompression	= BI_RGB;
	bitmapInfo.bmiHeader.biPlanes		= 1;
	bitmapInfo.bmiHeader.biBitCount		= 24;

	SetStretchBltMode(pDC->GetSafeHdc(), COLORONCOLOR);
	StretchDIBits(pDC->GetSafeHdc(), 
		m_bmpRect.left,
		m_bmpRect.top,
		m_bmpRect.Width(),//	DestWidth
		m_bmpRect.Height(),//	DestHeight
		0,
		0,						//	XSrc, YSrc
		m_bmpRect.Width(),
		m_bmpRect.Height(),	//	SrcWidth, SrcHeight, 
		m_bmpBuf,
		&bitmapInfo, 
		DIB_RGB_COLORS, 
		SRCCOPY);
}
コード例 #21
0
void BitmapControl::OnDraw(CDC* dc)
{
  RECT r;
  GetClientRect(&r);
  int w1 = r.right - r.left;
  int h1 = r.bottom - r.top;
  CDC memDC;
  memDC.CreateCompatibleDC(dc);
  if(!stretch) {
    if(w > w1)
      w1 = w;
    if(h > h1)
      h1 = h;
  }
  CBitmap bitmap, *pOldBitmap;
  bitmap.CreateCompatibleBitmap(dc, w1, h1);
  pOldBitmap = memDC.SelectObject(&bitmap);
  if(stretch) {
    bmpInfo->bmiHeader.biWidth = w;
    bmpInfo->bmiHeader.biHeight = -h;

    StretchDIBits(memDC.GetSafeHdc(),
                  0,
                  0,
                  w1,
                  h1,
                  0,
                  0,
                  w,
                  h,
                  data,
                  bmpInfo,
                  DIB_RGB_COLORS,
                  SRCCOPY);
  } else {
    FillOutsideRect(&memDC, CBrush::FromHandle(GetSysColorBrush(COLOR_BTNFACE)));

    bmpInfo->bmiHeader.biWidth = w;
    bmpInfo->bmiHeader.biHeight = -h;
    SetDIBitsToDevice(memDC.GetSafeHdc(),
                      0,
                      0,
                      w,
                      h,
                      0,
                      0,
                      0,
                      h,
                      data,
                      bmpInfo,
                      DIB_RGB_COLORS);
  }

  dc->BitBlt(0,0,w1,h1,
             &memDC,0,0,SRCCOPY);
  memDC.SelectObject(pOldBitmap);

  bitmap.DeleteObject();
  memDC.DeleteDC();
}
コード例 #22
0
internal void Win32DisplayBufferInWindow(win32_offscreen_buffer *Buffer, HDC DeviceContext, int WindowWidth, int WindowHeight) {
	if ((WindowWidth >= Buffer->Width * 2) && (WindowHeight >= Buffer->Height * 2)) {
		StretchDIBits(DeviceContext, 0, 0, Buffer->Width * 2, Buffer->Height * 2, 0, 0, Buffer->Width, Buffer->Height, Buffer->Memory, &Buffer->Info, DIB_RGB_COLORS, SRCCOPY);
	}
	else {
		int OffsetX = 10;
		int OffsetY = 10;

		PatBlt(DeviceContext, 0, 0, WindowWidth, OffsetY, BLACKNESS);
		PatBlt(DeviceContext, 0, OffsetY + Buffer->Height, WindowWidth, WindowHeight, BLACKNESS);
		PatBlt(DeviceContext, 0, 0, OffsetX, WindowHeight, BLACKNESS);
		PatBlt(DeviceContext, OffsetX + Buffer->Width, 0, WindowWidth, WindowHeight, BLACKNESS);

		StretchDIBits(DeviceContext, OffsetX, OffsetY, Buffer->Width, Buffer->Height, 0, 0, Buffer->Width, Buffer->Height, Buffer->Memory, &Buffer->Info, DIB_RGB_COLORS, SRCCOPY);
	}
}
コード例 #23
0
ファイル: imageview.cpp プロジェクト: b2kguga/CodesAndNotes
BOOL StretchJPEG(HDC hDC, int x, int y, int w, int h, void * pJPEGImage, unsigned nJPEGSize, int width, int height)
{
	DWORD esc = CHECKJPEGFORMAT;
	if ( ExtEscape(hDC, QUERYESCSUPPORT, sizeof(esc), (char *) &esc, 0, 0) <=0 )
		return FALSE;
	
	DWORD rslt = 0;
	if ( ExtEscape(hDC, CHECKJPEGFORMAT, nJPEGSize, (char *) pJPEGImage, sizeof(rslt), (char *) &rslt) <=0 )
		return FALSE;

	if ( rslt!=1 )
		return FALSE;

	BITMAPINFO bmi;

    memset(&bmi, 0, sizeof(bmi));
    bmi.bmiHeader.biSize        = sizeof(BITMAPINFOHEADER);
    bmi.bmiHeader.biWidth       =   width;
    bmi.bmiHeader.biHeight      = - height; // top-down image
    bmi.bmiHeader.biPlanes      = 1;
    bmi.bmiHeader.biBitCount    = 0;
    bmi.bmiHeader.biCompression = BI_JPEG;
    bmi.bmiHeader.biSizeImage   = nJPEGSize;

	return GDI_ERROR != StretchDIBits(hDC, x, y, w, h, 0, 0, width, height, pJPEGImage, & bmi, DIB_RGB_COLORS, SRCCOPY);
}
コード例 #24
0
//! presents a surface in the client area
bool CIrrDeviceWin32::present(video::IImage* image, void* windowId, core::rect<s32>* src)
{
	HWND hwnd = HWnd;
	if ( windowId )
		hwnd = reinterpret_cast<HWND>(windowId);

	HDC dc = GetDC(hwnd);

	if ( dc )
	{
		RECT rect;
		GetClientRect(hwnd, &rect);
		const void* memory = (const void *)image->lock();

		BITMAPV4HEADER bi;
		ZeroMemory (&bi, sizeof(bi));
		bi.bV4Size          = sizeof(BITMAPINFOHEADER);
		bi.bV4BitCount      = (WORD)image->getBitsPerPixel();
		bi.bV4Planes        = 1;
		bi.bV4Width         = image->getDimension().Width;
		bi.bV4Height        = -image->getDimension().Height;
		bi.bV4V4Compression = BI_BITFIELDS;
		bi.bV4AlphaMask     = image->getAlphaMask();
		bi.bV4RedMask       = image->getRedMask();
		bi.bV4GreenMask     = image->getGreenMask();
		bi.bV4BlueMask      = image->getBlueMask();

		if ( src )
		{
			StretchDIBits(dc, 0,0, rect.right, rect.bottom,
					src->UpperLeftCorner.X, src->UpperLeftCorner.Y,
					src->getWidth(), src->getHeight(),
					memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY);
		}
		else
		{
			StretchDIBits(dc, 0,0, rect.right, rect.bottom,
					0, 0, image->getDimension().Width, image->getDimension().Height,
					memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY);
		}

		image->unlock();

		ReleaseDC(hwnd, dc);
	}
	return true;
}
コード例 #25
0
//ÅжÏBMP»òJPG²¢ÏÔʾͼÏñ
void CYangLiuImageProcess::ImageDisplay(CDC * pDC, double dZoom)
{
	IplImage *image = (IplImage*)voidImage;
	if (m_nOpenMode == 1) //BMP
	{
		StretchDIBits(pDC->m_hDC, 0, 0,
			int(dZoom*imageWidth + 0.5), int(dZoom* imageHeight + 0.5), 0, 0, imageWidth, imageHeight,
			m_pBits, lpbmi, DIB_RGB_COLORS, SRCCOPY);
	}
	if (m_nOpenMode == 2) //JPG
	{
		StretchDIBits(pDC->m_hDC, 0, 0, int(dZoom*image->width + 0.5), int(dZoom*image->height + 0.5),
			0, image->height, image->width, -image->height,
			image->imageData, lpbmi,
			DIB_RGB_COLORS, SRCCOPY);
	}
}
コード例 #26
0
//----bitmap到screen位块传送---------------------------------------------------
//功能: 把一个位图中的一个矩形区域传送到另一个区域,两个位图的像素格式必须相同。
//      源和目的位图可以相同
//参数: dst_rect,目标矩形
//      src_bitmap,源位图
//      xsrc,ysrc,源位图中被传送的区域左上角坐标
//返回: true=成功,false=失败
//-----------------------------------------------------------------------------
bool_t __lcd_bm_to_screen(struct tagRectangle *dst_rect,
                struct tagRectBitmap *src_bitmap,s32 xsrc,s32 ysrc)
{
#if 1
    StretchDIBits (lcd_hdc,   dst_rect->left*X_SCALE, dst_rect->top*Y_SCALE,
                            (dst_rect->right - dst_rect->left)*X_SCALE,
                            (dst_rect->bottom - dst_rect->top)*Y_SCALE,
                            xsrc,ysrc + dst_rect->bottom - dst_rect->top,
                            dst_rect->right - dst_rect->left,
                            -(dst_rect->bottom - dst_rect->top),
                            pg_frame_buffer,lcdbmi,DIB_RGB_COLORS,SRCCOPY) ;
#else
    StretchDIBits (lcd_hdc,    0, 0,320, 240,
               0, 240, 320,-240,pg_frame_buffer,lcdbmi,DIB_RGB_COLORS,SRCCOPY) ;
#endif
    return true;
}
コード例 #27
0
// Correlates to Win32UpdateWindow from videos
internal void DisplayBufferInWindow(HDC deviceContext, const window_dimensions& window, offscreen_buffer& buffer)
{
	StretchDIBits(deviceContext,
		0, 0, window.width, window.height,
		0, 0, buffer.width, buffer.height,
		buffer.memory, &buffer.info,
		DIB_RGB_COLORS, SRCCOPY);
}
コード例 #28
0
ファイル: pngdib.c プロジェクト: xmoeproject/X-moe
static unsigned char* uncompress_dib(LPBITMAPINFO lpbmi1, int infosize, void *lpbits1)
{
	LPBITMAPINFOHEADER lpdib2;
	unsigned char *lpbits2;
	void *whatever;
	int linesize, bitssize;
	HBITMAP hb;
	HDC hdc;
	HGDIOBJ rvgdi;
	int rvi;
	int width,height;
	LPBITMAPINFOHEADER lpdib1;

	lpdib1=(LPBITMAPINFOHEADER)lpbmi1;
	width=lpdib1->biWidth;
	height=lpdib1->biHeight;

	linesize= (((width * lpdib1->biBitCount)+31)/32)*4;
	bitssize= linesize*height;

	lpdib2= (LPBITMAPINFOHEADER)malloc(infosize);
	if(!lpdib2) return NULL;

	//  create a header for the new uncompressed DIB
	CopyMemory((void*)lpdib2,(void*)lpdib1,infosize);
	lpdib2->biCompression=BI_RGB;
	lpdib2->biSizeImage=0;

	lpbits2= (unsigned char*)malloc(bitssize);
	if(!lpbits2) { free((void*)lpdib2); return NULL; }


	// Windows bitmap handling functions are not exactly convenient,
	// especially when trying to deal with DIBs. Every function wants
	// to convert them into DDBs. We have to play stupid games and
	// convert back and forth. This probably uses too much memory,
	// and I'm not 100% sure it is exactly correct, but it seems to
	// work for me.

	hb=CreateDIBSection(NULL,(LPBITMAPINFO)lpdib2,DIB_RGB_COLORS,&whatever,NULL,0);

	hdc=CreateCompatibleDC(NULL);
	rvgdi=SelectObject(hdc,hb);
	//SetStretchBltMode(hdc,COLORONCOLOR);
	rvi=StretchDIBits(hdc,
		0,0,width,height,
		0,0,width,height,
		lpbits1, (LPBITMAPINFO)lpdib1,
		DIB_RGB_COLORS,SRCCOPY);
	rvi=GetDIBits(hdc,hb,0,height, (LPVOID)lpbits2,
		(LPBITMAPINFO)lpdib2,DIB_RGB_COLORS);

	DeleteDC(hdc);
	DeleteObject(hb);
	free((void*)lpdib2);

	return lpbits2;
}
コード例 #29
0
//
//  函数: WndProc_lcd(HWND, unsigned, WORD, LONG)
//
//  目的: 处理主窗口的消息。
//
LRESULT CALLBACK WndProc_lcd(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    PAINTSTRUCT         ps ;
    switch (message)
    {
        case WM_PAINT:
            BeginPaint (hWnd, &ps) ;
            StretchDIBits (lcd_hdc,    0, 0,cn_lcd_window_xsize, cn_lcd_window_ysize,
                       0, LCD_YSIZE, LCD_XSIZE,-LCD_YSIZE,pg_frame_buffer,lcdbmi,DIB_RGB_COLORS,SRCCOPY) ;
            EndPaint (hWnd, &ps) ;
            break;
        case WM_MOVE:
            StretchDIBits (lcd_hdc,    0, 0,cn_lcd_window_xsize, cn_lcd_window_ysize,
               0, LCD_YSIZE, LCD_XSIZE,-LCD_YSIZE,pg_frame_buffer,lcdbmi,DIB_RGB_COLORS,SRCCOPY) ;
            GetWindowRect(hWnd, &tg_WindowRect);
            MoveWindow(tg_keyboard_wnd, tg_WindowRect.left+s32g_window_width + 5,
                       tg_WindowRect.top, s32g_window_width, s32g_window_height,
                       true);
            break ;
        case WM_ACTIVATE:
            StretchDIBits (lcd_hdc,    0, 0,cn_lcd_window_xsize, cn_lcd_window_ysize,
               0, LCD_YSIZE, LCD_XSIZE,-LCD_YSIZE,pg_frame_buffer,lcdbmi,DIB_RGB_COLORS,SRCCOPY) ;

            break ;
        case WM_LBUTTONDOWN:
            touch_x = LOWORD(lParam);
            touch_y = HIWORD(lParam);
            touch_z = 1;
            touched = true;
            break;
        case WM_LBUTTONUP:
            touch_x = LOWORD(lParam);
            touch_y = HIWORD(lParam);
            touch_z = 0;
            touched = false;
            break;
        case WM_MOUSEMOVE:
            touch_x = LOWORD(lParam);
            touch_y = HIWORD(lParam);
            break;
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
コード例 #30
0
ファイル: main.c プロジェクト: MichaelAf/Life
void Display()
{
	StretchDIBits(DeviceContext,
		0, 0, GlobalBackbuffer.Width, GlobalBackbuffer.Height,
		0, 0, GlobalBackbuffer.Width, GlobalBackbuffer.Height,
		GlobalBackbuffer.Memory,
		&GlobalBackbuffer.Info,
		DIB_RGB_COLORS, SRCCOPY);
};