티스토리 뷰
반응형
#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);
반응형
'C언어' 카테고리의 다른 글
다수의 통신포트를 비동기 방식으로 제어하는 C 코드를 작성하는 방법 (0) | 2023.04.08 |
---|---|
C언어에서 enum사용법 (0) | 2023.04.08 |
VC++ 6.0 Lib (0) | 2022.08.27 |
윈도우11 USB 시리얼포트 버그 문제 (0) | 2022.08.12 |
STM32 NUCLEO 보드로 펌웨어 쉽게 다운로드 하는 방법 (0) | 2022.08.12 |