回 帖 发 新 帖 刷新版面

主题:关于 StretchBlt 的问题

各位用  StretchBlt 放大图象和缩小 图片 怎么做啊 
谢谢各位了 表示感谢了 举个例子

回复列表 (共1个回复)

沙发

BCB对StretchBlt()是这样定义的:

StretchBlt()将源矩形按要求经缩放后,拷贝到目标矩形。

BOOL StretchBlt(

    HDC hdcDest,    // 目标矩形句柄 
    int dX,int dY,int dW,int dH,//目标矩形的左上坐标、长和宽. 
    HDC hdcSrc,    // 源矩形句柄 
    int sX,int sY,int sW,int sH,//源矩形的左上坐标、长和宽.
    DWORD dwRop     // 光栅操作码 
   );    
 

dwRop参数的值和意义:

Specifies a raster-operation code. These codes define how the color data for the source rectangle is to be combined with the color data for the destination rectangle to achieve the final color. 
The following list shows some common raster operation codes: 

Value      Description
BLACKNESS:Fills the destination rectangle using the color associated    with index 0 in the physical palette. (This color is black for the default physical palette.)
DSTINVERT    :Inverts the destination rectangle.
MERGECOPY    :Merges the colors of the source rectangle with the specified pattern by using the Boolean AND operator.
MERGEPAINT:Merges the colors of the inverted source rectangle with the colors of the destination rectangle by using the Boolean OR operator.
NOTSRCCOPY:Copies the inverted source rectangle to the destination.
NOTSRCERASE:Combines the colors of the source and destination rectangles by using the Boolean OR operator and then inverts the resultant color.
PATCOPY:Copies the specified pattern into the destination bitmap.
PATINVERT:Combines the colors of the specified pattern with the colors of the destination rectangle by using the Boolean XOR operator.
PATPAINT:    Combines the colors of the pattern with the colors of the inverted source rectangle by using the Boolean OR operator. The result of this operation is combined with the colors of the destination rectangle by using the Boolean OR operator.
SRCAND:Combines the colors of the source and destination rectangles by using the Boolean AND operator.
SRCCOPY:Copies the source rectangle directly to the destination rectangle.
SRCERASE:    Combines the inverted colors of the destination rectangle with the colors of the source rectangle by using the Boolean AND operator.
SRCINVERT:Combines the colors of the source and destination rectangles by using the Boolean XOR operator.
SRCPAINT:    Combines the colors of the source and destination rectangles by using the Boolean OR operator.
WHITENESS    :Fills the destination rectangle using the color associated with index 1 in the physical palette. (This color is white for the default physical palette.)

Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError. 

Remarks

StretchBlt stretches or compresses the source bitmap in memory and then copies the result to the destination rectangle. The color data for pattern or destination pixels is merged after the stretching or compression occurs. 
When an enhanced metafile is being recorded, an error occurs (and the function returns FALSE) if the source device context identifies an enhanced-metafile device context. 
If the specified raster operation requires a brush, Windows uses the brush currently selected into the destination device context. 

The destination coordinates are transformed by using the transformation currently specified for the destination device context; the source coordinates are transformed by using the transformation currently specified for the source device context. 
If the source transformation has a rotation or shear, an error occurs. 
If destination, source, and pattern bitmaps do not have the same color format, StretchBlt converts the source and pattern bitmaps to match the destination bitmap. 

If StretchBlt must convert a monochrome bitmap to a color bitmap, it sets white bits (1) to the background color and black bits (0) to the foreground color. To convert a color bitmap to a monochrome bitmap, 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. 
StretchBlt creates a mirror image of a bitmap if the signs of the nWidthSrc and nWidthDest parameters or of the nHeightSrc and nHeightDest parameters differ. If nWidthSrc and nWidthDest have different signs, the function creates a mirror image of the bitmap along the x-axis. If nHeightSrc and nHeightDest have different signs, the function creates a mirror image of the bitmap along the y-axis. 

Not all devices support the StretchBlt function. For more information, see the GetDeviceCaps function.

我来回复

您尚未登录,请登录后再回复。点此登录或注册