// (Worksheet 4-8-1s - Images. ) // Copy the following code into your active project file // // (Worksheet 4-8-1s Number 4) // Copy the graphics file supplied by your teammembers to the same directory as your code file // This line should go somewhere near the top of your file. // Edit it to exactly match the name of the file as it appears on the tab. The quote marks are necessary. // Make sure that their are no spaces or special characters in the filename - the code won't work if there are. // This line brings in the graphics file #include “myGraphicsFile.c” // (Worksheet 4-8-1s Number 5) // Create a function to return the value of a pixel from gimp_image given a row, column and color. // Use width and bytes_per_pixel as stored in the struct so the function will work even if these parameters change. // This function should return an integer (int, not void). Check that the name of the struct variable matches // the code in your graphics file. // This function returns the intensity value for the pixel at row, column and color // It only works if with 24-bit rgb color files int getPixel(int row, int column, int color) { int index = (row * gimp_image.width + column ) * gimp_image.bytes_per_pixel; return gimp_image.pixel_data[index + color]; } // The rest of the code goes INSIDE your main loop() function. We haven't done anything there yet. // If you have, you may want to delete what's there and replace it with this. // (Worksheet 4-8-1s Number 6) // Create a for loop that cycles through each of the columns in the picture (gimp_image.width) for(int column =0; column<8 ; column++) { // (Worksheet 4-8-1s Number 7) // Inside the column for loop create another for loop which cycles through the 3 colors (r, g and b). // Turn the appropriate color pins on inside this loop for (;;) { // (Worksheet 4-8-1s Number 8) // Inside the color loop create a loop which counts from 0 to 255. // This loop will adjust the intensity. // If a pixel value is greater than the loop counter we turn it ON, // otherwise we turn it off. A pixel with a value of 127 will be on for half of the time. for (;;) { // (Worksheet 4-8-1s Number 9) // Create one final loop which cycles through the eight rows. // In this loop use getPixel(row, column, color) // and an if() and else command to check if we should turn the pixel on or off. } } } // (Worksheet 4-8-1s Number 10) // Clear the row and column pins after the loops have executed so that we don’t leave anything on. // end of main loop