Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

[winAPI] Biblioteka ładująca JPG/PNG

Ostatnio zmodyfikowano 2016-07-02 10:44
Autor Wiadomość
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
P-149536
carlosmay
» 2016-06-30 15:58:29
P-149537
Gabes
» 2016-06-30 20:44:31
GDIplus


C/C++
#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;

void OnPaint( HDC hdc )
{
    Graphics graphics( hdc );
    Image obrazekPNG( L"obrazek.png" ); // obrazek
    Image obrazekJPG( L"obrazek.jpg" ); // obrazek
    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;
   
    // Inicjowanie GDIplus.
    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 ); /// wyświetlanie
        EndPaint( hWnd, & ps );
        return 0;
       
    case WM_DESTROY:
        PostQuitMessage( 0 );
        return 0;
        default:
        return DefWindowProc( hWnd, message, wParam, lParam );
    }
}
P-149552
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?
P-149562
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.
P-149566
Gabes
» 2016-07-01 11:09:01
P-149567
mikson
Temat założony przez niniejszego użytkownika
» 2016-07-01 22:35:11
Dziękuję za pomoc. Temat wyczerpany.
P-149602
mikson
Temat założony przez niniejszego użytkownika
» 2016-07-02 10:44:09
P-149605
« 1 »
  Strona 1 z 1