コード例 #1
3
ファイル: acllib.c プロジェクト: Gnnng/LaserTank
void putImageScale(ACL_Image *pImage,int x,int y,int width,int height)
{
	HDC hbitmapdc;
	ACL_ASSERT_BEGIN_PAINT;
	hbitmapdc = CreateCompatibleDC(g_hmemdc);
	SelectObject(hbitmapdc, pImage->hbitmap);
	if(width == -1)width = pImage->width;
	if(height == -1)height = pImage->height;
	StretchBlt( g_hmemdc,x,y,width,height,hbitmapdc,0,0,pImage->width,pImage->height,SRCCOPY);
	DeleteDC(hbitmapdc);
}
コード例 #2
0
ファイル: v4l.c プロジェクト: bpowers/wine
static void Resize(const Capture * capBox, LPBYTE output, const BYTE *input)
{
    /* the whole image needs to be reversed,
       because the dibs are messed up in windows */
    if (!capBox->swresize)
    {
        int depth = capBox->bitDepth / 8;
        int inoffset = 0, outoffset = capBox->height * capBox->width * depth;
        int ow = capBox->width * depth;
        while (outoffset > 0)
        {
            int x;
            outoffset -= ow;
            for (x = 0; x < ow; x++)
                output[outoffset + x] = input[inoffset + x];
            inoffset += ow;
        }
    }
    else
    {
        HDC dc_s, dc_d;
        HBITMAP bmp_s, bmp_d;
        int depth = capBox->bitDepth / 8;
        int inoffset = 0, outoffset = (capBox->outputheight) * capBox->outputwidth * depth;
        int ow = capBox->outputwidth * depth;
        LPBYTE myarray;

        /* FIXME: Improve software resizing: add error checks and optimize */

        myarray = CoTaskMemAlloc(capBox->outputwidth * capBox->outputheight * depth);
        dc_s = CreateCompatibleDC(NULL);
        dc_d = CreateCompatibleDC(NULL);
        bmp_s = CreateBitmap(capBox->width, capBox->height, 1, capBox->bitDepth, input);
        bmp_d = CreateBitmap(capBox->outputwidth, capBox->outputheight, 1, capBox->bitDepth, NULL);
        SelectObject(dc_s, bmp_s);
        SelectObject(dc_d, bmp_d);
        StretchBlt(dc_d, 0, 0, capBox->outputwidth, capBox->outputheight,
                   dc_s, 0, 0, capBox->width, capBox->height, SRCCOPY);
        GetBitmapBits(bmp_d, capBox->outputwidth * capBox->outputheight * depth, myarray);
        while (outoffset > 0)
        {
            int i;

            outoffset -= ow;
            for (i = 0; i < ow; i++)
                output[outoffset + i] = myarray[inoffset + i];
            inoffset += ow;
        }
        CoTaskMemFree(myarray);
        DeleteObject(dc_s);
        DeleteObject(dc_d);
        DeleteObject(bmp_s);
        DeleteObject(bmp_d);
    }
}
コード例 #3
0
ファイル: ddutil.cpp プロジェクト: galek/xform-megatexture
//-----------------------------------------------------------------------------
// Name: CSurface::DrawBitmap()
// Desc: Draws a bitmap over an entire DirectDrawSurface, stretching the 
//       bitmap if nessasary
//-----------------------------------------------------------------------------
HRESULT CSurface::DrawBitmap( HBITMAP hBMP, 
                              DWORD dwBMPOriginX, DWORD dwBMPOriginY, 
                              DWORD dwBMPWidth, DWORD dwBMPHeight )
{
    HDC            hDCImage;
    HDC            hDC;
    BITMAP         bmp;
    DDSURFACEDESC2 ddsd;
    HRESULT        hr;

    if( hBMP == NULL || m_pdds == NULL )
        return E_INVALIDARG;

    // Make sure this surface is restored.
    if( FAILED( hr = m_pdds->Restore() ) )
        return hr;

    // Get the surface.description
    ddsd.dwSize  = sizeof(ddsd);
    m_pdds->GetSurfaceDesc( &ddsd );

    if( ddsd.ddpfPixelFormat.dwFlags == DDPF_FOURCC )
        return E_NOTIMPL;

    // Select bitmap into a memoryDC so we can use it.
    hDCImage = CreateCompatibleDC( NULL );
    if( NULL == hDCImage )
        return E_FAIL;

    SelectObject( hDCImage, hBMP );

    // Get size of the bitmap
    GetObject( hBMP, sizeof(bmp), &bmp );

    // Use the passed size, unless zero
    dwBMPWidth  = ( dwBMPWidth  == 0 ) ? bmp.bmWidth  : dwBMPWidth;     
    dwBMPHeight = ( dwBMPHeight == 0 ) ? bmp.bmHeight : dwBMPHeight;

    // Stretch the bitmap to cover this surface
    if( FAILED( hr = m_pdds->GetDC( &hDC ) ) )
        return hr;

    StretchBlt( hDC, 0, 0, 
                ddsd.dwWidth, ddsd.dwHeight, 
                hDCImage, dwBMPOriginX, dwBMPOriginY,
                dwBMPWidth, dwBMPHeight, SRCCOPY );

    if( FAILED( hr = m_pdds->ReleaseDC( hDC ) ) )
        return hr;

    DeleteDC( hDCImage );

    return S_OK;
}
コード例 #4
0
ファイル: mirrorimage.cpp プロジェクト: rauls/mirrorimage
void CopyMirrored( HDC hdcDest, HDC hdcSrc, RECT drc )
{
	int border = GetSystemMetrics( SM_CXBORDER )+8;

	StretchBlt( hdcDest,	
				0,0, 
				(drc.right-drc.left),	(drc.bottom-drc.top),
				hdcSrc,		
				src_w-border,0, 
				-src_w,	src_h, SRCCOPY );
}
コード例 #5
0
ファイル: ImgBits.cpp プロジェクト: hufuman/xindows
// Used to StretchBlt an image whose bits are offset from the coordinates by the given amount
void CImgBits::StretchBltOffset(HDC hdc, RECT* prcDst, RECT* prcSrc, LONG xOffset, LONG yOffset, DWORD dwRop, DWORD dwFlags)
{
    RECT rcSrcOffset;

    rcSrcOffset.left    = prcSrc->left    - xOffset;
    rcSrcOffset.top     = prcSrc->top     - yOffset;
    rcSrcOffset.right   = prcSrc->right   - xOffset;
    rcSrcOffset.bottom  = prcSrc->bottom  - yOffset;

    StretchBlt(hdc, prcDst, &rcSrcOffset, dwRop, dwFlags);
}
コード例 #6
0
ファイル: vdev-gdi.cpp プロジェクト: rockcarry/ffnes
static void vdev_gdi_enqueue(void *ctxt)
{
    DEVGDICTXT *c = (DEVGDICTXT*)ctxt;
    RECT        rect;

    GetClientRect(c->hwnd, &rect);
    if (memcmp(&c->rtlast, &rect, sizeof(RECT))) {
        memcpy(&c->rtlast, &rect, sizeof(RECT));

        int x, y, sw, sh, dw, dh;
        sw = dw = rect.right;
        sh = dh = rect.bottom;

        //++ keep picture w/h ratio when stretching ++//
        if (c->width * sh > c->height * sw) {
            dh = dw * c->height / c->width;
        } else {
            dw = dh * c->width / c->height;
        }
        x = (sw - dw) / 2;
        y = (sh - dh) / 2;
        //-- keep picture w/h ratio when stretching --//

        c->rtview.left   = x;
        c->rtview.top    = y;
        c->rtview.right  = x + dw;
        c->rtview.bottom = y + dh;

        RECT rect1, rect2, rect3, rect4;
        rect1.left = 0;    rect1.top = 0;    rect1.right = sw; rect1.bottom = y;
        rect2.left = 0;    rect2.top = y;    rect2.right = x;  rect2.bottom = y+dh;
        rect3.left = x+dw; rect3.top = y;    rect3.right = sw; rect3.bottom = y+dh;
        rect4.left = 0;    rect4.top = y+dh; rect4.right = sw; rect4.bottom = sh;
        InvalidateRect(c->hwnd, &rect1, TRUE);
        InvalidateRect(c->hwnd, &rect2, TRUE);
        InvalidateRect(c->hwnd, &rect3, TRUE);
        InvalidateRect(c->hwnd, &rect4, TRUE);
    }

    if (c->texttick > GetTickCount()) {
        SetBkMode   (c->hdcsrc, TRANSPARENT);
        SetTextColor(c->hdcsrc, RGB(255,255,255));
        TextOut(c->hdcsrc, c->textposx, c->textposy, c->textstr, (int)strlen(c->textstr));
    } else {
        c->priority = 0;
    }

    // bitblt picture to window witch stretching
    StretchBlt(c->hdcdst, c->rtview.left, c->rtview.top,
               c->rtview.right - c->rtview.left,
               c->rtview.bottom - c->rtview.top,
               c->hdcsrc, 0, 0, c->width, c->height, SRCCOPY);
}
コード例 #7
0
void StretchBitmap(BUFFER &pBuffer, int pic, int screenx, int screeny, int width, int height, int imagex, int imagey, int imagew, int imageh)
{
	//select bitmap handle
	SelectObject(pBuffer.hdcBitmap, tiles[pic]);

	//blit bitmap into backbuffer
	StretchBlt(pBuffer.hdcBack, screenx, screeny, width, height, 
				   pBuffer.hdcBitmap, imagex, imagey, imagew, imageh, SRCCOPY);

	//select old handle to clean up
	SelectObject(pBuffer.hdcBitmap, pBuffer.hOldBitmap);
}
コード例 #8
0
ファイル: wing32.c プロジェクト: lucianolorenti/wine
/***********************************************************************
 *           WinGStretchBlt   ([email protected])
 */
BOOL WINAPI WinGStretchBlt( HDC hdcDst, INT xDst, INT yDst, INT widthDst, INT heightDst,
                            HDC hdcSrc, INT xSrc, INT ySrc, INT widthSrc, INT heightSrc )
{
    INT old_blt_mode;
    BOOL ret;

    old_blt_mode = SetStretchBltMode( hdcDst, COLORONCOLOR );
    ret = StretchBlt( hdcDst, xDst, yDst, widthDst, heightDst,
                      hdcSrc, xSrc, ySrc, widthSrc, heightSrc, SRCCOPY );
    SetStretchBltMode( hdcDst, old_blt_mode );
    return ret;
}
コード例 #9
0
ファイル: DIB.cpp プロジェクト: codebachi/ProjectDirectX
// CDIB <- HBITMAP
void CDIB::Draw(
	int dx, int dy, int dw, int dh, 
	HBITMAP bmp, int sx, int sy, int sw, int sh
) {
	HDC null_dc=::GetDC(NULL);
	HDC bmp_dc=CreateCompatibleDC(null_dc);
	HGDIOBJ obj=SelectObject(bmp_dc, bmp);
	StretchBlt(DC, dx, dy, dw, dh, bmp_dc, sx, sy, sw, sh, SRCCOPY);
	SelectObject(bmp_dc, obj);
	DeleteDC(bmp_dc);
	ReleaseDC(NULL, null_dc);
}
コード例 #10
0
ファイル: BBRoot.cpp プロジェクト: Jmos/bbclean-xzero450
static HBITMAP read_bitmap(const char* path, bool delete_after)
{
    HWND hwnd_desk = GetDesktopWindow();
    HDC hdc_desk = GetDC(hwnd_desk);
    BITMAP bm;
#if 0
    HBITMAP bmp = (HBITMAP)LoadImage(NULL, path, IMAGE_BITMAP, 0,0, LR_LOADFROMFILE);
#else
    HBITMAP bmp = NULL;
    FILE *fp=fopen(path, "rb");
    if (fp)
    {
        BITMAPFILEHEADER hdr;
        fread(&hdr, 1, sizeof(hdr), fp);
        if (0x4D42 == hdr.bfType)
        {
            BITMAPINFOHEADER bih, *pbih; int CU, s; void *lpBits;
            fread(&bih, 1, sizeof(bih), fp);
            CU = bih.biClrUsed * sizeof(RGBQUAD);
            pbih = (PBITMAPINFOHEADER)m_alloc(bih.biSize + CU);
            memmove(pbih, &bih, bih.biSize);
            fread(&((BITMAPINFO*)pbih)->bmiColors, 1, CU, fp);
            s = hdr.bfSize - hdr.bfOffBits;
            lpBits = m_alloc(s);
            fseek(fp, hdr.bfOffBits, SEEK_SET);
            fread(lpBits, 1, s, fp);
            bmp = CreateDIBitmap(hdc_desk, pbih, CBM_INIT, lpBits, (LPBITMAPINFO)pbih, DIB_RGB_COLORS);
            m_free(lpBits);
            m_free(pbih);
        }
        fclose(fp);
    }
#endif
    if (bmp && GetObject(bmp, sizeof bm, &bm))
    {
        // convert in any case (20ms), bc if it's compatible, it's faster to paint.
        HDC hdc_old = CreateCompatibleDC(hdc_desk);
        HGDIOBJ old_bmp = SelectObject(hdc_old, bmp);
        HDC hdc_new = CreateCompatibleDC(hdc_desk);
        HBITMAP bmp_new = CreateCompatibleBitmap(hdc_desk, VScreenWidth, VScreenHeight);
        SelectObject(hdc_new, bmp_new);
        StretchBlt(hdc_new, 0, 0, VScreenWidth, VScreenHeight, hdc_old, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
        DeleteDC(hdc_new);
        DeleteObject(SelectObject(hdc_old, old_bmp));
        DeleteDC(hdc_old);
        bmp = bmp_new;
    }

    ReleaseDC(hwnd_desk, hdc_desk);
    if (delete_after)
        DeleteFile(path);
    return bmp;
}
コード例 #11
0
ファイル: DDB.cpp プロジェクト: b2kguga/CodesAndNotes
BOOL KDDBMask::ApplyMask(HDC hDC, int nX, int nY, int nWidth, int nHeight, DWORD rop)
{
	COLORREF oldFore = SetTextColor(hDC, RGB(0, 0, 0));			// Foreground Black
	COLORREF oldBack = SetBkColor(hDC,   RGB(255, 255, 255));	// Background White

	BOOL rslt = StretchBlt(hDC, nX, nY, nWidth, nHeight, m_hMemDC, 0, 0, m_nMaskWidth, m_nMaskHeight, rop);

	SetTextColor(hDC, oldFore);
	SetBkColor(hDC,   oldBack);

	return rslt;
}
コード例 #12
0
ファイル: SysPal3.c プロジェクト: AaronFae/VimProject
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     static HBITMAP hBitmap ;
     static int     cxClient, cyClient ;
     BYTE           bits [256] ;
     HDC            hdc, hdcMem ;
     int            i ;
     PAINTSTRUCT    ps ;

     switch (message)
     {
     case WM_CREATE:
          if (!CheckDisplay (hwnd))
               return -1 ;

          for (i = 0 ; i < 256 ; i++)
               bits [i] = i ;
          
          hBitmap = CreateBitmap (16, 16, 1, 8, &bits) ;
          return 0 ;
                                                        
     case WM_DISPLAYCHANGE:
          if (!CheckDisplay)
               DestroyWindow (hwnd) ;

          return 0 ;

     case WM_SIZE:
          cxClient = LOWORD (lParam) ;
          cyClient = HIWORD (lParam) ;
          return 0 ;

     case WM_PAINT:
          hdc = BeginPaint (hwnd, &ps) ;

          hdcMem = CreateCompatibleDC (hdc) ;
          SelectObject (hdcMem, hBitmap) ;

          StretchBlt (hdc,    0, 0, cxClient, cyClient,
                      hdcMem, 0, 0, 16, 16, SRCCOPY) ;

          DeleteDC (hdcMem) ;
          EndPaint (hwnd, &ps) ;
          return 0 ;

     case WM_DESTROY:
          DeleteObject (hBitmap) ;
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}
コード例 #13
0
ファイル: main.cpp プロジェクト: HP-Enterprise/Training
void OnPaint(HWND hwnd)
{
    PAINTSTRUCT ps;
    RECT rc;
    HDC hdc = BeginPaint(hwnd, &ps);
    GetClientRect(hwnd, &rc);
    if (g_hdcMem != NULL) {
        SetStretchBltMode(hdc, HALFTONE);
        SetBrushOrgEx(hdc, 0, 0, NULL);
        StretchBlt(hdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, g_hdcMem, 0, 0, g_szBmp.cx, g_szBmp.cy, SRCCOPY);
    }
    EndPaint(hwnd, &ps);
}
コード例 #14
0
ファイル: myclasses.cpp プロジェクト: MOROZIL-nic/craft
void StretchDrawTo(HDC handle,LPRECT rect,float Angle)
        {
        if(Angle==0)
                {
                StretchBlt(handle,rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top,
                   Canvas->Handle,0,0,Width,Height,SRCCOPY);
                }else
                {
                Angle=Angle*0.017453292;
                Angle=-Angle;
                XFORM Matrix;
                SetGraphicsMode(handle, GM_ADVANCED);
                Matrix.eM11 = 1;
                Matrix.eM12 = 0;
                Matrix.eM21 = 0;
                Matrix.eM22 = 1;
                Matrix.eDx = -rect->left;
                Matrix.eDy = -rect->top;
                SetWorldTransform(handle, &Matrix);
                Matrix.eM11 = cos(Angle);
                Matrix.eM12 = sin(Angle);
                Matrix.eM21 = -sin(Angle);
                Matrix.eM22 = cos(Angle);
                Matrix.eDx = 0;
                Matrix.eDy = 0;
                ModifyWorldTransform(handle, &Matrix, MWT_RIGHTMULTIPLY);
                Matrix.eM11 = 1;
                Matrix.eM12 = 0;
                Matrix.eM21 = 0;
                Matrix.eM22 = 1;
                Matrix.eDx = rect->left;
                Matrix.eDy = rect->top;
                ModifyWorldTransform(handle, &Matrix, MWT_RIGHTMULTIPLY);

                StretchBlt(handle,rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top,
                   Canvas->Handle,0,0,Width,Height,SRCCOPY);
                ModifyWorldTransform(handle, &Matrix, MWT_IDENTITY);
                }
        }
コード例 #15
0
ファイル: GDIDrawer.cpp プロジェクト: yuki12/krkrz
void tTVPDrawer_GDIDoubleBuffering::Show()
{
	if(TargetDC && OffScreenDC && ShouldShow)
	{
		// オフスクリーンビットマップを TargetDC に転送する
		if(DestWidth == SrcWidth && DestHeight == SrcHeight)
		{
			// 拡大・縮小は必要ない
			BitBlt(TargetDC,
				DestLeft,
				DestTop,
				DestWidth,
				DestHeight,
				OffScreenDC,
				0,
				0,
				SRCCOPY);
		}
		else
		{
			// 拡大・縮小が必要
			if(TVPZoomInterpolation)
				SetStretchBltMode(TargetDC, HALFTONE);
			else
				SetStretchBltMode(TargetDC, COLORONCOLOR);
			SetBrushOrgEx(TargetDC, 0, 0, NULL);

			StretchBlt(TargetDC,
				DestLeft,
				DestTop,
				DestWidth,
				DestHeight,
				OffScreenDC,
				0,
				0,
				SrcWidth,
				SrcHeight,
				SRCCOPY);
		}

		if(InBenchMark)
		{
			// 画面からの読み出しを行う関数を実行する
			// こうしないと StrechBlt などはコマンドキューにたたき込まれる
			// だけで、実際の描画を待たずに帰る可能性がある。
			(void)GetPixel(TargetDC, DestLeft + DestWidth / 2, DestTop + DestHeight / 2);
		}

		ShouldShow = false;
	}
}
コード例 #16
0
void CMyDrawPictureClass::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// TODO: 在此处添加消息处理程序代码
	// 不为绘图消息调用 CDialogEx::OnPaint()
	//if (!m_SourceImgOriginal.IsNull()) 
	//{
	//	CRect rctWindowSize;
	//	m_LoadSourcePic.GetWindowRect(rctWindowSize);
	//	//GetDlgItem(IDC_STATIC_SOURCE)->GetWindowRect(&rctWindowSize);
	//	//GetDlgItem(IDC_STATIC_SOURCE)->GetClientRect(&rctWindowSize);
	//	CPoint point(rctWindowSize.left,rctWindowSize.top);
	//	::ScreenToClient(m_hWnd,&point);
	//	m_SourceImgOriginal.StretchBlt(dc.GetSafeHdc(),point.x,point.y,rctWindowSize.Width(),rctWindowSize.Height(),0,0,rctWindowSize.Width(),rctWindowSize.Height(),SRCCOPY);
	//	if(rctWindowSize.Width()<=m_SourceImgOriginal.GetWidth())
	//		m_Width = rctWindowSize.Width();
	//	else
	//		m_Width = m_SourceImgOriginal.GetWidth();

	//	if(rctWindowSize.Height()<=m_SourceImgOriginal.GetHeight())
	//		m_Height = rctWindowSize.Height();
	//	else
	//		m_Height = m_SourceImgOriginal.GetHeight();
	//}

	if(m_IsPicLoaded)
	{
		CRect rctWindowSize;
		m_LoadSourcePic.GetWindowRect(rctWindowSize);
		////// 获得位图和显示位图的区域大小
		/*BITMAP bitm;
		::GetObjectW(m_Hbitmap,sizeof(BITMAP),&bitm);
		if(rctWindowSize.Width()<=bitm.bmWidth)
			m_Width = rctWindowSize.Width();
		else
			m_Width = bitm.bmWidth;
		if(rctWindowSize.Height()<=bitm.bmHeight)
			m_Height = rctWindowSize.Height();
		else
			m_Height = bitm.bmHeight;*/

		CPoint point(rctWindowSize.left,rctWindowSize.top);
		::ScreenToClient(m_hWnd,&point);
		/*CBitmap cbt;
		cbt.Attach(m_Hbitmap);*/
		////绘图
		SelectObject(m_hMemDC,m_Hbitmap);
		StretchBlt(dc.GetSafeHdc(),point.x,point.y,rctWindowSize.Width(),rctWindowSize.Height(),m_hMemDC,0,0,rctWindowSize.Width(),rctWindowSize.Height(),SRCCOPY);
		
	}
}
コード例 #17
0
LRESULT CRetrySplashScreen::OnCtlColorStatic(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    
    HDC hdc = (HDC) wParam;
    HWND hwnd = (HWND) lParam;
    
    int DlgCtrlID = ::GetDlgCtrlID(hwnd);
	
	if (DlgCtrlID == IDC_SPLASH_LINE1){
		
        if (m_hDialogFont == NULL){
			m_hDialogFont = CreateDialogFont(hdc, TEXT("Sun Sans"), 10, FW_MEDIUM, FALSE);
        }
        
        ::SelectObject(hdc, m_hDialogFont);
        ::SetBkMode(hdc, TRANSPARENT);
        return (LRESULT) GetStockObject(WHITE_BRUSH);	
        
	} else if (DlgCtrlID == IDC_SPLASH_HEADER){
        
        if (m_hDialogHeaderFont == NULL){
            m_hDialogHeaderFont = CreateDialogFont(hdc, TEXT("Sun Sans"), 12, FW_BOLD, FALSE);
        }
        
        ::SelectObject(hdc, m_hDialogHeaderFont);
        ::SetBkMode(hdc, TRANSPARENT);
        return (LRESULT) GetStockObject(WHITE_BRUSH);
        
    } else if (DlgCtrlID == IDC_BANNER){
        
     	if (m_hMemDC == NULL){
            
            m_hBitmap = LoadBitmap(_Module.GetModuleInstance(),
                                   MAKEINTRESOURCE(IDI_BANNER));
            GetObject(m_hBitmap, sizeof(BITMAP), &m_bmBannerJFX);
            m_hMemDC = CreateCompatibleDC(NULL);
            SelectObject(m_hMemDC, m_hBitmap);
            
	    }
        
	    RECT rect;
	    ::GetClientRect(hwnd, &rect);
	    StretchBlt(hdc, rect.left, rect.top, (rect.right - rect.left), (rect.bottom - rect.top),
                   m_hMemDC, 0, 0, m_bmBannerJFX.bmWidth, m_bmBannerJFX.bmHeight, SRCCOPY);
        
	    return (LRESULT) GetStockObject(NULL_BRUSH);
    }
    
    return (LRESULT) GetStockObject(WHITE_BRUSH);
    
}
void CPushPinDesktop::doJustBitBltOrScaling(HDC hMemDC, int nWidth, int nHeight, int iFinalWidth, int iFinalHeight, HDC hScrDC, int nX, int nY) {
	__int64 start = StartCounter();
    
	boolean notNeedStretching = (iFinalWidth == nWidth) && (iFinalHeight == nHeight);

	if(m_iHwndToTrack != NULL)
		ASSERT(notNeedStretching); // we don't support HWND plus scaling...hmm... LODO move assertion LODO implement this (low prio since they probably are just needing that window, not with scaling too [?])

    int captureType = SRCCOPY;
	if(m_bUseCaptureBlt)
	  captureType = captureType | CAPTUREBLT; // CAPTUREBLT here [last param] is for layered (transparent) windows in non-aero I guess (which happens to include the mouse, but we do that elsewhere)

	if (notNeedStretching) {

	  if(m_iHwndToTrack != NULL) {
        // make sure we only capture 'not too much' i.e. not past the border of this HWND, for the case of Aero being turned off, it shows other windows that we don't want
	    // a bit confusing...
        RECT p;
	    GetClientRect(m_iHwndToTrack, &p); // 0.005 ms
        //GetRectOfWindowIncludingAero(m_iHwndToTrack, &p); // 0.05 ms
	    nWidth = min(p.right-p.left, nWidth);
	    nHeight = min(p.bottom-p.top, nHeight);
      }

	   // Bit block transfer from screen our compatible memory DC.	Apparently this is faster than stretching.
       BitBlt(hMemDC, 0, 0, nWidth, nHeight, hScrDC, nX, nY, captureType);
	   // 9.3 ms 1920x1080 -> 1920x1080 (100 fps) (11 ms? 14? random?)
	}
	else {
		if (m_iStretchMode == 0)
    	{
			// low quality scaling -- looks terrible
	        SetStretchBltMode (hMemDC, COLORONCOLOR); // the SetStretchBltMode call itself takes 0.003ms
			// COLORONCOLOR took 92ms for 1920x1080 -> 1000x1000, 69ms/80ms for 1920x1080 -> 500x500 aero
			// 20 ms 1920x1080 -> 500x500 without aero
			// LODO can we get better results with good speed? it is sooo ugly.
    	}
		else
		{
		    SetStretchBltMode (hMemDC, HALFTONE);
			// high quality stretching
			// HALFTONE took 160ms for 1920x1080 -> 1000x1000, 107ms/120ms for 1920x1080 -> 1000x1000
			// 50 ms 1920x1080 -> 500x500 without aero
			SetBrushOrgEx(hMemDC, 0, 0, 0); // MSDN says I should call this after using HALFTONE
		}
	    StretchBlt(hMemDC, 0, 0, iFinalWidth, iFinalHeight, hScrDC, nX, nY, nWidth, nHeight, captureType);
	}

	if(show_performance)
	  LocalOutput("%s took %.02f ms", notNeedStretching ? "bitblt" : "stretchblt", GetCounterSinceStartMillis(start));
}
コード例 #19
0
ファイル: mdi.c プロジェクト: ABratovic/open-watcom-v2
static void DrawMdiIcon( HDC hdc, an_MDI_icon *MDI_icon, RECT *r )
{
    BITMAP              bm;
    HDC                 memDC;
    POINT               src_org, src_size;
    POINT               dst_org, dst_size;

    dst_size.y = r->bottom - r->top + 1;
    dst_size.x = r->right - r->left + 1;
    DPtoLP( hdc, &dst_size, 1 );

    dst_org.x = r->left;
    dst_org.y = r->top;
    DPtoLP( hdc, &dst_org, 1 );

    GetObject( MDI_icon->AND_bitmap, sizeof( BITMAP ), (LPSTR) &bm );

    memDC = CreateCompatibleDC( hdc );
    SelectObject( memDC, MDI_icon->AND_bitmap );

    src_size.x = bm.bmWidth;
    src_size.y = bm.bmHeight;
    DPtoLP( hdc, &src_size, 1 );

    src_org.x = 0;
    src_org.y = 0;
    DPtoLP( hdc, &src_org, 1 );

    StretchBlt( hdc, dst_org.x, dst_org.y, dst_size.x, dst_size.y,
        memDC, src_org.x, src_org.y, src_size.x, src_size.y, SRCAND );

    SelectObject( memDC, MDI_icon->XOR_bitmap );

    StretchBlt( hdc, dst_org.x, dst_org.y, dst_size.x, dst_size.y,
        memDC, src_org.x, src_org.y, src_size.x, src_size.y, SRCCOPY );

    DeleteDC( memDC );
} /* DrawMdiIcon */
コード例 #20
0
bool GdiPrintContext::swapBuffer()
{
	//if (!isActivated() || isDrawing()) return false;
	if (isDrawing()) return false;
	if (NULL == memBmp_ || NULL == memDC_ || NULL == printDC_) return false;
	setDrawing(true);

	// copy off-screen buffer to window's DC
#if  1
	// method #1: [use DDB & DIB] the image is not scaled to fit the rectangle
	const bool ret = TRUE == BitBlt(
		printDC_,
		drawRegion_.left, drawRegion_.bottom, drawRegion_.getWidth(), drawRegion_.getHeight(), 
		memDC_,
		0, 0,  //drawRegion_.left, drawRegion_.bottom,
		SRCCOPY
	);
#elif 0
	// method #2: [use DDB & DIB] the image is scaled to fit the rectangle
	// caution:
	// all negative coordinate values are ignored.
	// instead, these values are regarded as absolute(positive) values.
	const bool ret = TRUE == StretchBlt(
		printDC_,
		drawRegion_.left, drawRegion_.bottom, drawRegion_.getWidth(), drawRegion_.getHeight(),
		memDC_,
		//(int)std::floor(viewingRegion_.left + 0.5), (int)std::floor(viewingRegion_.bottom + 0.5), (int)std::floor(viewingRegion_.getWidth() + 0.5), (int)std::floor(viewingRegion_.getHeight() + 0.5),
		0, 0, (int)std::floor(viewingRegion_.getWidth() + 0.5), (int)std::floor(viewingRegion_.getHeight() + 0.5),
		SRCCOPY
	);
#else
	// method #3: [use DIB] the image is scaled to fit the rectangle
	// caution:
	// all negative coordinate values are ignored.
	// instead, these values are regarded as absolute(positive) values.
	const bool ret = TRUE == StretchDIBits(
		printDC_,
		drawRegion_.left, drawRegion_.bottom, drawRegion_.getWidth(), drawRegion_.getHeight(),
		//(int)std::floor(viewingRegion_.left + 0.5), (int)std::floor(viewingRegion_.bottom + 0.5), (int)std::floor(viewingRegion_.getWidth() + 0.5), (int)std::floor(viewingRegion_.getHeight() + 0.5),
		0, 0, (int)std::floor(viewingRegion_.getWidth() + 0.5), (int)std::floor(viewingRegion_.getHeight() + 0.5),
		dibBits_,
		&bmiDIB,
		!isPaletteUsed_ ? DIB_RGB_COLORS : DIB_PAL_COLORS,
		SRCCOPY
	);
#endif

	setDrawing(false);
	return ret;
}
コード例 #21
0
ファイル: AxJpgCard.cpp プロジェクト: aaaasmile/briscola_net
/*! Draw the bitmap on the current status
// \param RECT &rc : 
// \param HDC hdcDST : 
// \param HDC hdcSRC : 
*/
BOOL CAxJpgCard::DrawNormal(RECT &rc, HDC hdcDST, HDC hdcSRC)
{
    SetStretchBltMode(hdcDST, COLORONCOLOR);
    
    HRESULT hrP = NULL;
    
    
    
    StretchBlt(hdcDST, rc.left, rc.top, (rc.right - rc.left) , (rc.bottom - rc.top), 
        hdcSRC, 0,0, e_BmW, e_BmH, SRCCOPY );
    
    
    return TRUE;
}
コード例 #22
0
ファイル: cldib_core.cpp プロジェクト: devkitPro/grit
/*!	\param hdc	Destination DC.
*	\param dX	Destination left
*	\param dY	Destination top (?)
*	\param dW	Destination width
*	\param dH	Destination height
*	\param hbm	HBITMAP to blit
*	\param sX	Source left
*	\param sY	Source top (?)
*	\param sW	Source width
*	\param sH	Source height.
*	\param flags	Blit flags.
*	\note	Tested for top-down and bottom-up DIB's
*/
int hbm_blit(HDC hdc, int dX, int dY, int dW, int dH, 
	HBITMAP hbm, int sX, int sY, int sW, int sH, DWORD flags)
{
	HDC hdcSrc= CreateCompatibleDC(hdc);
	HBITMAP hOldSrc= (HBITMAP)SelectObject(hdcSrc, hbm);

	SetStretchBltMode(hdc, COLORONCOLOR);
	int res= StretchBlt(hdc, dX, dY, dW, dH, 
		hdcSrc, sX, sY, sW, sH, SRCCOPY);

	SelectObject(hdcSrc, hOldSrc);
	DeleteDC(hdcSrc);
	return res;
}
コード例 #23
0
ファイル: GrafMenu.c プロジェクト: Jeanhwea/petzold-pw5e
HBITMAP StretchBitmap (HBITMAP hBitmap1)
{
     BITMAP     bm1, bm2 ;
     HBITMAP    hBitmap2 ;
     HDC        hdc, hdcMem1, hdcMem2 ;
     int        cxChar, cyChar ;

          // Get the width and height of a system font character

     cxChar = LOWORD (GetDialogBaseUnits ()) ;
     cyChar = HIWORD (GetDialogBaseUnits ()) ;

          // Create 2 memory DCs compatible with the display
     
     hdc = CreateIC (TEXT ("DISPLAY"), NULL, NULL, NULL) ;
     hdcMem1 = CreateCompatibleDC (hdc) ;
     hdcMem2 = CreateCompatibleDC (hdc) ;
     DeleteDC (hdc) ;

          // Get the dimensions of the bitmap to be stretched
     
     GetObject (hBitmap1, sizeof (BITMAP), (PTSTR) &bm1) ;

          // Scale these dimensions based on the system font size
     
     bm2 = bm1 ;
     bm2.bmWidth      = (cxChar * bm2.bmWidth)  / 4 ;
     bm2.bmHeight     = (cyChar * bm2.bmHeight) / 8 ;
     bm2.bmWidthBytes = ((bm2.bmWidth + 15) / 16) * 2 ;

          // Create a new bitmap of larger size
     
     hBitmap2 = CreateBitmapIndirect (&bm2) ;

          // Select the bitmaps in the memory DCs and do a StretchBlt
     
     SelectObject (hdcMem1, hBitmap1) ;
     SelectObject (hdcMem2, hBitmap2) ;
     
     StretchBlt (hdcMem2, 0, 0, bm2.bmWidth, bm2.bmHeight,
                 hdcMem1, 0, 0, bm1.bmWidth, bm1.bmHeight, SRCCOPY) ;

          // Clean up
     
     DeleteDC (hdcMem1) ;
     DeleteDC (hdcMem2) ;
     DeleteObject (hBitmap1) ;
     
     return hBitmap2 ;
}
コード例 #24
0
ファイル: Renderer.hpp プロジェクト: ShaheedLegion/Cloudy
  void Flip() {
    // We need a mechanism to actually present the buffer to the drawing system.
    unsigned char *temp = m_pixels;
    m_pixels = m_backBuffer;
    m_backBuffer = temp;

    memcpy(m_screen, m_pixels, (m_w * m_h * (m_bpp / 8)));
    if (m_bitmapRenderer)
      m_bitmapRenderer->RenderToBitmap(m_dc);

    // BitBlt(m_screenDC, 0, 0, m_w, m_h, m_dc, 0, 0, SRCCOPY);
    StretchBlt(m_screenDC, 0, 0, m_w << 1, m_h << 1, m_dc, 0, 0, m_w, m_h,
               SRCCOPY);
  }
コード例 #25
0
static	BOOL Render2d_Blit(HDC hDC, HBITMAP Bmp, const RECT *SourceRect, const RECT *DestRect)
{
	HDC		MemDC;
    int		SourceWidth;
    int		SourceHeight;
    int		DestWidth;
    int		DestHeight;

	MemDC = CreateCompatibleDC(hDC);
	if	(MemDC == NULL)
		return FALSE;

	SelectObject(MemDC, Bmp);

	SourceWidth = SourceRect->right - SourceRect->left;
   	SourceHeight = SourceRect->bottom - SourceRect->top;
	DestWidth = DestRect->right - DestRect->left;
   	DestHeight = DestRect->bottom - DestRect->top;
    if	(SourceWidth == DestWidth && SourceHeight == DestHeight)
    {
		BitBlt(hDC,
        	   DestRect->left,
               DestRect->top,
               DestRect->right - DestRect->left,
               DestRect->bottom - DestRect->top,
               MemDC,
               SourceRect->left,
               SourceRect->top,
               SRCCOPY);
    }
    else
    {
    	StretchBlt(hDC,
        		   DestRect->left,
        		   DestRect->top,
                   DestWidth,
                   DestHeight,
                   MemDC,
        		   SourceRect->left,
        		   SourceRect->top,
                   SourceWidth,
                   SourceHeight,
                   SRCCOPY);
    }

	DeleteDC(MemDC);

	return TRUE;
}
コード例 #26
0
cv::Mat windowToMat(HWND hwnd){

	HDC hwindowDC, hwindowCompatibleDC;

	int height, width, srcheight, srcwidth;
	HBITMAP hbwindow;
	cv::Mat src;
	BITMAPINFOHEADER  bi;

	hwindowDC = GetDC(hwnd);
	hwindowCompatibleDC = CreateCompatibleDC(hwindowDC);
	SetStretchBltMode(hwindowCompatibleDC, COLORONCOLOR);

	RECT windowsize;    // get the height and width of the screen
	GetClientRect(hwnd, &windowsize);

	srcheight = subwindow.bottom - subwindow.top;// windowsize.bottom;
	srcwidth = subwindow.right - subwindow.left;// windowsize.right;
	height = subwindow.bottom - subwindow.top;//windowsize.bottom;  //change this to whatever size you want to resize to
	width = subwindow.right - subwindow.left;//windowsize.right;

	src.create(height, width, CV_8UC4);

	// create a bitmap
	hbwindow = CreateCompatibleBitmap(hwindowDC, width, height);
	bi.biSize = sizeof(BITMAPINFOHEADER);
	bi.biWidth = width;
	bi.biHeight = -height;  //this is the line that makes it draw upside down or not
	bi.biPlanes = 1;
	bi.biBitCount = 32;
	bi.biCompression = BI_RGB;
	bi.biSizeImage = 0;
	bi.biXPelsPerMeter = 0;
	bi.biYPelsPerMeter = 0;
	bi.biClrUsed = 0;
	bi.biClrImportant = 0;

	// use the previously created device context with the bitmap
	SelectObject(hwindowCompatibleDC, hbwindow);
	// copy from the window device context to the bitmap device context
	//StretchBlt(hwindowCompatibleDC, 0, 0, width, height, hwindowDC, 0, 0, srcwidth, srcheight, SRCCOPY); //change SRCCOPY to NOTSRCCOPY for wacky colors !
	StretchBlt(hwindowCompatibleDC, 0, 0, width, height, hwindowDC, subwindow.left, 100, srcwidth, srcheight, SRCCOPY); //change SRCCOPY to NOTSRCCOPY for wacky colors !
	GetDIBits(hwindowCompatibleDC, hbwindow, 0, height, src.data, (BITMAPINFO *)&bi, DIB_RGB_COLORS);  //copy from hwindowCompatibleDC to hbwindow

	// avoid memory leak
	DeleteObject(hbwindow); DeleteDC(hwindowCompatibleDC); ReleaseDC(hwnd, hwindowDC);

	return src;
}
コード例 #27
0
ファイル: zmscreen.c プロジェクト: ABratovic/open-watcom-v2
void DrawScreen( ScreenBitmap *info, HDC dc, POINT *dstpos, POINT *dstsize,
                POINT *srcpos, POINT *srcsize ) {

    BOOL        own_dc;

    own_dc = FALSE;
    if( dc == NULL ) {
        dc = GetDC( info->hwnd );
        own_dc = TRUE;
    }
    StretchBlt( dc, dstpos->x, dstpos->y, dstsize->x, dstsize->y,
                info->memdc, srcpos->x, srcpos->y,
                srcsize->x, srcsize->y, SRCCOPY );
    if( own_dc ) ReleaseDC( info->hwnd, dc );
}
コード例 #28
0
ファイル: mdi.cpp プロジェクト: EastonWoo/libafba
// Needed for the non-preview mode
void StretchBmForClient(HDC hDC, HWND hWnd, HBITMAP hBitmap)
{
	HDC memDC; BITMAP bm; RECT re;

	memDC = CreateCompatibleDC(hDC);
	HGDIOBJ hOldObj = SelectObject(memDC, hBitmap);
	
	GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm);
	GetClientRect(hWnd, &re);
	
	StretchBlt(hDC, 0, 0, re.right, re.bottom, memDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
	
	SelectObject(memDC, hOldObj);
	DeleteDC(memDC);
}
コード例 #29
0
ファイル: Win32life.cpp プロジェクト: Sensayo/Life_Machine
//// отрисовывает картиночки
void DrawBmp(HDC hdc, LPCTSTR PathToFile, int ZeroX, int ZeroY)
{
	BITMAP Bitmap;
	HBITMAP hOldBitmap;
	HDC hCompatibleDC = CreateCompatibleDC(hdc);

	HBITMAP hBitmap = (HBITMAP)LoadImage(hInst, PathToFile, IMAGE_BITMAP, 0, 0, NULL);
	GetObject(hBitmap, sizeof(BITMAP), &Bitmap);
	hOldBitmap = (HBITMAP)SelectObject(hCompatibleDC, hBitmap);
	StretchBlt(hdc, ZeroX, ZeroY, Bitmap.bmWidth, Bitmap.bmHeight, hCompatibleDC, 0, 0, Bitmap.bmWidth, Bitmap.bmHeight, SRCCOPY);

	SelectObject(hCompatibleDC, hOldBitmap);
	DeleteObject(hBitmap);
	DeleteDC(hCompatibleDC);
}
コード例 #30
0
ファイル: RtImage.c プロジェクト: rt15/win32ex
RT_B RT_API RtStretchImage(RT_H hSourceDc, RT_N nSourceWidth, RT_N nSourceHeight, RT_H hDestinationDc, RT_N nDestinationWidth, RT_N nDestinationHeight)
{
  RT_B bResult;

  if (!SetStretchBltMode(hDestinationDc, HALFTONE)) goto handle_error;
  if (!SetBrushOrgEx(hDestinationDc, 0, 0, RT_NULL)) goto handle_error;
  if (!StretchBlt(hDestinationDc, 0, 0, nDestinationWidth, nDestinationHeight, hSourceDc, 0, 0, nSourceWidth, nSourceHeight, SRCCOPY)) goto handle_error;

  bResult = RT_TRUE;
  goto free_resources;
handle_error:
  bResult = RT_FALSE;
free_resources:
  return bResult;
}