Loading & Displaying Images

This is a discussion on Loading & Displaying Images within the C Programming forums, part of the General Programming Boards category; Hi, I am developing a small GK [General Knowledge] game in (Turbo) C. I want to use images such as ...

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    36

    Lightbulb Loading & Displaying Images

    Hi,


    I am developing a small GK [General Knowledge] game in (Turbo) C. I want to use images such as .bmp, .jpg, .gif (animated) when my program starts up.

    Is there any way to do it? Can anybody give me a simple example of C codes that demonstrate how to load and display an image file?

    Thanks in advance!

    Dev.

  2. #2
    Banned
    Join Date
    Dec 2008
    Location
    Maputo, Mozambique
    Posts
    82
    Is this for a DOS program?

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Turbo C is about 15 years old, and doesn't know about Windows - BMP is the native Windows bitmap format. JPEG was standardized in 1992, and I very much doubt that Turbo C has any support for it.

    There are libraries that support either or both of these formats, but I find it unlikely that any of those libraries have compiler support for Turbo C.

    Use a more modern compiler, and write the code for Windows, and you'll have a relatively easy task.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    Registered User
    Join Date
    Dec 2008
    Posts
    36

    Lightbulb

    Hi Mats,



    I am going to install Ms Visual Studio Express 2008 Edition, so, I will use VC++ IDE that is shipped with it.

    So, can I use C codes for achiving the afore mentioned goal? If, yes, then what are the codes that will do the work?


    Thanks!

    Dev.

    Quote Originally Posted by matsp View Post
    Turbo C is about 15 years old, and doesn't know about Windows - BMP is the native Windows bitmap format. JPEG was standardized in 1992, and I very much doubt that Turbo C has any support for it.

    There are libraries that support either or both of these formats, but I find it unlikely that any of those libraries have compiler support for Turbo C.

    Use a more modern compiler, and write the code for Windows, and you'll have a relatively easy task.

    --
    Mats

  5. #5
    Registered User
    Join Date
    Dec 2008
    Posts
    36
    Well, is it possible to display images for a DOS program? I think it is not something impossible with C because I have seen and used certain DOS based Games which make use of images or graphics.

    Quote Originally Posted by c++0x View Post
    Is this for a DOS program?

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yes, you can do this from C or C++.

    Assuming you are writing a Windows applicaton (rather than a console app), the basic functions you need are (amongst others):
    LoadImage()
    BitBlt()

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by devarishi View Post
    Well, is it possible to display images for a DOS program? I think it is not something impossible with C because I have seen and used certain DOS based Games which make use of images or graphics.
    It is certainly possible - but DOS graphics is pretty limited, and you will certainly be much better off with writing such an app for Windows - but it is also harder in some ways (but writing a JPEG library for Turbo C will be quite a lot more work than getting a simple Windows app for this purpose to work - I promise, and Windows LoadImage() already knows how to deal with JPEG images].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    Registered User
    Join Date
    Dec 2008
    Posts
    36
    Okay, Mats!


    I am going to try it under VC++ IDE and will copy and paste my C program codes therein.

    Thanks a lot to everyone over here!

    Quote Originally Posted by matsp View Post
    It is certainly possible - but DOS graphics is pretty limited, and you will certainly be much better off with writing such an app for Windows - but it is also harder in some ways (but writing a JPEG library for Turbo C will be quite a lot more work than getting a simple Windows app for this purpose to work - I promise, and Windows LoadImage() already knows how to deal with JPEG images].

    --
    Mats

  9. #9
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    That's wise. I have some old Turbo C image programs, and they ran with Win2000, OK.

    They don't run at all in WindowsXP (I just tried a few), perhaps because my graphics driver are now different, as is my monitor.

    I love old Turbo C/C++, but I wouldn't use it to display images, at all.

  10. #10
    Registered User
    Join Date
    Dec 2008
    Posts
    36
    Hi Adak,


    That's great! Well, I am also using Windows XP.


    Quote Originally Posted by Adak View Post
    That's wise. I have some old Turbo C image programs, and they ran with Win2000, OK.

    They don't run at all in WindowsXP (I just tried a few), perhaps because my graphics driver are now different, as is my monitor.

    I love old Turbo C/C++, but I wouldn't use it to display images, at all.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Loading Images in C
    By bucyyohare in forum C Programming
    Replies: 5
    Last Post: 02-28-2008, 05:52 PM
  2. Displaying animated images.
    By Queatrix in forum Windows Programming
    Replies: 4
    Last Post: 06-14-2005, 10:53 PM
  3. Displaying images
    By geek@02 in forum Windows Programming
    Replies: 5
    Last Post: 05-09-2005, 03:58 AM
  4. tutorial on displaying images
    By Chobo_C++ in forum C++ Programming
    Replies: 1
    Last Post: 04-04-2004, 05:12 PM
  5. Loading .jpg images from a file
    By Echidna in forum Windows Programming
    Replies: 4
    Last Post: 04-20-2002, 04:09 PM

Tags for this Thread


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