Hi !
I am trying to do a game for children to test their attention. So I have two images and they have to find out the differences between the images. How can I open the image on c++?
I also have a specie of questionair to see how many differents the kids found out. Can I open the image in the same window the questionair will be?
Thanks
This is what I have until now

#include <ctime>
#include <cstdlib> 
#include <string>
#include <iostream> /* to open the image */
#include <fstream> 
#include <iostream> /* to count the time taken to find out what the differences are*/
#include <stdio.h>
#include <time.h>

using namespace std;

/*int main (){

    int number; 
        int time; 

}*/

/*cout << "There are six differences between these two pictures. What are them?";*/

int main()

{
    int number; /*declaration of the variable number*/
    int duration; /*declaration of the variable time*/
    int answer; /* declaration of the variable answer*/


    std::cout << "There are six differences between these two pictures. What are them?";
ifstream image;
image.open("C:\\Documents and Settings\\B\\Desktop\\differences.jpeg");

clock_t startTime = clock();

std::cout <<"How many correct differences?";

cout <<" A) Zero" << endl;

cout << "B) One" << endl;

cout << "C) Two" << endl;

cout << "D) Three" << endl;

cout << "E) Four" << endl;

cout << "F) Five" << endl;

cout << "G) Six" << endl;
 std::cin >> number;
std::cout<< "The number of differences found was " << number  << std:: endl;



/*clock_t endTime = clock();
duration = endTime - startTime;
double timeInSeconds = clockTicksTaken / (double) CLOCKS_PER_SEC;*/


            if (answer == 'a' || answer == 'A')

{

cout << "duration=5 minutes"
     << "number of differences=0"<<endl;

          }

           if (answer == 'b' || answer == 'B')
           {

cout << "duration=5 minutes"
     <<"number of differences=1"<<endl;

           }

             if (answer == 'c' || answer == 'C')
             {

cout << "duration=5 minutes"
     <<"number of differences=2"<<endl;

          }

              if (answer == 'd' || answer == 'D')
             {

cout << "duration=5 minutes"
     <<"number of differences=3"<<endl;

          }

              if (answer == 'e' || answer == 'E')
             {

cout << "duration=5 minutes"
     << "number of differences=4"<<endl;

          }

              if (answer == 'f' || answer == 'F')
             {

cout << "duration=5 minutes"
     << "number of differences=5"<<endl;

          }             
              if (answer == 'g' || answer == 'G')
             {

cout << "duration=5 minutes"
     <<"number of differences=6"<<endl;

          }

           else
           {

             clock_t endTime = clock();
             duration = endTime - startTime;
             /*double timeInSeconds = clockTicksTaken / (double) CLOCKS_PER_SEC;*/

             return 0;
         }

        cout << endl;
        }; 

How much programming experience do you have, and with what languages? C++ is a low-level language; there are various definitions of what this means, but for the purposes of this conversation, it means that you have the flexibility and control to do an enormous amount with very few restrictions, but the trade-off is that many things that you might think are simple require significant work. For example, showing an image on the monitor.

A small digression; showing an image on a monitor is actually really complicated and difficult. It is. A number of high-level languages make it seem easy, by abstracting away an awful lot of the complexity. Showing an image on a monitor is a negotitation between you, your programming language, the operating system, the video driver, and the physical hardware itself. The price of higher-level languages that make this appear easy is limitations on what you can do; with a high-level language, you surrender some control in exchange for being able to do some things far more easily. Anyway, end of digression.

C++ (and C) are gifted with an enormous number of libraries. You can think of a library as a set of code that someone else wrote, that you can make use of. Some of these libraries involves displaying images on the monitor (and, as with the high-level languages, when you use a library to do this, the gain is that you can do some things more easily; the loss is that you lose some fine control - you can only do what the library lets you).

C++ does not come with any understanding of any particular kind of file. All files are just long sequences of numbers; every file needs to be interpreted to get the useful information out. Image files can be very complicated, and can require a significant amount of processing and understanding before you know what colour each pixels is. Fortunately, other people have written libraries to handle this difficulty for you. So, what you need is a library that will allow you to display images.

I often recommend a library named CImg to beginners. This library has, as they all do, advantages and disadvantages. THe most important advantage here is that it is a single header file, so all you need do is download the single header file from the CImg website, put it next to your existing code, and put this code at the top:

#include "CImg.h"
using namespace_cimg_library

Showing an image on the monitor then becomes as simple as this code (depending on what operating system you're using; I have a memory that to do this under windows requires the additional installation of some other libraries, which is unfortunate):

#include "CImg.h"
#include <iostream>
using namespace cimg_library;

int main()
{

  CImg<unsigned char> image("/directory/path/someImage.jpg");
  CImgDisplay main_disp(image);
  std::cin.ignore();
}

hello
i am natan hailu
first download virtual basic 2008/2010 edition
my question is how to desing my software

natanhailu: I realize that you are a newcomer here, but there are some pieces of netiquette you should be made aware of. First off, you should not post a new question in another poster's existing thread unless the question has some bearing on what is already being discussed. Doing that is called 'thread hijacking' and is considered rude, as it derails the thread from its original purpose. If you have a new question, please start a new thread.

Second, there are separate fora for different languages. The forum you have posted to is the one for the C++ programming language. If you have a question about Visual Basic .NET, you should post it in the appropriate forum on the message board.

Third, clarity is paramount when posting in any technical forum, mailing list or newsgroup. You need to be as specific as possible about the problem you are having and the help you are looking for.

I hope that these comments are taken in the spirit they are intended, and that they help you with future posts on Daniweb and elsewhere. I would recommend going over the forum rules and reading 'How to Ask Questions th Smart Way' by Eric S. Raymond for further advice.

Best for pictures is OpenGl or DirectX, however you would be able to read it like binry file, but that is just waste of time for that, there is way easier thing for that..

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.