mirror of https://github.com/aseprite/aseprite.git
Add RotSprite as a resize algorithm on Sprite > Resize Sprite menu
This commit is contained in:
parent
7841ec82f3
commit
66e3cacbd0
|
|
@ -1,5 +1,5 @@
|
|||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
|
|
@ -168,10 +168,16 @@ public:
|
|||
widthPx()->setTextf("%d", new_width);
|
||||
heightPx()->setTextf("%d", new_height);
|
||||
|
||||
static_assert(doc::algorithm::RESIZE_METHOD_NEAREST_NEIGHBOR == 0 &&
|
||||
doc::algorithm::RESIZE_METHOD_BILINEAR == 1 &&
|
||||
doc::algorithm::RESIZE_METHOD_ROTSPRITE == 2,
|
||||
"ResizeMethod enum has changed");
|
||||
method()->addItem("Nearest-neighbor");
|
||||
method()->addItem("Bilinear");
|
||||
method()->setSelectedItemIndex(get_config_int("SpriteSize", "Method",
|
||||
doc::algorithm::RESIZE_METHOD_NEAREST_NEIGHBOR));
|
||||
method()->addItem("RotSprite");
|
||||
method()->setSelectedItemIndex(
|
||||
get_config_int("SpriteSize", "Method",
|
||||
doc::algorithm::RESIZE_METHOD_NEAREST_NEIGHBOR));
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -279,6 +285,8 @@ void SpriteSizeCommand::onLoadParams(const Params& params)
|
|||
if (!resize_method.empty()) {
|
||||
if (resize_method == "bilinear")
|
||||
m_resizeMethod = doc::algorithm::RESIZE_METHOD_BILINEAR;
|
||||
else if (resize_method == "rotsprite")
|
||||
m_resizeMethod = doc::algorithm::RESIZE_METHOD_ROTSPRITE;
|
||||
else
|
||||
m_resizeMethod = doc::algorithm::RESIZE_METHOD_NEAREST_NEIGHBOR;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// Aseprite Document Library
|
||||
// Copyright (c) 2001-2015 David Capello
|
||||
// Copyright (c) 2001-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "doc/algorithm/resize_image.h"
|
||||
|
||||
#include "doc/algorithm/rotsprite.h"
|
||||
#include "doc/image_impl.h"
|
||||
#include "doc/palette.h"
|
||||
#include "doc/rgbmap.h"
|
||||
|
|
@ -23,8 +24,7 @@ void resize_image(const Image* src, Image* dst, ResizeMethod method, const Palet
|
|||
switch (method) {
|
||||
|
||||
// TODO optimize this
|
||||
case RESIZE_METHOD_NEAREST_NEIGHBOR:
|
||||
{
|
||||
case RESIZE_METHOD_NEAREST_NEIGHBOR: {
|
||||
int o_width = src->width(), o_height = src->height();
|
||||
int n_width = dst->width(), n_height = dst->height();
|
||||
double x_ratio = o_width / (double)n_width;
|
||||
|
|
@ -141,6 +141,16 @@ void resize_image(const Image* src, Image* dst, ResizeMethod method, const Palet
|
|||
break;
|
||||
}
|
||||
|
||||
case RESIZE_METHOD_ROTSPRITE: {
|
||||
rotsprite_image(
|
||||
dst, src, nullptr,
|
||||
0, 0,
|
||||
dst->width(), 0,
|
||||
dst->width(), dst->height(),
|
||||
0, dst->height());
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// Aseprite Document Library
|
||||
// Copyright (c) 2001-2015 David Capello
|
||||
// Copyright (c) 2001-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
|
|
@ -21,6 +21,7 @@ namespace doc {
|
|||
enum ResizeMethod {
|
||||
RESIZE_METHOD_NEAREST_NEIGHBOR,
|
||||
RESIZE_METHOD_BILINEAR,
|
||||
RESIZE_METHOD_ROTSPRITE,
|
||||
};
|
||||
|
||||
// Resizes the source image 'src' to the destination image 'dst'.
|
||||
|
|
|
|||
Loading…
Reference in New Issue