I have basic programming knowledge and have so far made a good start to my first programming assignment but have now hit a snag. I can honestly say I have no idea on where to go with this and my class notes and research have been of little aid (just can't get the jist of it). By the way im writing code in C language. Im a physics nerd
Q) After declaring the array, generate a smooth transition/gradient between two colours across the 256 wide by 128 high image. Build the colour values into your code to start with, but bear in mind that the finished version will require the user to supply them as 2 sets of 3 values (red, green and blue) between 0 and 255. Range checking should be implemented to ensure that colours outside this range are rejected.
So far, the code ive got to is:
#include <stdio.h>
int main()
{
int pixelarray[128][256];
int x, y;
FILE *image; /* File pointer */
for (x = 0; x <= 128; x++) { /* Nested for loops to contain zero elements */
for (y = 0; y <= 256; y++);}
image = fopen("image.ppm", "w"); /* Creates file to be written */
fprintf(image, "P3\n"); /* Writes to the created file */
fprintf(image, "# image.ppm\n");
fprintf(image, "128 256\n");
fprintf(image, "255\n");
fprintf(image, "%i", pixelarray[x][y]); /* Writes the array into the file */
fclose(image); /* Closes the file */
return 0;
}
Thanks

New Topic/Question
Reply


MultiQuote








|