Can't get desired data value from array

Discussion in 'C++' started by trapeze, Sep 8, 2007.

  1. trapeze

    trapeze New Member

    Joined:
    Sep 7, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    part of the code, reading an image file into memory
    --------------------------------------------------------
    unsigned char Picture[Size][Size][BytesPerPixel];

    if (!(file=fopen(argv[1],"rb")))
    {
    cout << "Cannot open picture: " << argv[1] <<endl;
    exit(1);
    }
    fread(Picture, sizeof(unsigned char), Size*Size*BytesPerPixel, file);
    fclose(file);
    ---------------------------------------------------------
    when i tryied to get the value of the 1st element in Picture, i put

    cout << Picture[0][0][0] << endl; after fread(.... before flose(file); ,

    it turned out to be nothing printed on my WinXP command prompt. However, the image file was stored successfully because i got the desired image after end of execution(store pic and spit out the exact same pic). the problem is i couldn't get the values stored in Picture.


    any ideas ? thx. ...racking my brain....
     
  2. trapeze

    trapeze New Member

    Joined:
    Sep 7, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Hi

    Any one can pitch in a bit ? I will really appreciate your help.:confused:
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice