Bläddra i källkod

Properly handle alpha components in the convolution code.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@3399 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 15 år sedan
förälder
incheckning
f0b30c6fa1
1 ändrade filer med 9 tillägg och 3 borttagningar
  1. +9
    -3
      pipi/filter/convolution.c

+ 9
- 3
pipi/filter/convolution.c Visa fil

@@ -134,7 +134,7 @@ static pipi_image_t *T(conv)(pipi_image_t *src, int m, int n, double mat[])
{
for(x = 0; x < w; x++)
{
double R = 0., G = 0., B = 0.;
double R = 0., G = 0., B = 0., A = 0.;
double Y = 0.;
int x2, y2, off = 4 * (y * w + x);

@@ -159,6 +159,7 @@ static pipi_image_t *T(conv)(pipi_image_t *src, int m, int n, double mat[])
R += f * srcdata[(y2 * w + x2) * 4];
G += f * srcdata[(y2 * w + x2) * 4 + 1];
B += f * srcdata[(y2 * w + x2) * 4 + 2];
A += f * srcdata[(y2 * w + x2) * 4 + 3];
}
}
}
@@ -170,6 +171,7 @@ static pipi_image_t *T(conv)(pipi_image_t *src, int m, int n, double mat[])
dstdata[off] = R < 0.0 ? 0.0 : R > 1.0 ? 1.0 : R;
dstdata[off + 1] = G < 0.0 ? 0.0 : G > 1.0 ? 1.0 : G;
dstdata[off + 2] = B < 0.0 ? 0.0 : B > 1.0 ? 1.0 : B;
dstdata[off + 3] = A < 0.0 ? 0.0 : A > 1.0 ? 1.0 : A;
}
}
}
@@ -204,7 +206,7 @@ static pipi_image_t *T(sepconv)(pipi_image_t *src,
{
for(x = 0; x < w; x++)
{
double R = 0., G = 0., B = 0.;
double R = 0., G = 0., B = 0., A = 0.;
double Y = 0.;
int x2, off = 4 * (y * w + x);

@@ -223,6 +225,7 @@ static pipi_image_t *T(sepconv)(pipi_image_t *src,
R += f * srcdata[(y * w + x2) * 4];
G += f * srcdata[(y * w + x2) * 4 + 1];
B += f * srcdata[(y * w + x2) * 4 + 2];
A += f * srcdata[(y * w + x2) * 4 + 3];
}
}

@@ -233,6 +236,7 @@ static pipi_image_t *T(sepconv)(pipi_image_t *src,
buffer[off] = R;
buffer[off + 1] = G;
buffer[off + 2] = B;
buffer[off + 3] = A;
}
}
}
@@ -241,7 +245,7 @@ static pipi_image_t *T(sepconv)(pipi_image_t *src,
{
for(x = 0; x < w; x++)
{
double R = 0., G = 0., B = 0.;
double R = 0., G = 0., B = 0., A = 0.;
double Y = 0.;
int y2, off = 4 * (y * w + x);

@@ -260,6 +264,7 @@ static pipi_image_t *T(sepconv)(pipi_image_t *src,
R += f * buffer[(y2 * w + x) * 4];
G += f * buffer[(y2 * w + x) * 4 + 1];
B += f * buffer[(y2 * w + x) * 4 + 2];
A += f * buffer[(y2 * w + x) * 4 + 3];
}
}

@@ -270,6 +275,7 @@ static pipi_image_t *T(sepconv)(pipi_image_t *src,
dstdata[off] = R < 0.0 ? 0.0 : R > 1.0 ? 1.0 : R;
dstdata[off + 1] = G < 0.0 ? 0.0 : G > 1.0 ? 1.0 : G;
dstdata[off + 2] = B < 0.0 ? 0.0 : B > 1.0 ? 1.0 : B;
dstdata[off + 3] = A < 0.0 ? 0.0 : A > 1.0 ? 1.0 : A;
}
}
}


Laddar…
Avbryt
Spara