tennvolsmb
March 1st, 2012, 11:51 PM
Okay so I'm trying to make a ppm image for a class that creates 3 vertical bars of different colors (similar to how the French flag looks) but every time I run my code I get slanted bars...
Any help would be greatly appreciated!
#include <stdio.h>
void make_pixel(int r, int g, int b)
{
printf("%c%c%c", r, g, b);
}
void make_ppm_header(int width, int height)
{
printf("P6\n");
printf("%d %d %d\n", width, height, 255);
}
void make_ppm_image(int width, int height)
{
int count, hcount;
make_ppm_header(width, height);
int size = height * width;
for(hcount = 0; hcount <= height; hcount++)
{
for(count = 0; count < width * 1 / 3; count++)
{
make_pixel(128, 192, 85);
}
for(count = count; count < width * 2 / 3; count++)
{
make_pixel(84, 92, 139);
}
for(count = count; count <= width; count ++)
{
make_pixel(74, 29, 84);
}
}
}
int main()
{
int height = 133, width = 200;
make_ppm_header(width, height);
make_ppm_image(width, height);
return 0;
}
Any help would be greatly appreciated!
#include <stdio.h>
void make_pixel(int r, int g, int b)
{
printf("%c%c%c", r, g, b);
}
void make_ppm_header(int width, int height)
{
printf("P6\n");
printf("%d %d %d\n", width, height, 255);
}
void make_ppm_image(int width, int height)
{
int count, hcount;
make_ppm_header(width, height);
int size = height * width;
for(hcount = 0; hcount <= height; hcount++)
{
for(count = 0; count < width * 1 / 3; count++)
{
make_pixel(128, 192, 85);
}
for(count = count; count < width * 2 / 3; count++)
{
make_pixel(84, 92, 139);
}
for(count = count; count <= width; count ++)
{
make_pixel(74, 29, 84);
}
}
}
int main()
{
int height = 133, width = 200;
make_ppm_header(width, height);
make_ppm_image(width, height);
return 0;
}