转载:::StretchDIBits()函数

CDC::StretchBlt
BOOL StretchBlt( int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwRop );

Return Value

Nonzero if the bitmap is drawn; otherwise 0.

如果位图已经绘制,则返回非零值,否则为0。

Parameters

x

Specifies the x-coordinate (in logical units) of the upper-left corner of the destination rectangle.

目标矩形左上角的X逻辑坐标。

y

Specifies the y-coordinate (in logical units) of the upper-left corner of the destination rectangle.

目标矩形左上角的Y逻辑坐标。

nWidth

Specifies the width (in logical units) of the destination rectangle.

目标矩形的宽度(逻辑单位)。

nHeight

Specifies the height (in logical units) of the destination rectangle.

目标矩形的高度(逻辑单位)。

pSrcDC

Specifies the source device context.

指定源设备上下文。

xSrc

Specifies the x-coordinate (in logical units) of the upper-left corner of the source rectangle.

源矩形左上角的X逻辑坐标。

ySrc

Specifies the x-coordinate (in logical units) of the upper-left corner of the source rectangle.

源矩形左上角的Y逻辑坐标。

nSrcWidth

Specifies the width (in logical units) of the source rectangle.

源矩形的宽度(逻辑单位)。

nSrcHeight

Specifies the height (in logical units) of the source rectangle.

源矩形的高度(逻辑单位)。

dwRop

Specifies 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:

指定光栅操作。光栅操作模式说明了GDI是如何组合输出操作中的颜色,包括当前画刷、可能的源位图和目标位图。可以为下列值之一:

BLACKNESS Turns all output black.

BLACKNESS 将所有输出变为黑色。
DSTINVERT Inverts the destination bitmap.

DSTINBERT 反转目标位图颜色。
MERGECOPY Combines the pattern and the source bitmap using the Boolean AND operator.

MERGECOPY 使用AND运算符组合模板与源位图的颜色。
MERGEPAINT Combines the inverted source bitmap with the destination bitmap using the Boolean OR operator.

MERGEPAINT 使用OR运算符组合源位图的反色与目标矩形的颜色。
NOTSRCCOPY Copies the inverted source bitmap to the destination.

NOTSRCCOPY 将源位图的反色拷贝到目标矩形中。
NOTSRCERASE Inverts the result of combining the destination and source bitmaps using the Boolean OR operator.

NOTSRCERASE 反转使用OR运算符组合源位图与目标矩形后得到的颜色
PATCOPY Copies the pattern to the destination bitmap.

PATCOPY 将模板颜色拷贝到目标矩形中。
PATINVERT Combines the destination bitmap with the pattern using the Boolean XOR operator.

PATINVERT 使用XOR运算符组合目标矩形与模板颜色。
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.

PATPAINT 使用OR运算符组合模板与源位图的反色。再使用OR运算符将该操作结果与目标矩形组合。
SRCAND Combines pixels of the destination and source bitmaps using the Boolean AND operator.

SRCAND 使用AND运算符组合源位图和目标位图的像素。
SRCCOPY Copies the source bitmap to the destination bitmap.

SRCCOPY 将源位图拷贝到目标位图。
SRCERASE Inverts the destination bitmap and combines the result with the source bitmap using the Boolean AND operator.

SRCERASE 反转目标矩形的颜色,再使用AND运算符将该结果与源位图组合。
SRCINVERT Combines pixels of the destination and source bitmaps using the Boolean XOR operator.

SRCINVERT 使用XOR运算符组合源位图和目标位图的像素。
SRCPAINT Combines pixels of the destination and source bitmaps using the Boolean OR operator.

SRCPAINT 使用OR运算符组合源位图和目标位图的像素
WHITENESS Turns all output white.

WHITENESS 使所有输出变成白色。
Remarks

Copies 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.

将源矩形中的位图拷贝到目标矩形中,如果有必要,可以扩展或压缩该位图使其与目标矩形尺寸吻合。函数使用目标设备上下文(由SetStretchBltMode设置)的扩展模式来决定如何扩展或压缩位图。

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.

StretchBlt 函数将pSrcDC源设备中的位图移动到目标矩形,该矩形用成员函数正在调用的设备上下文来表示。xSrc,ySrc,nSrcWidth和nSrcHeight 参数定义了源矩形的左上角和尺寸。x,yc,nWidth和nHeight参数定义了目标矩形的左上角和尺寸。dwRop指定的光栅操作模式说明了源位图与目标设备上已经存在的位图是如何组合的。

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.

如果nSrcWidth和nWidth或nSrcHeight和nHeight的符号不同,StretchBlt将为位图创建一个镜像。如果nSrcWidth和nWidth符号不同,函数沿X轴创建镜像。如果nSrcHeight和nHeight符号不同,函数沿Y轴创建镜像。

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.

StretchBlt函数在内存中对源位图进行扩展或压缩,然后将结果拷贝到目标矩形中。如果模板要与结果组合,则在扩展后的位图拷贝到目标矩形后才组合。如果用到画刷,应使用目标设备上下文中选定的画刷。目标坐标根据目标设备上下文来转换,源坐标根据源设备上下文来转换。

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.

如果目标位图、源位图和模板位图的格式不一致,StretchBlt使模板与源位图匹配模板位图格式,转换中会使用到目标设备上下文中的前景色和背景色。

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.

如果要将黑白位图转换为彩色位图,它将背景色设置为白位(1),前景色设置为黑位(0)。如果要将彩色位图转换为黑白位图,函数设置与背景色匹配的像素为白(1),其它像素为黑(0),用到了带颜色的设备上下文中的前景色和背景色。

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.

不是所有的设备都支持StretchBlt函数。调用带RASTERCAPS索引的GetDev-iceCaps 函数来决定是否支持StretchBlt。并检验为返回给RC_STRETCH-BLT标记的值。 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值