jeudi 29 octobre 2015

Read PPM files RGB values c++

I´m trying read from a PPM file. I want to read the first, second and third number from each row, in this file, but i don´t know how to read the lines.

This is what i have so far:

    for (int y = 4; y <= HEIGHT; y++) { // i think it has to start on row 4 
            for (int x = 1; x <= WIDTH; x++) { // and x from 1

            int r = CurrentR(x * y);
            int g = CurrentG(x * y);
            int b = CurrentB(x * y);

            img << r << " " << g << " " << b << endl;
    }   
}

int CurrentR(int xy) {
    return // the first number in row xy
}
int CurrentG(int xy) {
    return // the second number in row xy
}
int CurrentB(int xy) {
    return // the third number in row xy
}

Correct me if i´m wrong of course.

Aucun commentaire:

Enregistrer un commentaire