made vertical_flip first try
This commit is contained in:
+27
-15
@@ -212,7 +212,18 @@ horizontal_flip(unsigned int* buf, int size, int w) {
|
|||||||
|
|
||||||
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));
|
||||||
|
|
||||||
|
int idx = 0;
|
||||||
|
for(int i = h - 1; i >= 0; i--) {
|
||||||
|
for(int k = 0; k < w; k++) {
|
||||||
|
flip[idx] = buf[i * w + k];
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(buf);
|
||||||
|
|
||||||
|
return flip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -247,21 +258,22 @@ main()
|
|||||||
// test = (test << 3) | (test >> (8 - 3));
|
// test = (test << 3) | (test >> (8 - 3));
|
||||||
// print_bits_int(test);
|
// print_bits_int(test);
|
||||||
|
|
||||||
unsigned int color = encoder(200, 10, 50);
|
// unsigned int color = encoder(200, 10, 50);
|
||||||
color = set_alpha(color, 100);
|
// color = set_alpha(color, 100);
|
||||||
print_bits_int(color);
|
// print_bits_int(color);
|
||||||
// unsigned int channelled_color = channel_mask(color, 'g');
|
// // unsigned int channelled_color = channel_mask(color, 'g');
|
||||||
color = chromatic_circular_shift(color, 3);
|
// color = chromatic_circular_shift(color, 3);
|
||||||
print_bits_int(color);
|
// print_bits_int(color);
|
||||||
// int width, height;
|
int width, height;
|
||||||
// char magic_number[3];
|
char magic_number[3];
|
||||||
// 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);
|
||||||
// ppm_decode(buf, (width * height), "../new.ppm", &width, &height);
|
buf = vertical_flip(buf, (width * height), width, height);
|
||||||
// free(buf);
|
ppm_decode(buf, (width * height), "../new.ppm", &width, &height);
|
||||||
|
free(buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user