summaryrefslogtreecommitdiff
path: root/src/image_processing_effects.c
diff options
context:
space:
mode:
authorGriffinR <griffin.g.richards@gmail.com>2021-03-29 20:56:15 -0400
committerGitHub <noreply@github.com>2021-03-29 20:56:15 -0400
commit50e9666e1637b15bd57fd7ee88180e50d2eb5e8c (patch)
treeb1543b6d79695862cb60d686548dd1a996b69e8c /src/image_processing_effects.c
parentdea07dc8656c8fb32f5b389b9f4f9a30fe26e555 (diff)
parente8b6b4b65e3b53f5fcf83035b9f848c5ef6378bd (diff)
Merge branch 'master' into doc-introcred
Diffstat (limited to 'src/image_processing_effects.c')
-rw-r--r--src/image_processing_effects.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/image_processing_effects.c b/src/image_processing_effects.c
index 224de6fe1..4a56871a4 100644
--- a/src/image_processing_effects.c
+++ b/src/image_processing_effects.c
@@ -51,7 +51,9 @@ static u16 QuantizePixel_GrayscaleSmall(u16*);
static u16 QuantizePixel_Grayscale(u16*);
static u16 QuantizePixel_PrimaryColors(u16*);
-extern const u8 gPointillismPoints[][3];
+#define MAX_DIMENSION 64
+
+#include "data/pointillism_points.h"
void ApplyImageProcessingEffects(struct ImageProcessingContext *context)
{
@@ -169,7 +171,7 @@ static void ApplyImageEffect_RedChannelGrayscaleHighlight(u8 highlight)
static void ApplyImageEffect_Pointillism(void)
{
u32 i;
- for (i = 0; i < 3200; i++)
+ for (i = 0; i < ARRAY_COUNT(sPointillismPoints); i++)
AddPointillismPoints(i);
}
@@ -307,9 +309,9 @@ static void ApplyImageEffect_Shimmer(void)
// First, invert all of the colors.
pixel = gCanvasPixels;
- for (i = 0; i < 64; i++)
+ for (i = 0; i < MAX_DIMENSION; i++)
{
- for (j = 0; j < 64; j++, pixel++)
+ for (j = 0; j < MAX_DIMENSION; j++, pixel++)
{
if (!IS_ALPHA(*pixel))
*pixel = QuantizePixel_Invert(pixel);
@@ -317,16 +319,16 @@ static void ApplyImageEffect_Shimmer(void)
}
// Blur the pixels twice.
- for (j = 0; j < 64; j++)
+ for (j = 0; j < MAX_DIMENSION; j++)
{
pixel = &gCanvasPixels[j];
prevPixel = *pixel;
*pixel = RGB_ALPHA;
- for (i = 1, pixel += 64; i < 63; i++, pixel += 64)
+ for (i = 1, pixel += MAX_DIMENSION; i < MAX_DIMENSION - 1; i++, pixel += MAX_DIMENSION)
{
if (!IS_ALPHA(*pixel))
{
- *pixel = QuantizePixel_BlurHard(&prevPixel, pixel, pixel + 64);
+ *pixel = QuantizePixel_BlurHard(&prevPixel, pixel, pixel + MAX_DIMENSION);
prevPixel = *pixel;
}
}
@@ -335,11 +337,11 @@ static void ApplyImageEffect_Shimmer(void)
pixel = &gCanvasPixels[j];
prevPixel = *pixel;
*pixel = RGB_ALPHA;
- for (i = 1, pixel += 64; i < 63; i++, pixel += 64)
+ for (i = 1, pixel += MAX_DIMENSION; i < MAX_DIMENSION - 1; i++, pixel += MAX_DIMENSION)
{
if (!IS_ALPHA(*pixel))
{
- *pixel = QuantizePixel_BlurHard(&prevPixel, pixel, pixel + 64);
+ *pixel = QuantizePixel_BlurHard(&prevPixel, pixel, pixel + MAX_DIMENSION);
prevPixel = *pixel;
}
}
@@ -351,9 +353,9 @@ static void ApplyImageEffect_Shimmer(void)
// The above blur causes the outline areas to darken, which makes
// this inversion give the effect of light outlines.
pixel = gCanvasPixels;
- for (i = 0; i < 64; i++)
+ for (i = 0; i < MAX_DIMENSION; i++)
{
- for (j = 0; j < 64; j++, pixel++)
+ for (j = 0; j < MAX_DIMENSION; j++, pixel++)
{
if (!IS_ALPHA(*pixel))
*pixel = QuantizePixel_Invert(pixel);
@@ -408,19 +410,19 @@ struct PointillismPoint
u16 delta;
};
-static void AddPointillismPoints(u16 arg0)
+static void AddPointillismPoints(u16 point)
{
u8 i;
bool8 offsetDownLeft;
u8 colorType;
struct PointillismPoint points[6];
- points[0].column = gPointillismPoints[arg0][0];
- points[0].row = gPointillismPoints[arg0][1];
- points[0].delta = (gPointillismPoints[arg0][2] >> 3) & 7;
+ points[0].column = sPointillismPoints[point][0];
+ points[0].row = sPointillismPoints[point][1];
+ points[0].delta = GET_POINT_DELTA(sPointillismPoints[point][2]);
- colorType = (gPointillismPoints[arg0][2] >> 1) & 3;
- offsetDownLeft = gPointillismPoints[arg0][2] & 1;
+ colorType = GET_POINT_COLOR_TYPE(sPointillismPoints[point][2]);
+ offsetDownLeft = GET_POINT_OFFSET_DL(sPointillismPoints[point][2]);
for (i = 1; i < points[0].delta; i++)
{
if (!offsetDownLeft)
@@ -434,7 +436,7 @@ static void AddPointillismPoints(u16 arg0)
points[i].row = points[0].row - 1;
}
- if (points[i].column > 63 || points[i].row > 63)
+ if (points[i].column >= MAX_DIMENSION || points[i].row >= MAX_DIMENSION)
{
points[0].delta = i - 1;
break;
@@ -445,7 +447,7 @@ static void AddPointillismPoints(u16 arg0)
for (i = 0; i < points[0].delta; i++)
{
- u16 *pixel = &gCanvasPixels[points[i].row * 64] + points[i].column;
+ u16 *pixel = &gCanvasPixels[points[i].row * MAX_DIMENSION] + points[i].column;
if (!IS_ALPHA(*pixel))
{
@@ -457,7 +459,7 @@ static void AddPointillismPoints(u16 arg0)
{
case 0:
case 1:
- switch (((gPointillismPoints[arg0][2] >> 3) & 7) % 3)
+ switch (GET_POINT_DELTA(sPointillismPoints[point][2]) % 3)
{
case 0:
if (red >= points[i].delta)