Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <time.h>
- #define LENGTH 640
- #define HEIGHT 480
- typedef unsigned int uint;
- int **img_array;
- FILE *image;
- int main( void )
- {
- srand ( time(NULL) );
- uint rows, cols;
- image = fopen("../myimage.raw", "wb");
- img_array = (int**) malloc ( LENGTH * HEIGHT * sizeof(int) );
- if(img_array == NULL)
- {
- free(image);
- free(img_array);
- exit(1);
- }
- for(rows=0; rows<LENGTH; rows++)
- {
- for(cols=0; cols<HEIGHT; cols++)
- {
- img_array[rows][cols] = rand()%2;
- fwrite(img_array, sizeof(int), sizeof(img_array), image);
- }
- }
- printf("write complete.\n");
- free(img_array);
- fclose(image);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement