rendered paste body#include <stdio.h>
#include <stdlib.h>
void create_flag(FILE *file, int flag_color1_r, int flag1_color1_g, int flag_color1_b,
int flag_color2_r, int flag_color2_g, int flag_color2_b, int flag_color3_r,
int flag_color3_g, int flag_color3_b);
int main(void)
{
printf("Creating flag for Lithuania!\n");
FILE *lithp = fopen("lithuania.ppm", "wb");
create_flag(lithp, 253, 185, 19, 0, 106, 68, 193, 39, 45);
printf("Flag Complete!\n");
fclose(lithp);
/*
printf("Creating flag for France!\n");
FILE *franp = fopen("france.ppm", "wb");
printf("Flag Complete!\n");
fclose(franp);
*/
printf("Creating flag for Germany!\n");
FILE *germp = fopen("germany.ppm", "wb");
create_flag(germp, 0, 0, 0, 221, 0, 0, 255, 206, 0);
printf("Flag Complete!\n");
fclose(germp);
return 0;
}
void create_flag(FILE *file, int flag_color1_r, int flag_color1_g, int flag_color1_b,
int flag_color2_r, int flag_color2_g, int flag_color2_b, int flag_color3_r,
int flag_color3_g, int flag_color3_b)
{
int height = 600;
int width = 900;
int i, j;
fprintf(file, "P6\n%d, %d\n255\n", width, height);
for(j = 0; j < height / 3; j++)
{
for(i = 0; i < width; i++)
{
static unsigned char color[3];
color[0] = flag_color1_r;
color[1] = flag_color1_g;
color[2] = flag_color1_b;
fwrite (color, 1, 3, file);
}
}
for(j = (height / 3); j < height - 200; j++)
{
for(i = 0; i < width; i++)
{
static unsigned char color[3];
color[0] = flag_color2_r;
color[1] = flag_color2_g;
color[2] = flag_color2_b;
fwrite (color, 1, 3, file);
}
}
for(j = (height - 200); j <= height; j++)
{
for(i = 0; i < width; i++)
{
static unsigned char color[3];
color[0] = flag_color3_r;
color[1] = flag_color3_g;
color[2] = flag_color3_b;
fwrite (color, 1, 3, file);
}
}
}