#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    3
    Rep Power
    0

    Exclamation Display an image in c


    I'm new to image processing in C. I want to open and display an image (bmp and yuv format) using C/C++ without using any additional graphics libraries. I read somewhere that pointers can be used for this purpose but i didn't find any code. Can someone give a sample code and source?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    187
    Rep Power
    82
    Here is a Dev Shed post that illustrates the basic concepts of displaying a Windows platform BMP image.
  4. #3
  5. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,377
    Rep Power
    1871
    > I read somewhere that pointers can be used for this purpose
    The days when you could just point directly at video memory, write some bytes and see pixels on the screen are long gone.

    > I want to open and display an image (bmp and yuv format) using C/C++ without using any additional graphics libraries
    Whether you use a graphics library, or use the API of the OS, you're still going to be dependent on external code to see an image on screen.

    Which compiler are you using? If your answer is "TurboC", then the first thing we're going to say is upgrade!
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  6. #4
  7. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,109
    Rep Power
    1802
    Any non-trivial C code is likly to use pointers - they ar e fundamental. Saying that you can use pointers to display images is about as useful as saying you can use bricks to build a house.

    Wat do you mean by "without using any additional libraries"? Additional to what? The standard library has no support for graphics and modern operating systems necessarily control the graphical display through device drivers through which you must access the display, if only so you app plays nicely with others. So you will need at least access the display through OS libraries of some sort - for cross-platform support using a third-party library is beneficial. The "no libraries" constraint is pointless and counter productive. At some level at least you probably have no real alternative.

    Once you have decided how to access the screen, assuming you are not at least going to use a library that already supports your chosen image format, you will need to at least understand that format. For that http://www.wotsit.org/ is your friend.

IMN logo majestic logo threadwatch logo seochat tools logo