REFACTOR: I forgot to actually change the function logic after rename;
The functions take in {width,height} to use instead of PPM image
containers. The function only pulled len, width and height so I just
imported them instead for all image types to be used.
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
* @retval NULL If original buffer is invalid or if new buffer fails to create
|
* @retval NULL If original buffer is invalid or if new buffer fails to create
|
||||||
* */
|
* */
|
||||||
unsigned int*
|
unsigned int*
|
||||||
u32_flop(const unsigned int* buf, const PPM img);
|
u32_flop(const unsigned int* buf, const int width, const int height);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Flips image on Y-Axis
|
* @brief Flips image on Y-Axis
|
||||||
@@ -25,7 +25,7 @@ u32_flop(const unsigned int* buf, const PPM img);
|
|||||||
* @retval NULL If original buffer is invalid or if new buffer fails to create
|
* @retval NULL If original buffer is invalid or if new buffer fails to create
|
||||||
* */
|
* */
|
||||||
unsigned int*
|
unsigned int*
|
||||||
ppm_flip(const unsigned int* buf, const PPM img);
|
u32_flip(const unsigned int* buf, const int width, const int height);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Rotates image on 90 Clockwise
|
* @brief Rotates image on 90 Clockwise
|
||||||
|
|||||||
+12
-10
@@ -6,25 +6,26 @@
|
|||||||
#include "image/utils.h"
|
#include "image/utils.h"
|
||||||
|
|
||||||
unsigned int*
|
unsigned int*
|
||||||
u32_flop(const unsigned int* buf, const PPM img)
|
u32_flop(const unsigned int* buf, const int width, const int height)
|
||||||
{
|
{
|
||||||
if (!buf)
|
if (!buf)
|
||||||
{
|
{
|
||||||
LOGERROR(ERR_BUF_NULL);
|
LOGERROR(ERR_BUF_NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
unsigned int* flip = malloc(img.len * sizeof(unsigned int));
|
int len = width * height;
|
||||||
|
unsigned int* flip = malloc(len * sizeof(unsigned int));
|
||||||
if (!flip)
|
if (!flip)
|
||||||
{
|
{
|
||||||
LOGERROR(ERR_CREATION_FAIL);
|
LOGERROR(ERR_CREATION_FAIL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for (int i = 0; i < img.height; i++)
|
for (int i = 0; i < height; i++)
|
||||||
{
|
{
|
||||||
for (int k = img.width - 1; k >= 0; k--)
|
for (int k = width - 1; k >= 0; k--)
|
||||||
{
|
{
|
||||||
flip[idx] = buf[(i * img.width) + k];
|
flip[idx] = buf[(i * width) + k];
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,14 +35,15 @@ u32_flop(const unsigned int* buf, const PPM img)
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int*
|
unsigned int*
|
||||||
u32_flip(const unsigned int* buf, const PPM img)
|
u32_flip(const unsigned int* buf, const int width, const int height)
|
||||||
{
|
{
|
||||||
if (!buf)
|
if (!buf)
|
||||||
{
|
{
|
||||||
LOGERROR(ERR_BUF_NULL);
|
LOGERROR(ERR_BUF_NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
unsigned int* flip = malloc(img.len * sizeof(unsigned int));
|
int len = width * height;
|
||||||
|
unsigned int* flip = malloc(len * sizeof(unsigned int));
|
||||||
if (!flip)
|
if (!flip)
|
||||||
{
|
{
|
||||||
LOGERROR(ERR_FILE_NULL);
|
LOGERROR(ERR_FILE_NULL);
|
||||||
@@ -49,11 +51,11 @@ u32_flip(const unsigned int* buf, const PPM img)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for (int i = img.height - 1; i >= 0; i--)
|
for (int i = height - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
for (int k = 0; k < img.width; k++)
|
for (int k = 0; k < width; k++)
|
||||||
{
|
{
|
||||||
flip[idx] = buf[(i * img.width) + k];
|
flip[idx] = buf[(i * width) + k];
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user