Skip to content

Commit

Permalink
Add DOC_SPRITE_MAX_WIDTH/HEIGHT constants
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed Jun 28, 2018
1 parent f595cee commit aec65fa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/app/commands/cmd_canvas_size.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
Expand Down Expand Up @@ -335,7 +335,10 @@ void CanvasSizeCommand::onExecute(Context* context)
Transaction transaction(writer.context(), "Canvas Size");
DocumentApi api = document->getApi(transaction);

api.cropSprite(sprite, gfx::Rect(x1, y1, x2-x1, y2-y1));
api.cropSprite(sprite,
gfx::Rect(x1, y1,
MID(1, x2-x1, DOC_SPRITE_MAX_WIDTH),
MID(1, y2-y1, DOC_SPRITE_MAX_HEIGHT)));
transaction.commit();

document->generateMaskBoundaries();
Expand Down
6 changes: 3 additions & 3 deletions src/app/commands/cmd_new_file.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
Expand Down Expand Up @@ -138,8 +138,8 @@ void NewFileCommand::onExecute(Context* context)
static_assert(IMAGE_INDEXED == 2, "Indexed pixel format should be 2");

format = MID(IMAGE_RGB, format, IMAGE_INDEXED);
w = MID(1, w, 65535);
h = MID(1, h, 65535);
w = MID(1, w, DOC_SPRITE_MAX_WIDTH);
h = MID(1, h, DOC_SPRITE_MAX_HEIGHT);
bg = MID(0, bg, 2);

// Select the color
Expand Down
3 changes: 3 additions & 0 deletions src/app/commands/cmd_sprite_size.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ void SpriteSizeCommand::onExecute(Context* context)
}
#endif // ENABLE_UI

new_width = MID(1, new_width, DOC_SPRITE_MAX_WIDTH);
new_height = MID(1, new_height, DOC_SPRITE_MAX_HEIGHT);

{
SpriteSizeJob job(reader, new_width, new_height, resize_method);
job.startJob();
Expand Down
5 changes: 4 additions & 1 deletion src/doc/sprite.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Aseprite Document Library
// Copyright (c) 2001-2017 David Capello
// Copyright (c) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
Expand All @@ -25,6 +25,9 @@

#include <vector>

#define DOC_SPRITE_MAX_WIDTH 65535
#define DOC_SPRITE_MAX_HEIGHT 65535

namespace doc {

class CelsRange;
Expand Down

0 comments on commit aec65fa

Please sign in to comment.