The synthesis of image and text

Source: Internet
Author: User

A few days ago to do a program, the text and bitmap image synthesis and save as a bitmap file. But asked for a long time no one to give a satisfactory answer, had to grope in the dark, took some effort to achieve the image and text synthesis, and can drag the mouse text. Now I post the code, hoping to give help to the friend I need.

One, the key function 1.

int SetDIBits(
    HDC hdc,         // 兼容DC的句柄
    HBITMAP hbmp,       // 兼容位图的句柄
    UINT uStartScan,     // 扫描起始行的编号
    UINT cScanLines,     // 扫描的行的数目
    CONST VOID *lpvBits,   // 位图缓冲区的指针,要求已经分配空间
    CONST BITMAPINFO *lpbmi, // 位图信息
    UINT fuColorUse      // 颜色格式
    );

This function pastes bitmap data one pixel pixel to a compatible bitmap, HDC is a compatible DC with a compatible bitmap selected.

2.

int GetDIBits(
     HDC hdc,      // 兼容DC的句柄
     HBITMAP hbmp,   // 兼容位图的句柄
     UINT uStartScan,  // 扫描起始行的编号
     UINT cScanLines,  // 扫描的行的数目
     LPVOID lpvBits,  // 位图缓冲区的指针,要求已经分配空间
     LPBITMAPINFO lpbi, // 位图信息
     UINT uUsage    // 颜色格式
     );

This function, in contrast to setdibits, copies the existing data in a compatible bitmap to the data buffer (lpvbits) in pixels of one pixel. So the implementation of the program is more clear, first, according to the size of the bitmap, create a compatible bitmap, and then draw the picture to a compatible bitmap, and then write the text to a compatible bitmap, and then from the compatible bitmap to get the synthesized data.

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.