can anybody tell me how to display image in C++ (C-Free)

Recommended Answers

All 7 Replies

What type of image? You're going to need some kind of a library, regardless, as there's nothing in standard C++ that will open an image.

As Jonsca said, you can't just display an image in C++ (well you can, but you wouldn't want to because you'd have to write a lot of complex code that has already been written by other people and packaged into a nice library).

If you want something really easy to start with, you can use the C++ API to Imagemagick, Magick++. There is a very good "gentle introduction" to Magick++ here. Once you have read in your image, you can display it easily with the Magick::Image::display() member function.

Of course, this is only a very simple way to show an image (mainly as a way to check steps in some kind of image processing algorithm). You can't actually interact with the image in any way, except to close the window when you're done. If you want to do something useful and interactive with the image, then you'll need a more sophisticated approach, using QImage from the Qt library, for example.

What is your current understanding of C/C++? Do any of the things that I've said so far have any meaning to you? If not, you might what to consider focussing on some more basic principles before tackling image processing and display...

well you can, but you wouldn't want to because you'd have to write a lot of complex code that has already been written by other people and packaged into a nice library).

That's an excellent point. I should clarify the issue when I say that, I meant that there's no single function or class specific to the task of image manipulation. Certainly, you can read the file directly as binary, as ravenous is attesting.

ok i understand what you said . Yesterday i downloaded two librarys call "allegro" and "cximage" but i don't understand how to use it . if anyone know plz tell me .

ok i understand what you said . Yesterday i downloaded two librarys call "allegro" and "cximage" but i don't understand how to use it . if anyone know plz tell me .

Did you read the manual? There are probably examples on their websites.

Or, do you mean that you don't know how to use any external library in you code at all? Because that's a different question.

First, learn to use Allegro. Start here: http://wiki.allegro.cc/index.php?title=Allegro_5_Tutorial
Start with this one: http://wiki.allegro.cc/index.php?title=Allegro_5_Tutorial#Installing_Tutorials
Get your Allegro libraries setup in your compiler. Then get them ready to link into your project. (Many times, you will need to tell it to link in both Debug and Release configurations).

Now check out the code tutorials:
http://wiki.allegro.cc/index.php?title=Allegro_5_API_Tutorials

Once you get that, copy and paste the code. Try it and compile.
If it doesn't work and you're using image files, there's a good chance you need to copy the data files into the same folder as where the program is executing from.

Once you get Allegro done, let us know and we'll help you get CXImage working in it. For now, focus on Allegro.

Good luck and happy coding!

HI DeanMSands3,
Thanx for the allegro information. I tried and i'm able to execute sample program that is mentioned in Allegro tutorial. I set all the necessary project settings as mentioned in the link. But i'm not able to build it in debug mode. Its giving build error as "Cannot open Odbcc32.dll file". I can able to build and run it in release mode.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.