提问:我在内存DC中BITBLT了很多东西,现在我想把它们显示到显示DC中,该怎么做?
我是这样做的,不过没有效果:
CDlg::OnPaint()
{
CPaintDC dc(this);
CDC mdc;
mdc.CreateCompatibleDC(&dc);.......在mdc里画了很多东西
CRect rect;GetClientRect(recr):
dc.BitBlt(rect.left,rect.top,rect.right,rect.bottom,&mdc,0,0,SRCAND);
ReleaseDC(&mdc);
}
我是这样做的,不过没有效果:
CDlg::OnPaint()
{
CPaintDC dc(this);
CDC mdc;
mdc.CreateCompatibleDC(&dc);.......在mdc里画了很多东西
CRect rect;GetClientRect(recr):
dc.BitBlt(rect.left,rect.top,rect.right,rect.bottom,&mdc,0,0,SRCAND);
ReleaseDC(&mdc);
}
解决方案 »
- 关于一个 tab control的问题
- 【求教】自己改的一个VC的天气预报 为何截取的内容全是乱码?
- 在MFC的 基于对话框的程序中,如何在EDIT控件上,模拟鼠标滚轮键?
- 自编了一个文本输入框,不能输入中文。。。。。
- 在ListCtrl的report模式中,给“非第一列”加入一个图片(bmp 或 icon),该怎么弄?
- VC的SDK编程, 点击菜单项后,为何消息循环会结束,请高手指点
- 请问用什么软件制作chm帮助文档?
- !紧急救援,在线等待!关于按F5调试的问题。
- 用WINGATE 代理上网,如何用NETANETS下债???
- 关于CEDITView类的问题,各位大虾帮帮忙!!
- 这是为何?
- 视频捕捉用VFW和DirectShow哪个好?主要用于视频会议.
BOOL StretchBlt( int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwRop );Return ValueNonzero if the bitmap is drawn; otherwise 0.ParametersxSpecifies the x-coordinate (in logical units) of the upper-left corner of the destination rectangle.ySpecifies the y-coordinate (in logical units) of the upper-left corner of the destination rectangle.nWidthSpecifies the width (in logical units) of the destination rectangle.nHeightSpecifies the height (in logical units) of the destination rectangle.pSrcDCSpecifies the source device context.xSrcSpecifies the x-coordinate (in logical units) of the upper-left corner of the source rectangle.ySrcSpecifies the x-coordinate (in logical units) of the upper-left corner of the source rectangle.nSrcWidthSpecifies the width (in logical units) of the source rectangle.nSrcHeightSpecifies the height (in logical units) of the source rectangle.dwRopSpecifies the raster operation to be performed. Raster operation codes define how GDI combines colors in output operations that involve a current brush, a possible source bitmap, and a destination bitmap. This parameter may be one of the following values: BLACKNESS Turns all output black.
DSTINVERT Inverts the destination bitmap.
MERGECOPY Combines the pattern and the source bitmap using the Boolean AND operator.
MERGEPAINT Combines the inverted source bitmap with the destination bitmap using the Boolean OR operator.
NOTSRCCOPY Copies the inverted source bitmap to the destination.
NOTSRCERASE Inverts the result of combining the destination and source bitmaps using the Boolean OR operator.
PATCOPY Copies the pattern to the destination bitmap.
PATINVERT Combines the destination bitmap with the pattern using the Boolean XOR operator.
PATPAINT Combines the inverted source bitmap with the pattern using the Boolean OR operator. Combines the result of this operation with the destination bitmap using the Boolean OR operator.
SRCAND Combines pixels of the destination and source bitmaps using the Boolean AND operator.
SRCCOPY Copies the source bitmap to the destination bitmap.
SRCERASE Inverts the destination bitmap and combines the result with the source bitmap using the Boolean AND operator.
SRCINVERT Combines pixels of the destination and source bitmaps using the Boolean XOR operator.
SRCPAINT Combines pixels of the destination and source bitmaps using the Boolean OR operator.
WHITENESS Turns all output white.
ResCopies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap if necessary to fit the dimensions of the destination rectangle. The function uses the stretching mode of the destination device context (set by SetStretchBltMode) to determine how to stretch or compress the bitmap.The StretchBlt function moves the bitmap from the source device given by pSrcDC to the destination device represented by the device-context object whose member function is being called. The xSrc, ySrc, nSrcWidth, and nSrcHeight parameters define the upper-left corner and dimensions of the source rectangle. The x, y, nWidth, and nHeight parameters give the upper-left corner and dimensions of the destination rectangle. The raster operation specified by dwRop defines how the source bitmap and the bits already on the destination device are combined.The StretchBlt function creates a mirror image of a bitmap if the signs of the nSrcWidth and nWidth or nSrcHeight and nHeight parameters differ. If nSrcWidth and nWidth have different signs, the function creates a mirror image of the bitmap along the x-axis. If nSrcHeight and nHeight have different signs, the function creates a mirror image of the bitmap along the y-axis.The StretchBlt function stretches or compresses the source bitmap in memory and then copies the result to the destination. If a pattern is to be merged with the result, it is not merged until the stretched source bitmap is copied to the destination. If a brush is used, it is the selected brush in the destination device context. The destination coordinates are transformed according to the destination device context; the source coordinates are transformed according to the source device context.If the destination, source, and pattern bitmaps do not have the same color format, StretchBlt converts the source and pattern bitmaps to match the destination bitmaps. The foreground and background colors of the destination device context are used in the conversion. If StretchBlt must convert a monochrome bitmap to color, it sets white bits (1) to the background color and black bits (0) to the foreground color. To convert color to monochrome, it sets pixels that match the background color to white (1) and sets all other pixels to black (0). The foreground and background colors of the device context with color are used.Not all devices support the StretchBlt function. To determine whether a device supports StretchBlt, call the GetDeviceCaps member function with the RASTERCAPS index and check the return value for the RC_STRETCHBLT flag.
dc.BitBlt(rect.left,rect.top,rect.right,rect.bottom,&mdc,0,0,SRCAND);
dc.BitBlt(0, 0, rect.right, rect.bottom, &mdc, 0, 0, SRCCOPY);
建立内存dc
建立位图,笔,刷子
dc选入位图,笔,刷子
画图操作
拷贝到显示dc
释放资源看看帮助吧
2.再將位圖選入到內存DC.
你再用Bitblt才會顯示.