mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 03:44:16 +00:00
Fix crash on image_scale_tpl() and rotsprite_image()
This commit is contained in:
parent
66e3cacbd0
commit
14262c270c
@ -47,16 +47,22 @@ static void image_scale_tpl(
|
|||||||
{
|
{
|
||||||
LockImageBits<ImageTraits> dst_bits(dst, gfx::Rect(dst_x, dst_y, dst_w, dst_h));
|
LockImageBits<ImageTraits> dst_bits(dst, gfx::Rect(dst_x, dst_y, dst_w, dst_h));
|
||||||
typename LockImageBits<ImageTraits>::iterator dst_it = dst_bits.begin();
|
typename LockImageBits<ImageTraits>::iterator dst_it = dst_bits.begin();
|
||||||
|
fixed x;
|
||||||
|
fixed y = itofix(src_y);
|
||||||
|
fixed dx = fixdiv(itofix(src_w-1), itofix(dst_w-1));
|
||||||
|
fixed dy = fixdiv(itofix(src_h-1), itofix(dst_h-1));
|
||||||
|
|
||||||
for (int v=0; v<dst_h; ++v) {
|
for (int v=0; v<dst_h; ++v) {
|
||||||
|
x = itofix(src_x);
|
||||||
for (int u=0; u<dst_w; ++u) {
|
for (int u=0; u<dst_w; ++u) {
|
||||||
color_t src_color =
|
ASSERT(dst_it != dst_bits.end());
|
||||||
get_pixel_fast<ImageTraits>(src,
|
color_t src_color = get_pixel_fast<ImageTraits>(src, fixtoi(x), fixtoi(y));
|
||||||
src_w*(src_x+u)/dst_w,
|
|
||||||
src_h*(src_y+v)/dst_h);
|
|
||||||
*dst_it = blend(*dst_it, src_color);
|
*dst_it = blend(*dst_it, src_color);
|
||||||
++dst_it;
|
++dst_it;
|
||||||
|
|
||||||
|
x = fixadd(x, dx);
|
||||||
}
|
}
|
||||||
|
y = fixadd(y, dy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,8 +176,8 @@ void rotsprite_image(Image* bmp, const Image* spr, const Image* mask,
|
|||||||
int xmax = MAX(x1, MAX(x2, MAX(x3, x4)));
|
int xmax = MAX(x1, MAX(x2, MAX(x3, x4)));
|
||||||
int ymin = MIN(y1, MIN(y2, MIN(y3, y4)));
|
int ymin = MIN(y1, MIN(y2, MIN(y3, y4)));
|
||||||
int ymax = MAX(y1, MAX(y2, MAX(y3, y4)));
|
int ymax = MAX(y1, MAX(y2, MAX(y3, y4)));
|
||||||
int rot_width = xmax - xmin + 1;
|
int rot_width = xmax - xmin;
|
||||||
int rot_height = ymax - ymin + 1;
|
int rot_height = ymax - ymin;
|
||||||
|
|
||||||
int scale = 8;
|
int scale = 8;
|
||||||
base::UniquePtr<Image> bmp_copy(Image::create(bmp->pixelFormat(), rot_width*scale, rot_height*scale, buf[0]));
|
base::UniquePtr<Image> bmp_copy(Image::create(bmp->pixelFormat(), rot_width*scale, rot_height*scale, buf[0]));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user