CxImage 정리(중첩 문자/이미지 결합)

3896 단어 image
//CxImage 

void CCxImageTestDlg::OnBnClickedButton1()

{

    CxImage imgJPG;   //  CxImage 

    imgJPG.Load("1.jpg", CXIMAGE_FORMAT_JPG);   // jpg     

    //  jpg 。

    if (imgJPG.IsValid())

    {

        // HBITMAP

        HBITMAP hbmp = imgJPG.MakeBitmap();



        HWND hwnd = GetSafeHwnd();

        HDC hdc = ::GetDC(hwnd);



        HDC hdcMem = ::CreateCompatibleDC(hdc);

        SelectObject(hdcMem, hbmp);



        RECT rc = {50, 50, 200, 200};

        ::SetBkMode(hdcMem, TRANSPARENT);

        ::DrawText(hdcMem, "Hello World.", -1, &rc,  DT_VCENTER);



        CxImage imgBmp;

        imgBmp.CreateFromHBITMAP(hbmp);

        imgBmp.Save("1jpg.jpg", CXIMAGE_FORMAT_JPG);





        ::ReleaseDC(hwnd, hdc);        

        ::DeleteDC(hdcMem);

        ::DeleteDC(hdc);

    }

}



// , ; 。

// 1 2, 1 。 MixFrom 

void mergerImage(void)

{

    CxImage img1,img2,img3;

    int h1,w1,h2,w2,h3,w3,bpp;



    img1.Load("F:\\1.jpg");

    img2.Load("F:\\2.jpg");



    h1=img1.GetHeight();

    w1=img1.GetWidth();



    h2=img2.GetHeight();

    w2=img2.GetWidth();



    h3=h1;

    w3=w1+w2;



    bpp=img1.GetBpp();



    img3.Create(w3,h3,bpp);

    img3.MixFrom(img1,0,0);

    img3.MixFrom(img2,w1,0);



    img3.Save("f:\\3.jpg",CXIMAGE_FORMAT_JPG);

}

좋은 웹페이지 즐겨찾기