Implemented image flipper
This commit is contained in:
parent
efb8fb1703
commit
3acdd717b1
22
src/pixeldata_utils.c
Normal file
22
src/pixeldata_utils.c
Normal file
@ -0,0 +1,22 @@
|
||||
//
|
||||
// Created by marcsello on 03/11/2020.
|
||||
//
|
||||
|
||||
#include "pixeldata_utils.h"
|
||||
|
||||
uint8_t flip_image(const uint8_t *source, uint8_t *destination, uint64_t data_length, uint64_t width, uint64_t height) {
|
||||
|
||||
if ((width*height*3) != data_length) {
|
||||
return IMAGE_FLIP_FAIL;
|
||||
}
|
||||
|
||||
for (uint64_t i = 0; i < height; i++) {
|
||||
for (uint64_t j = 0; j < width; j++) {
|
||||
destination[(i * width + j) * 3] = source[((height - i - 1) * width + j) * 3];
|
||||
destination[(i * width + j) * 3 + 1] = source[((height - i - 1) * width + j) * 3 + 1];
|
||||
destination[(i * width + j) * 3 + 2] = source[((height - i - 1) * width + j) * 3 + 2];
|
||||
}
|
||||
}
|
||||
|
||||
return IMAGE_FLIP_SUCCESS;
|
||||
}
|
15
src/pixeldata_utils.h
Normal file
15
src/pixeldata_utils.h
Normal file
@ -0,0 +1,15 @@
|
||||
//
|
||||
// Created by marcsello on 03/11/2020.
|
||||
//
|
||||
|
||||
#ifndef CAFF_PREVIEWER_PIXELDATA_UTILS_H
|
||||
#define CAFF_PREVIEWER_PIXELDATA_UTILS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define IMAGE_FLIP_SUCCESS 0
|
||||
#define IMAGE_FLIP_FAIL 0
|
||||
|
||||
uint8_t flip_image(const uint8_t* source, uint8_t* destination, uint64_t data_length, uint64_t width, uint64_t height);
|
||||
|
||||
#endif //CAFF_PREVIEWER_PIXELDATA_UTILS_H
|
Loading…
Reference in New Issue
Block a user