Avoid crash when shift a tilemap pixels (still not working, but at doesn't crash)

This commit is contained in:
David Capello 2020-08-24 12:24:08 -03:00
parent ab4accb60d
commit 18759b1198

View File

@ -12,12 +12,13 @@
#include "doc/algorithm/shift_image.h"
#include "base/pi.h"
#include "gfx/rect.h"
#include "doc/algorithm/shrink_bounds.h"
#include "doc/cel.h"
#include "doc/image.h"
#include "doc/layer.h"
#include "doc/mask.h"
#include "doc/primitives.h"
#include "gfx/rect.h"
#include <vector>
@ -106,10 +107,14 @@ ImageRef shift_image_with_mask(const Cel* cel,
// Bounds and Image shrinking (we have to fit compound image (compImage) and bounds (compCelBounds))
gfx::Rect newBounds = compImage->bounds();
if (algorithm::shrink_bounds(compImage.get(),
compImage->maskColor(),
nullptr,
newBounds)) {
if (algorithm::shrink_bounds(
compImage.get(),
compImage->maskColor(),
// TODO adding the layer for tilemaps (so the program doesn't
// crash), but anyway it the Shift algorithm is not
// working yet for tilemaps
cel->layer(),
newBounds)) {
compCelBounds.offset(newBounds.x, newBounds.y);
compCelBounds.setSize(newBounds.size());
}