Thread: How to use loadJPG function from library jpeg?

  1. #76
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Also, you need to move forward in your histogram so that you don't print the same four entries over and over and over again. If you need to use fwrite, then you should be adding 4 to histogram every time through the loop. (Not to *histogram, but to histogram). If you end up using fprintf, then you'll need to use an index on histogram (like histogram[i]) that should move forward.

  2. #77
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    int intarray[ X ] = { filledwithcolor }, *intptr = intarray;
    char chararray[ (X/COLS) * (1+sizeof(int)) ] = {0}, *charptr = chararray;
    
    while( charptr < chararray + sizeof( chararray ) )
    {
        size_t col;
        for( col = 0; col < COLS; col++ )
            *((int*)charptr++) = *intptr++;
        *charptr++ = '\n';
    }
    fwrite( chararray, sizeof( chararray ), 1, fp );
    :shiftyeyes:

    [edit]
    that cast / increment is bugging me. Let's go with this:
    Code:
    union u
    {
        char *cp;
        int *ip;
    } hah;
    
    int intarray[ X ] = { filledwithcolor }, *intptr = intarray;
    char chararray[ (X/COLS) * (1+sizeof(int)) ] = {0};
    
    for( hah.cp = chararray; hah.cp < chararray + sizeof( chararray ); *hah.cp++  = '\n' )
    {
        size_t col;
        for( col = 0; col < COLS; col++ )
            *(hah.ip++) = *intptr++;
    }
    fwrite( chararray, sizeof( chararray ), 1, fp );
    If a union isn't the right answer, you're asking the wrong question!
    [/edit]


    Quzah.
    Last edited by quzah; 07-29-2011 at 10:06 PM.
    Hope is the first step on the road to disappointment.

  3. #78
    Normander the Barbarian TheReceptionist's Avatar
    Join Date
    Jul 2011
    Location
    Gainesville,FL
    Posts
    24
    fprintf worked! =D

    program is officially done and fully functional!! /victorydance

    thanks, fellow programmers, i couldnt have done with without you!!!! <3 <3 <3 <3 <3

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. function library (from scratch)?
    By SirJiub in forum C Programming
    Replies: 7
    Last Post: 06-05-2011, 01:48 PM
  2. how to know which function belongs to which library?
    By gibsosmat in forum Linux Programming
    Replies: 8
    Last Post: 11-18-2007, 07:46 AM
  3. The mathematical function library in C++
    By turkertopal in forum C++ Programming
    Replies: 3
    Last Post: 10-08-2005, 06:54 AM
  4. Library Function to verify Int
    By Mr_roboto in forum C++ Programming
    Replies: 24
    Last Post: 09-29-2005, 02:11 PM
  5. library function
    By darfader in forum C Programming
    Replies: 4
    Last Post: 09-10-2003, 09:38 PM

Tags for this Thread