he shoots and misses try again
This commit is contained in:
+20
-9
@@ -206,21 +206,33 @@ chromatic_circular_shift(unsigned int clr, int n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int*
|
unsigned int*
|
||||||
horizontal_flip(unsigned int* buf, int size, int w, int h) {
|
horizontal_flip(unsigned int* buf, int size, int w, int h)
|
||||||
|
{
|
||||||
unsigned int* flip = malloc((w * h) * sizeof(unsigned int));
|
unsigned int* flip = malloc((w * h) * sizeof(unsigned int));
|
||||||
|
int idx = 0;
|
||||||
|
for (int i = 0; i < w; i++)
|
||||||
|
{
|
||||||
|
for (int k = h - 1; k >= 0; k--)
|
||||||
|
{
|
||||||
|
flip[idx] = buf[i * w + k];
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
return flip;
|
return flip;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int*
|
unsigned int*
|
||||||
vertical_flip(unsigned int* buf, int size, int w, int h) {
|
vertical_flip(unsigned int* buf, int size, int w, int h)
|
||||||
|
{
|
||||||
unsigned int* flip = malloc((w * h) * sizeof(unsigned int));
|
unsigned int* flip = malloc((w * h) * sizeof(unsigned int));
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for(int i = h - 1; i >= 0; i--) {
|
for (int i = h - 1; i >= 0; i--)
|
||||||
for(int k = 0; k < w; k++) {
|
{
|
||||||
|
for (int k = 0; k < w; k++)
|
||||||
|
{
|
||||||
flip[idx] = buf[i * w + k];
|
flip[idx] = buf[i * w + k];
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
@@ -230,7 +242,6 @@ vertical_flip(unsigned int* buf, int size, int w, int h) {
|
|||||||
return flip;
|
return flip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
print_bits_int(unsigned int n)
|
print_bits_int(unsigned int n)
|
||||||
{
|
{
|
||||||
@@ -273,10 +284,10 @@ main()
|
|||||||
int max_val;
|
int max_val;
|
||||||
|
|
||||||
unsigned int* buf =
|
unsigned int* buf =
|
||||||
ppm_encode("../test.ppm", &width, &height, &max_val,
|
ppm_encode("../test.ppm", &width, &height, &max_val, magic_number);
|
||||||
magic_number);
|
|
||||||
// ppm_apply_brightness(buf, (width * height), .5);
|
// ppm_apply_brightness(buf, (width * height), .5);
|
||||||
buf = vertical_flip(buf, (width * height), width, height);
|
// buf = vertical_flip(buf, (width * height), width, height);
|
||||||
|
buf = horizontal_flip(buf, (width * height), width, height);
|
||||||
ppm_decode(buf, (width * height), "../new.ppm", &width, &height);
|
ppm_decode(buf, (width * height), "../new.ppm", &width, &height);
|
||||||
free(buf);
|
free(buf);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user