StretchDIBits How to use

Source: Internet
Author: User

Transferred from: http://blog.csdn.net/giantchen547792075/article/details/6996011

The StretchDIBits function copies the pixel color data in a rectangular region of a DIB, JPEG, or PNG image into a specified target rectangle. Assuming that the destination rectangle is larger than the source rectangle, this function stretches the rows and columns to fit the color data of the destination rectangle. If the destination rectangle is smaller than the source rectangle, this function uses the specified raster operation to compress the rows and columns. (Note: The entire image is displayed in a rectangular area, and this rectangle area is not allowed to display the original picture)

Syntax:int StretchDIBits (HDC hdc,int xdest,ydest,int int ndestwidth,int ndestheight,int xsrc,int ysrc,int nsrcwidth,int NSrcHei Ght,const VOID __in * lpbits,__in Const BITMAPINFO * lpbitsinfo,__in UINT iusage,__in dword = dwrop); number of references:HDC [in](Note: I don't know what this [in] stands for, but it doesn't really matter.)The handle to the target device context. Xdest [in] the x-coordinate of the corner point, in logical units, to the upper-left corner of the destination rectangle. ydest [in]y coordinates, the upper-left corner of the destination rectangle on the logical unit. Ndestwidth [in] logical unit, the width of the target rectangle. Ndestheight [in] logical unit, the height of the target rectangle. The x-coordinate of the xsrc [in] corner, in pixels, in the source rectangle image. YSRC [in]y coordinates, in pixels, in the source rectangle image. Nsrcwidth [in] width, in pixels, in the source rectangle image. The nsrcheight [in] height is in pixels, in the source rectangle image. A bit of the lpbits [in] image as a pointer to a byte array store. For specific information, see the Remarks section. Lpbitsinfo [in] pointer to the BITMAPINFO structure that includes information about the DIB. Iusage [in] Specifies whether the bmicolors member of the BITMAPINFO structure is provided, and if so, whether the bmicolors includes an explicit red, green, Blue (RGB) value, or an index. The Iusage parameter must be one of the following values.
Value Note
Dib_rgb_colors The RGB value of the text is included in the color table.
Dib_pal_colors The array includes a 16-bit index to the logical palette of the source device context.

Dwrop [in] is grouped together to form a new image source pixel, the current brush for the target device context, and the target pixel. For specific information, please refer to the Remarks section below. return value

Assuming the function succeeds, the return value is the number of rows scanned for replication. Note that this value can be a negative mirror content.

If the function fails, or if no scanned rows are copied, the return value is 0.

Assuming that the driver does not support JPEG or PNG file images to StretchDIBits, the function fails and returns GDI_ERROR. Assuming a problem occurs, the application must rely on its own JPEG or PNG support, compress the image's extract into a bitmap, and then pass the bitmap to StretchDIBits.

Note the starting position of the bottom-up DIB is the lower-left corner, and the top-down DIB starts at the upper-left corner. StretchDIBits creates an image of a bitmap mirror, assuming that the two parameters of Nsrcwidth and ndestwidth are different from those of Nsrcheight and ndestheight. Nsrcwidth and ndestwidth have different symbols, the function creates a bitmap image that is mirrored along the x-axis. Nsrcheight and ndestheight have different symbols, the function creates a bitmap image that is mirrored along the y-axis. This function agrees that a JPEG or PNG image is passed in as a source image. How each of the parameters is used remains the same, unless:
    • Assume that the bicompression member of Bitmapinfoheader is Bi_jpeg or bi_png,lpbits points to a separate buffer that includes a JPEG or PNG image. The biSizeImage member of the BITMAPINFOHEADER structure specifies the size of the buffer. The Iusage parameter has to be set to Dib_rgb_colors. The Dwrop parameter has to be set to Srccopy.
    • To ensure that you have the appropriate metafile cache pool for printing, your application must call Checkjpegformat or Checkpngformat escape before calling StretchDIBits to verify that the printer can identify JPEG or PNG images individually.
ICM: If color management is enabled for calls that are set to icm_on by using SetICMMode's IENABLEICM parameters, color management will run. Assume that the bitmap specified by Lpbitsinfo has a bitmapv4header structure that specifies the gamma and member endpoint members, or a member of a specified profiledata and profilesize, or a member of a gamma and a member of the end node Bitmapv5header The entire pixel of the bitmap is then considered to be expressed in the source color space of the color space species described by these members rather than the device context.

StretchDIBits How to use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.