Created
May 4, 2019 18:15
-
-
Save pat36/86526415f18249113710b3df8eccb9fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <time.h> | |
#include <stdio.h> | |
#define HEIGHT 640 | |
#define WIDTH 480 | |
#define FIELDS 3 | |
int main(int argc, char** argv) { | |
FILE* f_img; | |
srand(time(nullptr)); | |
unsigned char pix[HEIGHT][WIDTH][FIELDS] = {0}; | |
for(int i = 0; i < HEIGHT; i++) { | |
for(int j = 0; j < WIDTH; j++) { | |
for(int h = 0; h < FIELDS; h++) | |
pix[i][j][h] = std::rand(); | |
} | |
} | |
f_img = fopen("random_image.ppm", "wb"); | |
fprintf(f_img, "P6\n"); | |
fprintf(f_img, "%d %d\n", WIDTH, HEIGHT); | |
fprintf(f_img, "255\n"); | |
fwrite(pix,1, HEIGHT*WIDTH*FIELDS,f_img); | |
fclose(f_img); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment