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*
|
||||
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));
|
||||
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);
|
||||
return flip;
|
||||
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
int idx = 0;
|
||||
for(int i = h - 1; i >= 0; i--) {
|
||||
for(int k = 0; k < w; k++) {
|
||||
for (int i = h - 1; i >= 0; i--)
|
||||
{
|
||||
for (int k = 0; k < w; k++)
|
||||
{
|
||||
flip[idx] = buf[i * w + k];
|
||||
idx++;
|
||||
}
|
||||
@@ -230,7 +242,6 @@ vertical_flip(unsigned int* buf, int size, int w, int h) {
|
||||
return flip;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
print_bits_int(unsigned int n)
|
||||
{
|
||||
@@ -273,10 +284,10 @@ main()
|
||||
int max_val;
|
||||
|
||||
unsigned int* buf =
|
||||
ppm_encode("../test.ppm", &width, &height, &max_val,
|
||||
magic_number);
|
||||
ppm_encode("../test.ppm", &width, &height, &max_val, magic_number);
|
||||
// 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);
|
||||
free(buf);
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user