Bild anzeigen
-
Ich hoffe ich verärgere nicht viele Leute, weil das ganze schon tausend mal besprochen wurde... habe aber bis jetzt nichts gefunden was mir hilft...
Gibt es eine Möglichkeit ein Bild (.jpg) mit der WinAPI darzustellen? also ohne irgendwelche extrabibliotheken??
-
Die Win-Api kann mit Bildern im Format *.bmp umgehen. Wenn du keine Bibliotheken einsetzen willst, machen die meisten Bildbearbeitungsprogramme die Umwandlung von JPG nach BMP.
-
hmm... das ist zu umständlich, dann also doch mit bibliotheken...
was kannst du/ihr mir empfehlen? Ich will ganz einfach fotos in einem Normalen Fenster darstellen, mer muss nicht gehen und es sollte relativ einfach sein... wenn möglich...
-
Mit IPicture kannst du laden jpg, gif, bmp...
#include <olectl.h> HBITMAP LoadImg(WCHAR *path, int *lpWidth, int *lpHeight) { HBITMAP outbm = 0; CoInitialize(NULL); IPicture *pic; if (!OleLoadPicturePath(path, 0, 0, 0, IID_IPicture, (void**)&pic)) { OLE_XPOS_HIMETRIC ole_w, ole_h; pic->get_Width(&ole_w); pic->get_Height(&ole_h); HDC deskdc = GetDC(NULL); HDC outdc = CreateCompatibleDC(deskdc); int w,h; w = MulDiv(ole_w, GetDeviceCaps(outdc, LOGPIXELSX), 2540); h = MulDiv(ole_h, GetDeviceCaps(outdc, LOGPIXELSY), 2540); if (lpWidth) *lpWidth=w; if (lpHeight) *lpHeight=h; // alloc new bitmap and render the image outbm = CreateCompatibleBitmap(deskdc, w,h); HGDIOBJ oldbm = SelectObject(outdc,outbm); pic->Render(outdc, 0,0,w,h,0, ole_h, ole_w, -ole_h, NULL); SelectObject(outdc,oldbm); ReleaseDC(NULL, deskdc); DeleteDC(outdc); pic->Release(); } CoUninitialize(); return outbm; }