-
JPEG, GIF etc.
Hi,
How should I display JPEG, GIF(animated), etc. in a VC++(6) program crearing in MS VC++(6).
Currently I'm only able to display BITMAPS, by using following code :
Code:
void DisplayPic(HWND hwnd, char* path)
{
thePic = (HBITMAP)LoadImage(0 , path, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
SendDlgItemMessage(hwnd, IDC_PIC, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)thePic);
}
Thanks,
-
It appears that with most of Microsoft's Graphics API's that objects capable of handling bitmaps, can handle JPEGs, GIFs (not sure about animated), and other formats too, though my search didn't turn up much specifically about MSVC, so I'm not sure. Try having a look at MSDN yourself, or just trying it.
-
C / C++ / MFC?
GDI+ (not GDI) or other library will do it (ie ImageSource by SmallerAnimals software *not free but very good*).
IIRC MSVC v6 has GDI+ (v5 is just GDI). Look at the GDI+ Image class, specifically Image::FromFile() (Gdiplus.h)
Search here for more info as this has been answered before....
-
There's also the older OleLoadPicture and OleLoadPicturePath.
Don't know if it's any good but here's an example of gif animation with mfc.
This approach does require more knowledge of the image file formats so you should probably prefer the gdiplus route as recommended by Novacain.
-
Thanks Ken for the link.
I also tried the GDI+, but GDI+ is failing on my VC6,
here is the output from build window:
--------------------Configuration: TestDlg - Win32 Debug--------------------
Compiling...
StdAfx.cpp
c:\program files\microsoft visual studio\vc98\include\gdiplusinit.h(32) :
error C2065: 'ULONG_PTR' : undeclared identifier
c:\program files\microsoft visual studio\vc98\include\gdiplusinit.h(32) :
error C2065: 'token' : undeclared identifier
c:\program files\microsoft visual studio\vc98\include\gdiplusinit.h(32) :
error C2165: 'left-side modifier' : cannot modify pointers to data
c:\program files\microsoft visual studio\vc98\include\gdiplusinit.h(32) :
error C2071: 'NotificationHookProc' : illegal storage class
c:\program files\microsoft visual studio\vc98\include\gdiplusinit.h(33) :
error C2146: syntax error : missing ')' before identifier 'token'
c:\program files\microsoft visual studio\vc98\include\gdiplusinit.h(33) :
error C2165: 'left-side modifier' : cannot modify pointers to data
c:\program files\microsoft visual studio\vc98\include\gdiplusinit.h(33) :
error C2071: 'NotificationUnhookProc' : illegal storage class
c:\program files\microsoft visual studio\vc98\include\gdiplusinit.h(33) :
error C2059: syntax error : ')'
c:\program files\microsoft visual studio\vc98\include\gdiplusinit.h(86) :
error C2059: syntax error : 'const'
c:\program files\microsoft visual studio\vc98\include\gdiplusinit.h(95) :
error C2146: syntax error : missing ')' before identifier 'token'
c:\program files\microsoft visual studio\vc98\include\gdiplusinit.h(95) :
warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft visual studio\vc98\include\gdiplusinit.h(95) :
error C2182: 'GdiplusShutdown' : illegal use of type 'void'
c:\program files\microsoft visual studio\vc98\include\gdiplusinit.h(95) :
error C2059: syntax error : ')'
Error executing cl.exe.
TestDlg.exe - 12 error(s), 1 warning(s)
--------------------
--when I tried to create a MFC-Dialog-based application, No idea what's
going on..
I downloaded GDI+ from http://www.codeproject.com/vcpp/gdiplus/codemaze.asp
OS: Win98SE
MSVC++(6)
--- What to do? Oh! please help...
(please note I cann't afford to install the entire SDK from MS web-site.)
thanks,
playwin
-
You have included in the stdafx.h
(and they all exist and are in your include path)
#include <afxwin.h>
#include <afxext.h>
#include <afxdisp.h>
#include <afxdtctl.h>
BEFORE
#include <gdiplus.h> ?
-
Thank You, I tracked down the problem.
I think that Ken's link is quite good, but having problem for createing scrollview for that class.
Any idea about this...