当前位置: 首页>>代码示例>>C++>>正文


C++ StretchBlt函数代码示例

本文整理汇总了C++中StretchBlt函数的典型用法代码示例。如果您正苦于以下问题:C++ StretchBlt函数的具体用法?C++ StretchBlt怎么用?C++ StretchBlt使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了StretchBlt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Resize

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);
    }
}
开发者ID:bpowers,项目名称:wine,代码行数:55,代码来源:v4l.c

示例2: putImageScale

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);
}
开发者ID:Gnnng,项目名称:LaserTank,代码行数:11,代码来源:acllib.c

示例3: sizeof

//-----------------------------------------------------------------------------
// 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;
}
开发者ID:galek,项目名称:xform-megatexture,代码行数:59,代码来源:ddutil.cpp

示例4: CopyMirrored

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 );
}
开发者ID:rauls,项目名称:mirrorimage,代码行数:11,代码来源:mirrorimage.cpp

示例5: StretchBlt

// 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);
}
开发者ID:hufuman,项目名称:xindows,代码行数:12,代码来源:ImgBits.cpp

示例6: vdev_gdi_enqueue

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);
}
开发者ID:rockcarry,项目名称:ffnes,代码行数:53,代码来源:vdev-gdi.cpp

示例7: StretchBitmap

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);
}
开发者ID:Illya-Van-Gils,项目名称:Zombie-Penguin-Pirates,代码行数:12,代码来源:bitblt.cpp

示例8: WinGStretchBlt

/***********************************************************************
 *           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;
}
开发者ID:lucianolorenti,项目名称:wine,代码行数:15,代码来源:wing32.c

示例9: StretchBlt

// 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);
}
开发者ID:codebachi,项目名称:ProjectDirectX,代码行数:13,代码来源:DIB.cpp

示例10: read_bitmap

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;
}
开发者ID:Jmos,项目名称:bbclean-xzero450,代码行数:53,代码来源:BBRoot.cpp

示例11: SetTextColor

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;
}
开发者ID:b2kguga,项目名称:CodesAndNotes,代码行数:12,代码来源:DDB.cpp

示例12: WndProc

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) ;
}
开发者ID:AaronFae,项目名称:VimProject,代码行数:52,代码来源:SysPal3.c

示例13: OnPaint

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);
}
开发者ID:HP-Enterprise,项目名称:Training,代码行数:13,代码来源:main.cpp

示例14: StretchDrawTo

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);
                }
        }
开发者ID:MOROZIL-nic,项目名称:craft,代码行数:39,代码来源:myclasses.cpp

示例15: BitBlt

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;
	}
}
开发者ID:yuki12,项目名称:krkrz,代码行数:51,代码来源:GDIDrawer.cpp


注:本文中的StretchBlt函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。