티스토리 뷰

반응형
#include <objidl.h>
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment (lib,"Gdiplus.lib")


void strcpy(wchar_t* buf, const char* s)
{
    int nLen = MultiByteToWideChar(CP_ACP,
        0,
        s, -1,
        NULL,
        NULL);

    MultiByteToWideChar(CP_ACP,
        0,
        s, -1,
        buf,
        nLen);
}
HBITMAP LoadPng(const char* file1,int *w,int *h)
{
    wchar_t file[1024];
    strcpy(file, file1);

    HBITMAP hb = 0;
    int bok = 0;
    Image image(file);
    *w = image.GetWidth();
    if (*w > 0)
    {
        *h = image.GetHeight();
        if (*h > 0)
        {
            HDC hdc = GetDC(0);
            if (hdc)
            {
                HDC hdc_mem = ::CreateCompatibleDC(hdc);
                hb = ::CreateCompatibleBitmap(hdc, *w, *h);
                ReleaseDC(0, hdc);

                ::SelectObject(hdc_mem, hb);
                Graphics graphics(hdc_mem);
                graphics.DrawImage(&image, 0, 0);
                ::DeleteDC(hdc_mem);
                bok = 1;
            }
        }
    }
    if (bok == 0)
    {
        *w = 0;
        *h = 0;
    }
    return hb;
}
void BitBlt(HDC hdc, int x, int y, int cx,int cy, HBITMAP hb, int x1, int y1,DWORD op)
{
    HDC hdc_mem= CreateCompatibleDC(hdc);
    ::SelectObject(hdc_mem, hb);
    BitBlt(hdc, x, y, cx, cy, hdc_mem, x1, y1, op);
    ::DeleteDC(hdc_mem);
}

HBITMAP hb_back_img;
int hb_back_img_w, hb_back_img_h;

hb_back_img=LoadPng("C:\\601-1.png",&hb_back_img_w,&hb_back_img_h);

LoadPng.zip
0.01MB

반응형
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
글 보관함