mikson Temat założony przez niniejszego użytkownika |
[winAPI] Biblioteka ładująca JPG/PNG » 2016-06-30 15:30:51 Cześć,
Jakiej biblioteki mogę użyć, aby namalowała ładnie w moim oknie obrazek *.jpg lub *.png? Z tego, co wyczytałem, winAPI obsługuje tylko *.bmp.
Z góry dzięki za pomoc. Pozdrawiam |
|
carlosmay |
» 2016-06-30 15:58:29 |
|
Gabes |
» 2016-06-30 20:44:31 GDIplus #include <windows.h> #include <gdiplus.h> using namespace Gdiplus;
void OnPaint( HDC hdc ) { Graphics graphics( hdc ); Image obrazekPNG( L"obrazek.png" ); Image obrazekJPG( L"obrazek.jpg" ); graphics.DrawImage( & obrazekPNG, 0, 0 ); graphics.DrawImage( & obrazekJPG, 0, 100 ); }
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
INT WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, PSTR, INT iCmdShow ) { HWND hWnd; MSG msg; WNDCLASS wndClass; GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; GdiplusStartup( & gdiplusToken, & gdiplusStartupInput, NULL ); wndClass.style = CS_HREDRAW | CS_VREDRAW; wndClass.lpfnWndProc = WndProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 0; wndClass.hInstance = hInstance; wndClass.hIcon = LoadIcon( NULL, IDI_APPLICATION ); wndClass.hCursor = LoadCursor( NULL, IDC_ARROW ); wndClass.hbrBackground =( HBRUSH ) GetStockObject( WHITE_BRUSH ); wndClass.lpszMenuName = NULL; wndClass.lpszClassName = TEXT( "GDI" ); RegisterClass( & wndClass ); hWnd = CreateWindow( TEXT( "GDI" ), TEXT( "-:)" ), WS_SYSMENU, 100, 100, 400, 300, NULL, NULL, hInstance, NULL ); ShowWindow( hWnd, iCmdShow ); UpdateWindow( hWnd ); while( GetMessage( & msg, NULL, 0, 0 ) ) { TranslateMessage( & msg ); DispatchMessage( & msg ); } GdiplusShutdown( gdiplusToken ); return msg.wParam; }
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { HDC hdc; PAINTSTRUCT ps; switch( message ) { case WM_PAINT: hdc = BeginPaint( hWnd, & ps ); OnPaint( hdc ); EndPaint( hWnd, & ps ); return 0; case WM_DESTROY: PostQuitMessage( 0 ); return 0; default: return DefWindowProc( hWnd, message, wParam, lParam ); } } |
|
mikson Temat założony przez niniejszego użytkownika |
» 2016-07-01 10:39:14 Dzięki, a gdzie mogę pobrać to GDIplus i jak wygląda instalacja? |
|
j23 |
» 2016-07-01 11:06:09 GDI+ nie trzeba instalować, wystarczy załączyć odpowiedni nagłówek i dodać bibliotekę gdiplus.a/gdiplus.lib w opcjach projektu. |
|
Gabes |
» 2016-07-01 11:09:01 |
|
mikson Temat założony przez niniejszego użytkownika |
» 2016-07-01 22:35:11 Dziękuję za pomoc. Temat wyczerpany. |
|
mikson Temat założony przez niniejszego użytkownika |
» 2016-07-02 10:44:09 |
|
« 1 » |