Thread: reading pixels from y frame (yuv frame) using fread()?

  1. #1
    Registered User
    Join Date
    Sep 2006

    reading pixels from y frame (yuv frame) using fread()?

    hi..i would like to know to read pixels and later store the pixel values in i use fread()? if yes how? this is a part of my code..please reply ASAP...thank you
    fseek(vidf, 0L, SEEK_SET); //same as rewind(vidf)
       //initialize array
            for(colpixels=0; colpixels<width; colpixels++){
               fread(ttemp, sizeof(char), 1, vidf);
    			grayscaleV = *ttemp;
                inityHist[grayscaleV] = inityHist[grayscaleV] + 1; //to check the ocurences of pixel
    Last edited by Salem; 09-17-2006 at 05:35 AM. Reason: Added code tags - please learn to use them

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    All things being equal, like ttemp pointing at some valid memory, and say the file opened with "rb" mode, and the initial fseek offset being OK, it should be fine.
    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.

  3. #3
    Registered User mikahell's Avatar
    Join Date
    Jun 2006
    This stuff is interesting me. I would like to know how this is working out. Do you have to use a pointer to the video memory? I don't get that:
    Is this supposed to point on pixel memory? Is this in a file?

    I'm all mixed up.

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Since fseek sets the file position in a file, I'd guess it seeks (54+4*256) characters from the beginning of the file (SEEK_SET).

    [edit] sizeof(char) is always 1, but you can leave it in if you want to. [/edit]

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. reading words using fread
    By -EquinoX- in forum C Programming
    Replies: 22
    Last Post: 05-05-2008, 02:09 PM
  2. reading BMP files and pixels' colours
    By Xavier in forum C++ Programming
    Replies: 3
    Last Post: 12-16-2005, 04:19 AM
  3. fread - reading strings and integers.
    By Vber in forum C Programming
    Replies: 1
    Last Post: 11-17-2002, 03:08 PM
  4. Replies: 1
    Last Post: 06-06-2002, 04:17 PM
  5. fread is reading too much
    By CeeCee in forum C Programming
    Replies: 7
    Last Post: 02-18-2002, 02:44 PM
Website Security Test