I am taking a computer graphics class, and I need to work with textures, but I can't use any library to do it. I am stuck on loading the rgb values of the images I need to use (the images can be in any format, jpg, raw, png, etc..) so my question is, which is the easiest way to get the rgb values of an image (of any format) without using any libraries to get this values?? Here is what I found already on the site:

```
    unsigned char *data;
    File *file;

    file = fopen("image.png", "r");//

    data = (unsigned char *)malloc(TH*TV*3); //TH and TV are both 50

    fread(data, TH*TV*3, 1, file);
    fclose(file);

    int i;

    for(i=0;i<TH*TV*3;i++){
       //suposing I have a struct RGB for the rgb values
       RGB.r = data[?];// how do I get the r value
       RGB.g = data[?];// how do I get the g value
       RGB.b = data[?];// how do I get the b value
    }

```

Thanks