JPEG, GIF etc.

This is a discussion on JPEG, GIF etc. within the Windows Programming forums, part of the Platform Specific Boards category; Hi, How should I display JPEG, GIF(animated), etc. in a VC++(6) program crearing in MS VC++(6). Currently I'm only able ...

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    12

    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,

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    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....
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    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.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    12
    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

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    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> ?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    12
    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...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ Equivalent JPEG Functions?
    By stickman in forum C++ Programming
    Replies: 9
    Last Post: 05-06-2006, 10:50 AM
  2. JPEG from resource with GDI+
    By lord mazdak in forum Windows Programming
    Replies: 4
    Last Post: 04-05-2006, 04:23 PM
  3. Displaying a transparent gif
    By Just in forum Windows Programming
    Replies: 2
    Last Post: 05-09-2003, 09:53 PM
  4. Bitmap... gif...jpeg...
    By Devil Panther in forum Windows Programming
    Replies: 2
    Last Post: 01-28-2003, 07:20 AM
  5. jpeg or gif of buttons
    By samudrala_99 in forum Windows Programming
    Replies: 3
    Last Post: 06-03-2002, 09:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21