Displaying an Image with C++

This is a discussion on Displaying an Image with C++ within the C++ Programming forums, part of the General Programming Boards category; Hi, i was wondering how to display an image to screen using c++. Which would be the best way to ...

  1. #1
    Registered User mmarab's Avatar
    Join Date
    Jul 2007
    Posts
    30

    Displaying an Image with C++

    Hi,

    i was wondering how to display an image to screen using c++. Which would be the best way to go about doing this, any help would be great.

    Thanks.
    In times of war, shoot!

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    There isn't a "standard library" way to do that. You will have to either use system specific functions (e.g. Windows API calls) or use a third party library [wxWidgets comes to mind, but I'm no expert at that].

    So we would need to know if you are using Windows or some form of Unix (or some other OS perhaps). Which compiler you are using would also be useful.

    --
    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.

  3. #3
    Registered User mmarab's Avatar
    Join Date
    Jul 2007
    Posts
    30
    Thanks,

    I will be using Windows XP, i like to use Visual C++ Express to do my development. So i guess looking at the Windows API is probably a good place to start.
    In times of war, shoot!

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Ok, so you will first of all need to create a simple window. On top of that, you will have to load the bitmap (using for example LoadImage()), and then use a BitBlt() function to draw the image to the window.

    If you haven't got a book that describes how to do Windows programming, I would suggest that you get one - Charles Petzold (I think that's the correct spelling) have good reputation when it comes for writing books on Windows programming. There are dozens of other good authors too.

    --
    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.

  5. #5
    Registered User mmarab's Avatar
    Join Date
    Jul 2007
    Posts
    30
    Thanks for your help.

    Much appreciated .
    In times of war, shoot!

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,538
    Suggest you load that bitmap and keep it open as long as your program is running. If the window needs repainting, it's much, much faster to redraw a bitmap you have loaded rather than reloading the bitmap and drawing it.
    Consider it an advice.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Jan 2010
    Posts
    31

    How to open/display/write transparent .png win32 api

    Greets,
    I would like to "Open/display/write transparent .png win32 api"
    in "C" Source. Is there maybe a snippet for this?

    Thanks a gig...vmars316

  8. #8
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    681
    Do not bother with WinAPI.

    You cannot just "display it". You will need to have a form processing events, etc. You can use wxWidgets (it is free), but if you are targetting Windows you can use MFC (I am not expert at Visual Studio).
    I never put signature, but I decided to make an exception.

  9. #9
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,538
    In C? Then why are you posting in the C++ forum, then? Unless I am misunderstanding something, that is.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading tiff image files?
    By compz in forum C++ Programming
    Replies: 9
    Last Post: 10-30-2009, 04:17 AM
  2. Loading & displaying an image
    By csonx_p in forum Windows Programming
    Replies: 1
    Last Post: 06-19-2008, 06:40 AM
  3. Displaying an Image
    By evanman in forum C++ Programming
    Replies: 3
    Last Post: 07-07-2006, 01:04 PM
  4. Button Displaying Image
    By mrafcho001 in forum Windows Programming
    Replies: 4
    Last Post: 12-03-2005, 01:14 PM
  5. Displaying a PNG image
    By grep in forum Windows Programming
    Replies: 5
    Last Post: 07-07-2005, 08:27 PM

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