mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-30 04:20:23 +00:00
Fix bug in fixup_image_transparent_colors(): reading pixels out of bounds
This commit is contained in:
parent
f8e8657093
commit
0fa2842e40
@ -150,7 +150,7 @@ void resize_image(const Image* src, Image* dst, ResizeMethod method, const Palet
|
|||||||
|
|
||||||
void fixup_image_transparent_colors(Image* image)
|
void fixup_image_transparent_colors(Image* image)
|
||||||
{
|
{
|
||||||
int x, y, u, v;
|
int x, y;
|
||||||
|
|
||||||
switch (image->getPixelFormat()) {
|
switch (image->getPixelFormat()) {
|
||||||
|
|
||||||
@ -168,20 +168,17 @@ void fixup_image_transparent_colors(Image* image)
|
|||||||
count = 0;
|
count = 0;
|
||||||
r = g = b = 0;
|
r = g = b = 0;
|
||||||
|
|
||||||
LockImageBits<RgbTraits>::iterator it2 =
|
gfx::Rect area = gfx::Rect(x-1, y-1, 3, 3).createIntersect(image->getBounds());
|
||||||
bits.begin_area(gfx::Rect(x-1, y-1, 3, 3));
|
LockImageBits<RgbTraits>::iterator it2 = bits.begin_area(area);
|
||||||
|
LockImageBits<RgbTraits>::iterator end2 = bits.end_area(area);
|
||||||
|
|
||||||
for (v=y-1; v<=y+1; ++v) {
|
for (; it2 != end2; ++it2) {
|
||||||
for (u=x-1; u<=x+1; ++u, ++it2) {
|
c = *it2;
|
||||||
if ((u >= 0) && (v >= 0) && (u < image->getWidth()) && (v < image->getHeight())) {
|
if (rgba_geta(c) > 0) {
|
||||||
c = *it2;
|
r += rgba_getr(c);
|
||||||
if (rgba_geta(c) > 0) {
|
g += rgba_getg(c);
|
||||||
r += rgba_getr(c);
|
b += rgba_getb(c);
|
||||||
g += rgba_getg(c);
|
++count;
|
||||||
b += rgba_getb(c);
|
|
||||||
++count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,18 +208,15 @@ void fixup_image_transparent_colors(Image* image)
|
|||||||
count = 0;
|
count = 0;
|
||||||
k = 0;
|
k = 0;
|
||||||
|
|
||||||
LockImageBits<GrayscaleTraits>::iterator it2 =
|
gfx::Rect area = gfx::Rect(x-1, y-1, 3, 3).createIntersect(image->getBounds());
|
||||||
bits.begin_area(gfx::Rect(x-1, y-1, 3, 3));
|
LockImageBits<GrayscaleTraits>::iterator it2 = bits.begin_area(area);
|
||||||
|
LockImageBits<GrayscaleTraits>::iterator end2 = bits.end_area(area);
|
||||||
|
|
||||||
for (v=y-1; v<=y+1; ++v) {
|
for (; it2 != end2; ++it2) {
|
||||||
for (u=x-1; u<=x+1; ++u, ++it2) {
|
c = *it2;
|
||||||
if ((u >= 0) && (v >= 0) && (u < image->getWidth()) && (v < image->getHeight())) {
|
if (graya_geta(c) > 0) {
|
||||||
c = *it2;
|
k += graya_getv(c);
|
||||||
if (graya_geta(c) > 0) {
|
++count;
|
||||||
k += graya_getv(c);
|
|
||||||
++count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user