mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-14 04:19:12 +00:00
Replace MIN/MAX() macros with std::min/max() functions
This commit is contained in:
parent
86259a64fc
commit
b628e21e76
2
laf
2
laf
@ -1 +1 @@
|
||||
Subproject commit 4f0acaa1ffb456b335201ca457b09f3cb99369cc
|
||||
Subproject commit 58941d53846be4e1a90eda6e2293ad3559d419a1
|
@ -35,6 +35,7 @@
|
||||
#include "doc/tags.h"
|
||||
#include "render/dithering_algorithm.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
|
||||
@ -518,7 +519,7 @@ int CliProcessor::process(Context* ctx)
|
||||
scaleWidth = (doc->width() > maxWidth ? maxWidth / doc->width() : 1.0);
|
||||
scaleHeight = (doc->height() > maxHeight ? maxHeight / doc->height() : 1.0);
|
||||
if (scaleWidth < 1.0 || scaleHeight < 1.0) {
|
||||
scale = MIN(scaleWidth, scaleHeight);
|
||||
scale = std::min(scaleWidth, scaleHeight);
|
||||
Params params;
|
||||
params.set("scale", base::convert_to<std::string>(scale).c_str());
|
||||
ctx->executeCommand(Commands::instance()->byId(CommandId::SpriteSize()),
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -37,11 +37,11 @@ SetPalette::SetPalette(Sprite* sprite, frame_t frame, const Palette* newPalette)
|
||||
ASSERT(diffs > 0);
|
||||
|
||||
if (m_from >= 0 && m_to >= m_from) {
|
||||
int oldColors = MIN(m_to+1, m_oldNColors)-m_from;
|
||||
int oldColors = std::min(m_to+1, m_oldNColors)-m_from;
|
||||
if (oldColors > 0)
|
||||
m_oldColors.resize(oldColors);
|
||||
|
||||
int newColors = MIN(m_to+1, m_newNColors)-m_from;
|
||||
int newColors = std::min(m_to+1, m_newNColors)-m_from;
|
||||
if (newColors > 0)
|
||||
m_newColors.resize(newColors);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2019 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -45,6 +45,7 @@
|
||||
|
||||
#include "keyboard_shortcuts.xml.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
@ -260,7 +261,7 @@ private:
|
||||
m_headerItem->contextXPos() +
|
||||
Graphics::measureUITextLength(
|
||||
convertKeyContextToUserFriendlyString(m_key->keycontext()), font());
|
||||
size.w = MAX(size.w, w);
|
||||
size.w = std::max(size.w, w);
|
||||
}
|
||||
|
||||
if (m_key && !m_key->accels().empty()) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -41,8 +41,10 @@
|
||||
|
||||
#include "new_layer.xml.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -419,8 +421,8 @@ std::string NewLayerCommand::onGetFriendlyName() const
|
||||
void NewLayerCommand::adjustRefCelBounds(Cel* cel, gfx::RectF bounds)
|
||||
{
|
||||
Sprite* sprite = cel->sprite();
|
||||
double scale = MIN(double(sprite->width()) / bounds.w,
|
||||
double(sprite->height()) / bounds.h);
|
||||
double scale = std::min(double(sprite->width()) / bounds.w,
|
||||
double(sprite->height()) / bounds.h);
|
||||
bounds.w *= scale;
|
||||
bounds.h *= scale;
|
||||
bounds.x = sprite->width()/2 - bounds.w/2;
|
||||
@ -447,7 +449,7 @@ int NewLayerCommand::getMaxLayerNum(const Layer* layer) const
|
||||
if (layer->isGroup()) {
|
||||
for (const Layer* child : static_cast<const LayerGroup*>(layer)->layers()) {
|
||||
int tmp = getMaxLayerNum(child);
|
||||
max = MAX(tmp, max);
|
||||
max = std::max(tmp, max);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,8 @@
|
||||
|
||||
#include "sprite_size.xml.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#define PERC_FORMAT "%.4g"
|
||||
|
||||
namespace app {
|
||||
@ -130,7 +132,9 @@ protected:
|
||||
new_mask->replace(
|
||||
gfx::Rect(
|
||||
scale_x(document()->mask()->bounds().x-1),
|
||||
scale_y(document()->mask()->bounds().y-1), MAX(1, w), MAX(1, h)));
|
||||
scale_y(document()->mask()->bounds().y-1),
|
||||
std::max(1, w),
|
||||
std::max(1, h)));
|
||||
|
||||
// Always use the nearest-neighbor method to resize the bitmap
|
||||
// mask.
|
||||
|
@ -168,8 +168,8 @@ FileOpROI::FileOpROI(const Doc* doc,
|
||||
m_selFrames.displace(m_tag->fromFrame());
|
||||
|
||||
m_selFrames =
|
||||
m_selFrames.filter(MAX(0, m_tag->fromFrame()),
|
||||
MIN(m_tag->toFrame(), doc->sprite()->lastFrame()));
|
||||
m_selFrames.filter(std::max(0, m_tag->fromFrame()),
|
||||
std::min(m_tag->toFrame(), doc->sprite()->lastFrame()));
|
||||
}
|
||||
// All frames if selected frames is empty
|
||||
else if (m_selFrames.empty())
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "flic/flic.h"
|
||||
#include "render/render.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
|
||||
namespace app {
|
||||
@ -239,7 +240,7 @@ bool FliFormat::onSave(FileOp* fop)
|
||||
|
||||
frame_t frame = *frame_it;
|
||||
const Palette* pal = sprite->palette(frame);
|
||||
int size = MIN(256, pal->size());
|
||||
int size = std::min(256, pal->size());
|
||||
|
||||
for (int c=0; c<size; c++) {
|
||||
color_t color = pal->getEntry(c);
|
||||
@ -255,7 +256,7 @@ bool FliFormat::onSave(FileOp* fop)
|
||||
// time that it has in the sprite
|
||||
if (f < nframes) {
|
||||
int times = sprite->frameDuration(frame) / header.speed;
|
||||
times = MAX(1, times);
|
||||
times = std::max(1, times);
|
||||
for (int c=0; c<times; c++)
|
||||
encoder.writeFrame(fliFrame);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2019 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -33,6 +33,8 @@
|
||||
|
||||
#include "gif_options.xml.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <gif_lib.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
@ -52,7 +54,7 @@
|
||||
#define GIF_TRACE(...)
|
||||
|
||||
// GifBitSize can return 9 (it's a bug in giflib)
|
||||
#define GifBitSizeLimited(v) (MIN(GifBitSize(v), 8))
|
||||
#define GifBitSizeLimited(v) (std::min(GifBitSize(v), 8))
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -539,7 +541,7 @@ private:
|
||||
palette.reset(new Palette(*m_sprite->palette(m_frameNum-1)));
|
||||
palette->setFrame(m_frameNum);
|
||||
}
|
||||
resetRemap(MAX(ncolors, palette->size()));
|
||||
resetRemap(std::max(ncolors, palette->size()));
|
||||
|
||||
// Number of colors in the colormap that are part of the current
|
||||
// sprite palette.
|
||||
@ -588,7 +590,7 @@ private:
|
||||
|
||||
Palette oldPalette(*palette);
|
||||
palette->resize(base + missing + (needsExtraBgColor ? 1: 0));
|
||||
resetRemap(MAX(ncolors, palette->size()));
|
||||
resetRemap(std::max(ncolors, palette->size()));
|
||||
|
||||
for (int i=0; i<ncolors; ++i) {
|
||||
if (!usedEntries[i])
|
||||
@ -792,7 +794,7 @@ private:
|
||||
(m_previousImage.get(), NULL, IMAGE_RGB,
|
||||
render::Dithering(),
|
||||
nullptr,
|
||||
m_sprite->palette(MAX(0, m_frameNum-1)),
|
||||
m_sprite->palette(std::max(0, m_frameNum-1)),
|
||||
m_opaque,
|
||||
m_bgIndex));
|
||||
|
||||
@ -906,7 +908,7 @@ public:
|
||||
if (m_sprite->pixelFormat() == IMAGE_INDEXED) {
|
||||
for (Palette* palette : m_sprite->getPalettes()) {
|
||||
int bpp = GifBitSizeLimited(palette->size());
|
||||
m_bitsPerPixel = MAX(m_bitsPerPixel, bpp);
|
||||
m_bitsPerPixel = std::max(m_bitsPerPixel, bpp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -1092,9 +1094,9 @@ private:
|
||||
// 1/4 of its duration for some strange reason in the Twitter
|
||||
// conversion from GIF to video.
|
||||
if (fixDuration)
|
||||
frameDelay = MAX(2, frameDelay/4);
|
||||
frameDelay = std::max(2, frameDelay/4);
|
||||
if (fix_last_frame_duration)
|
||||
frameDelay = MAX(2, frameDelay);
|
||||
frameDelay = std::max(2, frameDelay);
|
||||
|
||||
extension_bytes[0] = (((int(disposalMethod) & 7) << 2) |
|
||||
(transparentIndex >= 0 ? 1: 0));
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include "ui/system.h"
|
||||
#include "ui/theme.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace app {
|
||||
|
||||
using namespace app::skin;
|
||||
@ -183,7 +185,7 @@ void draw_alpha_slider(ui::Graphics* g,
|
||||
const gfx::Rect& rc,
|
||||
const app::Color& color)
|
||||
{
|
||||
const int xmax = MAX(1, rc.w-1);
|
||||
const int xmax = std::max(1, rc.w-1);
|
||||
const doc::color_t c =
|
||||
(color.getType() != app::Color::MaskType ?
|
||||
doc::rgba(color.getRed(),
|
||||
@ -210,7 +212,7 @@ void draw_alpha_slider(os::Surface* s,
|
||||
const gfx::Rect& rc,
|
||||
const app::Color& color)
|
||||
{
|
||||
const int xmax = MAX(1, rc.w-1);
|
||||
const int xmax = std::max(1, rc.w-1);
|
||||
const doc::color_t c =
|
||||
(color.getType() != app::Color::MaskType ?
|
||||
doc::rgba(color.getRed(),
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "render/projection.h"
|
||||
#include "render/render.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
|
||||
@ -119,9 +120,9 @@ private:
|
||||
const int h = sprite->height()*sprite->pixelRatio().h;
|
||||
|
||||
// Calculate the thumbnail size
|
||||
int thumb_w = MAX_THUMBNAIL_SIZE * w / MAX(w, h);
|
||||
int thumb_h = MAX_THUMBNAIL_SIZE * h / MAX(w, h);
|
||||
if (MAX(thumb_w, thumb_h) > MAX(w, h)) {
|
||||
int thumb_w = MAX_THUMBNAIL_SIZE * w / std::max(w, h);
|
||||
int thumb_h = MAX_THUMBNAIL_SIZE * h / std::max(w, h);
|
||||
if (std::max(thumb_w, thumb_h) > std::max(w, h)) {
|
||||
thumb_w = w;
|
||||
thumb_h = h;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "base/gcd.h"
|
||||
#include "base/pi.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
namespace app {
|
||||
@ -154,8 +155,8 @@ public:
|
||||
if ((int(loop->getModifiers()) & int(ToolLoopModifiers::kSquareAspect))) {
|
||||
int dx = stroke[1].x - m_first.x;
|
||||
int dy = stroke[1].y - m_first.y;
|
||||
int minsize = MIN(ABS(dx), ABS(dy));
|
||||
int maxsize = MAX(ABS(dx), ABS(dy));
|
||||
int minsize = std::min(ABS(dx), ABS(dy));
|
||||
int maxsize = std::max(ABS(dx), ABS(dy));
|
||||
|
||||
// Lines
|
||||
if (loop->getIntertwine()->snapByAngle()) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2019 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -26,6 +26,7 @@
|
||||
#include "ui/theme.h"
|
||||
#include "ui/widget.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdarg>
|
||||
|
||||
namespace app {
|
||||
@ -264,8 +265,8 @@ void ButtonSet::Item::onSizeHint(ui::SizeHintEvent& ev)
|
||||
gfx::Size iconSize;
|
||||
if (m_icon) {
|
||||
iconSize = m_icon->size();
|
||||
iconSize.w = MAX(iconSize.w, 16*guiscale());
|
||||
iconSize.h = MAX(iconSize.h, 16*guiscale());
|
||||
iconSize.w = std::max(iconSize.w, 16*guiscale());
|
||||
iconSize.h = std::max(iconSize.h, 16*guiscale());
|
||||
}
|
||||
|
||||
gfx::Rect boxRc;
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include "gfx/rect_io.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace app {
|
||||
|
||||
using namespace app::skin;
|
||||
@ -306,9 +308,9 @@ void ColorButton::openPopup(const bool forcePinned)
|
||||
m_window->sizeHint());
|
||||
winBounds.x = base::clamp(bounds().x, 0, ui::display_w()-winBounds.w);
|
||||
if (bounds().y2() <= ui::display_h()-winBounds.h)
|
||||
winBounds.y = MAX(0, bounds().y2());
|
||||
winBounds.y = std::max(0, bounds().y2());
|
||||
else
|
||||
winBounds.y = MAX(0, bounds().y-winBounds.h);
|
||||
winBounds.y = std::max(0, bounds().y-winBounds.h);
|
||||
}
|
||||
else if (forcePinned) {
|
||||
winBounds = m_hiddenPopupBounds;
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "ui/size_hint_event.h"
|
||||
#include "ui/system.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <condition_variable>
|
||||
#include <thread>
|
||||
@ -261,7 +262,7 @@ app::Color ColorSelector::getColorByPosition(const gfx::Point& pos)
|
||||
return app::Color::fromMask();
|
||||
|
||||
const int u = pos.x - rc.x;
|
||||
const int umax = MAX(1, rc.w-1);
|
||||
const int umax = std::max(1, rc.w-1);
|
||||
|
||||
const gfx::Rect bottomBarBounds = this->bottomBarBounds();
|
||||
if (( hasCapture() && m_capturedInBottom) ||
|
||||
@ -274,7 +275,7 @@ app::Color ColorSelector::getColorByPosition(const gfx::Point& pos)
|
||||
return getAlphaBarColor(u, umax);
|
||||
|
||||
const int v = pos.y - rc.y;
|
||||
const int vmax = MAX(1, rc.h-bottomBarBounds.h-alphaBarBounds.h-1);
|
||||
const int vmax = std::max(1, rc.h-bottomBarBounds.h-alphaBarBounds.h-1);
|
||||
return getMainAreaColor(u, umax,
|
||||
v, vmax);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "ui/slider.h"
|
||||
#include "ui/theme.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
namespace app {
|
||||
@ -62,7 +63,7 @@ namespace {
|
||||
auto convertColor = convert_from_current_to_screen_color_space();
|
||||
|
||||
gfx::Color color = gfx::ColorNone;
|
||||
int w = MAX(rc.w-1, 1);
|
||||
int w = std::max(rc.w-1, 1);
|
||||
|
||||
for (int x=0; x <= w; ++x) {
|
||||
switch (m_channel) {
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include "ui/size_hint_event.h"
|
||||
#include "ui/system.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace app {
|
||||
|
||||
using namespace app::skin;
|
||||
@ -88,8 +90,8 @@ void ColorSpectrum::onPaintSurfaceInBgThread(
|
||||
{
|
||||
if (m_paintFlags & MainAreaFlag) {
|
||||
double sat = m_color.getHslSaturation();
|
||||
int umax = MAX(1, main.w-1);
|
||||
int vmax = MAX(1, main.h-1);
|
||||
int umax = std::max(1, main.w-1);
|
||||
int vmax = std::max(1, main.h-1);
|
||||
|
||||
for (int y=0; y<main.h && !stop; ++y) {
|
||||
for (int x=0; x<main.w && !stop; ++x) {
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include "base/clamp.h"
|
||||
#include "ui/graphics.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace app {
|
||||
|
||||
using namespace app::skin;
|
||||
@ -78,8 +80,8 @@ void ColorTintShadeTone::onPaintSurfaceInBgThread(
|
||||
bool& stop)
|
||||
{
|
||||
double hue = m_color.getHsvHue();
|
||||
int umax = MAX(1, main.w-1);
|
||||
int vmax = MAX(1, main.h-1);
|
||||
int umax = std::max(1, main.w-1);
|
||||
int vmax = std::max(1, main.h-1);
|
||||
|
||||
if (m_paintFlags & MainAreaFlag) {
|
||||
for (int y=0; y<main.h && !stop; ++y) {
|
||||
|
@ -143,7 +143,7 @@ app::Color ColorWheel::getMainAreaColor(const int _u, const int umax,
|
||||
if (m_color.getAlpha() > 0) {
|
||||
const gfx::Point pos(_u, _v);
|
||||
int n = getHarmonies();
|
||||
int boxsize = MIN(umax/10, vmax/10);
|
||||
int boxsize = std::min(umax/10, vmax/10);
|
||||
|
||||
for (int i=0; i<n; ++i) {
|
||||
app::Color color = getColorInHarmony(i);
|
||||
@ -179,7 +179,7 @@ void ColorWheel::onPaintMainArea(ui::Graphics* g, const gfx::Rect& rc)
|
||||
{
|
||||
bool oldHarmonyPicked = m_harmonyPicked;
|
||||
|
||||
int r = MIN(rc.w/2, rc.h/2);
|
||||
int r = std::min(rc.w/2, rc.h/2);
|
||||
m_wheelRadius = r;
|
||||
m_wheelBounds = gfx::Rect(rc.x+rc.w/2-r,
|
||||
rc.y+rc.h/2-r,
|
||||
@ -200,7 +200,7 @@ void ColorWheel::onPaintMainArea(ui::Graphics* g, const gfx::Rect& rc)
|
||||
}
|
||||
else {
|
||||
int n = getHarmonies();
|
||||
int boxsize = MIN(rc.w/10, rc.h/10);
|
||||
int boxsize = std::min(rc.w/10, rc.h/10);
|
||||
|
||||
for (int i=0; i<n; ++i) {
|
||||
app::Color color = getColorInHarmony(i);
|
||||
@ -248,8 +248,8 @@ void ColorWheel::onPaintSurfaceInBgThread(os::Surface* s,
|
||||
bool& stop)
|
||||
{
|
||||
if (m_paintFlags & MainAreaFlag) {
|
||||
int umax = MAX(1, main.w-1);
|
||||
int vmax = MAX(1, main.h-1);
|
||||
int umax = std::max(1, main.w-1);
|
||||
int vmax = std::max(1, main.h-1);
|
||||
|
||||
for (int y=0; y<main.h && !stop; ++y) {
|
||||
for (int x=0; x<main.w && !stop; ++x) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -30,6 +30,8 @@
|
||||
#include "ui/paint_event.h"
|
||||
#include "ui/size_hint_event.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace app {
|
||||
|
||||
using namespace ui;
|
||||
@ -122,7 +124,7 @@ private:
|
||||
void onSizeHint(SizeHintEvent& ev) override {
|
||||
gfx::Size sz = textSize();
|
||||
|
||||
sz.w = MAX(sz.w, preview()->width()) + 4*guiscale();
|
||||
sz.w = std::max(sz.w, preview()->width()) + 4*guiscale();
|
||||
sz.h += 6*guiscale() + preview()->height();
|
||||
|
||||
ev.setSizeHint(sz);
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "doc/sprite.h"
|
||||
#include "ui/message.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
namespace app {
|
||||
@ -234,7 +235,7 @@ bool MovingCelState::onMouseMove(Editor* editor, MouseMessage* msg)
|
||||
|
||||
if (int(editor->getCustomizationDelegate()
|
||||
->getPressedKeyAction(KeyContext::ScalingSelection) & KeyAction::MaintainAspectRatio)) {
|
||||
m_celScale.w = m_celScale.h = MAX(m_celScale.w, m_celScale.h);
|
||||
m_celScale.w = m_celScale.h = std::max(m_celScale.w, m_celScale.h);
|
||||
}
|
||||
|
||||
m_scaled = true;
|
||||
|
@ -343,7 +343,7 @@ bool FileList::onProcessMessage(Message* msg)
|
||||
FileItemList::iterator
|
||||
link = m_list.begin() + ((select >= 0) ? select: 0);
|
||||
|
||||
for (i=MAX(select, 0); i<bottom; ++i, ++link) {
|
||||
for (i=std::max(select, 0); i<bottom; ++i, ++link) {
|
||||
IFileItem* fi = *link;
|
||||
if (base::utf8_icmp(fi->displayName(), m_isearch, chrs) == 0) {
|
||||
select = i;
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -39,10 +40,12 @@
|
||||
#include "font_popup.xml.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <shlobj.h>
|
||||
#include <windows.h>
|
||||
#include <shlobj.h>
|
||||
#include <windows.h>
|
||||
#undef max
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
|
||||
namespace app {
|
||||
@ -87,7 +90,7 @@ private:
|
||||
gfx::Size sz = ev.sizeHint();
|
||||
ev.setSizeHint(
|
||||
sz.w + 4 + m_image->width(),
|
||||
MAX(sz.h, m_image->height()));
|
||||
std::max(sz.h, m_image->height()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ void PaletteView::clearSelection()
|
||||
|
||||
Palette palette(*currentPalette());
|
||||
Palette newPalette(palette);
|
||||
newPalette.resize(MAX(1, newPalette.size() - m_selectedEntries.picks()));
|
||||
newPalette.resize(std::max(1, newPalette.size() - m_selectedEntries.picks()));
|
||||
|
||||
Remap remap = create_remap_to_move_picks(m_selectedEntries, palette.size());
|
||||
for (int i=0; i<palette.size(); ++i) {
|
||||
@ -398,7 +398,7 @@ bool PaletteView::onProcessMessage(Message* msg)
|
||||
case State::RESIZING_PALETTE:
|
||||
if (m_hot.part == Hit::COLOR ||
|
||||
m_hot.part == Hit::POSSIBLE_COLOR) {
|
||||
int newPalSize = MAX(1, m_hot.color);
|
||||
int newPalSize = std::max(1, m_hot.color);
|
||||
Palette newPalette(*currentPalette());
|
||||
newPalette.resize(newPalSize);
|
||||
setNewPalette(currentPalette(), &newPalette,
|
||||
@ -645,7 +645,7 @@ void PaletteView::onResize(ui::ResizeEvent& ev)
|
||||
+this->childSpacing())
|
||||
/ (boxSizePx()
|
||||
+this->childSpacing());
|
||||
setColumns(MAX(1, columns));
|
||||
setColumns(std::max(1, columns));
|
||||
}
|
||||
m_isUpdatingColumns = false;
|
||||
}
|
||||
@ -915,7 +915,7 @@ void PaletteView::setStatusBar()
|
||||
m_hot.part == Hit::OUTLINE ||
|
||||
m_hot.part == Hit::POSSIBLE_COLOR) &&
|
||||
(m_hot.color < currentPalette()->size())) {
|
||||
int i = MAX(0, m_hot.color);
|
||||
int i = std::max(0, m_hot.color);
|
||||
|
||||
statusBar->showColor(
|
||||
0, "", app::Color::fromIndex(i));
|
||||
@ -928,11 +928,11 @@ void PaletteView::setStatusBar()
|
||||
case State::DRAGGING_OUTLINE:
|
||||
if (m_hot.part == Hit::COLOR) {
|
||||
const int picks = m_selectedEntries.picks();
|
||||
const int destIndex = MAX(0, m_hot.color);
|
||||
const int destIndex = std::max(0, m_hot.color);
|
||||
const int palSize = currentPalette()->size();
|
||||
const int newPalSize =
|
||||
(m_copy ? MAX(palSize + picks, destIndex + picks):
|
||||
MAX(palSize, destIndex + picks));
|
||||
(m_copy ? std::max(palSize + picks, destIndex + picks):
|
||||
std::max(palSize, destIndex + picks));
|
||||
|
||||
statusBar->setStatusText(
|
||||
0, "%s to %d - New Palette Size %d",
|
||||
@ -948,7 +948,7 @@ void PaletteView::setStatusBar()
|
||||
if (m_hot.part == Hit::COLOR ||
|
||||
m_hot.part == Hit::POSSIBLE_COLOR ||
|
||||
m_hot.part == Hit::RESIZE_HANDLE) {
|
||||
int newPalSize = MAX(1, m_hot.color);
|
||||
int newPalSize = std::max(1, m_hot.color);
|
||||
statusBar->setStatusText(
|
||||
0, "New Palette Size %d",
|
||||
newPalSize);
|
||||
|
@ -82,7 +82,7 @@ protected:
|
||||
setTextQuiet(m_path);
|
||||
gfx::Size sz2 = theme->calcSizeHint(this, styleDetail);
|
||||
|
||||
ev.setSizeHint(gfx::Size(sz1.w+sz2.w, MAX(sz1.h, sz2.h)));
|
||||
ev.setSizeHint(gfx::Size(sz1.w+sz2.w, std::max(sz1.h, sz2.h)));
|
||||
}
|
||||
|
||||
bool onProcessMessage(Message* msg) override {
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (c) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -17,6 +18,8 @@
|
||||
#include "ui/paint_event.h"
|
||||
#include "ui/size_hint_event.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace app {
|
||||
|
||||
using namespace app::skin;
|
||||
@ -75,7 +78,7 @@ void SearchEntry::onSizeHint(SizeHintEvent& ev)
|
||||
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(this->theme());
|
||||
auto icon = theme->parts.iconSearch()->bitmap(0);
|
||||
sz.h = MAX(sz.h, icon->height()+border().height());
|
||||
sz.h = std::max(sz.h, icon->height()+border().height());
|
||||
|
||||
ev.setSizeHint(sz);
|
||||
}
|
||||
|
@ -43,6 +43,7 @@
|
||||
|
||||
#include "tinyxml.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
#define BGCOLOR (getWidgetBgColor(widget))
|
||||
@ -1078,7 +1079,7 @@ void SkinTheme::drawEntryText(ui::Graphics* g, ui::Entry* widget)
|
||||
const std::string& textString = widget->text();
|
||||
base::utf8_const_iterator utf8_it((textString.begin()));
|
||||
int textlen = base::utf8_length(textString);
|
||||
scroll = MIN(scroll, textlen);
|
||||
scroll = std::min(scroll, textlen);
|
||||
if (scroll)
|
||||
utf8_it += scroll;
|
||||
|
||||
|
@ -154,7 +154,7 @@ void Tabs::updateTabs()
|
||||
double tabWidth = defTabWidth;
|
||||
if (tabWidth * m_list.size() > availWidth) {
|
||||
tabWidth = availWidth / double(m_list.size());
|
||||
tabWidth = MAX(4*ui::guiscale(), tabWidth);
|
||||
tabWidth = std::max(double(4*ui::guiscale()), tabWidth);
|
||||
}
|
||||
double x = 0.0;
|
||||
int i = 0;
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "os/system.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
|
||||
@ -998,7 +999,7 @@ bool Timeline::onProcessMessage(Message* msg)
|
||||
gfx::Rect onionRc = getOnionskinFramesBounds();
|
||||
|
||||
int newValue = m_origFrames + (m_clk.frame - hit.frame);
|
||||
docPref().onionskin.prevFrames(MAX(0, newValue));
|
||||
docPref().onionskin.prevFrames(std::max(0, newValue));
|
||||
|
||||
onionRc |= getOnionskinFramesBounds();
|
||||
invalidateRect(onionRc.offset(origin()));
|
||||
@ -1009,7 +1010,7 @@ bool Timeline::onProcessMessage(Message* msg)
|
||||
gfx::Rect onionRc = getOnionskinFramesBounds();
|
||||
|
||||
int newValue = m_origFrames - (m_clk.frame - hit.frame);
|
||||
docPref().onionskin.nextFrames(MAX(0, newValue));
|
||||
docPref().onionskin.nextFrames(std::max(0, newValue));
|
||||
|
||||
onionRc |= getOnionskinFramesBounds();
|
||||
invalidateRect(onionRc.offset(origin()));
|
||||
@ -1055,7 +1056,7 @@ bool Timeline::onProcessMessage(Message* msg)
|
||||
// we shouldn't change the hot (so the separator can be
|
||||
// tracked to the mouse's released).
|
||||
if (m_clk.part == PART_SEPARATOR) {
|
||||
m_separator_x = MAX(0, mousePos.x);
|
||||
m_separator_x = std::max(0, mousePos.x);
|
||||
layout();
|
||||
return true;
|
||||
}
|
||||
@ -1520,7 +1521,7 @@ void Timeline::onResize(ui::ResizeEvent& ev)
|
||||
gfx::Rect(
|
||||
rc.x,
|
||||
rc.y+(visibleTagBands()-1)*oneTagHeight(),
|
||||
MIN(sz.w, m_separator_x),
|
||||
std::min(sz.w, m_separator_x),
|
||||
oneTagHeight()));
|
||||
|
||||
updateScrollBars();
|
||||
@ -2707,7 +2708,7 @@ gfx::Rect Timeline::getPartBounds(const Hit& hit) const
|
||||
case PART_HEADER_FRAME:
|
||||
return gfx::Rect(
|
||||
bounds.x + m_separator_x + m_separator_w - 1
|
||||
+ frameBoxWidth()*MAX(firstFrame(), hit.frame) - viewScroll().x,
|
||||
+ frameBoxWidth()*std::max(firstFrame(), hit.frame) - viewScroll().x,
|
||||
bounds.y + y, frameBoxWidth(), headerBoxHeight());
|
||||
|
||||
case PART_ROW:
|
||||
@ -2806,7 +2807,7 @@ gfx::Rect Timeline::getPartBounds(const Hit& hit) const
|
||||
return gfx::Rect(
|
||||
bounds.x + m_separator_x + m_separator_w - 1,
|
||||
bounds.y
|
||||
+ (m_tagFocusBand < 0 ? oneTagHeight() * MAX(0, hit.band): 0),
|
||||
+ (m_tagFocusBand < 0 ? oneTagHeight() * std::max(0, hit.band): 0),
|
||||
bounds.w - m_separator_x - m_separator_w + 1,
|
||||
oneTagHeight());
|
||||
|
||||
@ -2827,7 +2828,7 @@ gfx::Rect Timeline::getPartBounds(const Hit& hit) const
|
||||
return gfx::Rect(
|
||||
bounds.x + bounds.w - sz.w - 2*ui::guiscale(),
|
||||
bounds.y
|
||||
+ (m_tagFocusBand < 0 ? oneTagHeight() * MAX(0, hit.band): 0)
|
||||
+ (m_tagFocusBand < 0 ? oneTagHeight() * std::max(0, hit.band): 0)
|
||||
+ oneTagHeight()/2 - sz.h/2,
|
||||
sz.w, sz.h);
|
||||
}
|
||||
@ -2986,7 +2987,7 @@ void Timeline::regenerateTagBands()
|
||||
const int oldVisibleBands = visibleTagBands();
|
||||
m_tagBands = 0;
|
||||
for (int i : tagsPerFrame)
|
||||
m_tagBands = MAX(m_tagBands, i);
|
||||
m_tagBands = std::max(m_tagBands, i);
|
||||
|
||||
if (m_tagFocusBand >= m_tagBands)
|
||||
m_tagFocusBand = -1;
|
||||
@ -3540,8 +3541,8 @@ gfx::Point Timeline::getMaxScrollablePos() const
|
||||
gfx::Size size = getScrollableSize();
|
||||
int max_scroll_x = size.w - getCelsBounds().w + 1*guiscale();
|
||||
int max_scroll_y = size.h - getCelsBounds().h + 1*guiscale();
|
||||
max_scroll_x = MAX(0, max_scroll_x);
|
||||
max_scroll_y = MAX(0, max_scroll_y);
|
||||
max_scroll_x = std::max(0, max_scroll_x);
|
||||
max_scroll_y = std::max(0, max_scroll_y);
|
||||
return gfx::Point(max_scroll_x, max_scroll_y);
|
||||
}
|
||||
else
|
||||
@ -3927,9 +3928,9 @@ double Timeline::zoom() const
|
||||
int Timeline::calcTagVisibleToFrame(Tag* tag) const
|
||||
{
|
||||
return
|
||||
MAX(tag->toFrame(),
|
||||
tag->fromFrame() +
|
||||
font()->textLength(tag->name())/frameBoxWidth());
|
||||
std::max(tag->toFrame(),
|
||||
tag->fromFrame() +
|
||||
font()->textLength(tag->name())/frameBoxWidth());
|
||||
}
|
||||
|
||||
int Timeline::topHeight() const
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (c) 2019 Igara Studio S.A.
|
||||
// Copyright (c) 2019-2020 Igara Studio S.A.
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -20,6 +20,7 @@
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
namespace app {
|
||||
@ -80,7 +81,7 @@ void resize_cel_image(
|
||||
const int h = std::max(1, int(scale.h*image->height()));
|
||||
doc::ImageRef newImage(
|
||||
doc::Image::create(
|
||||
image->pixelFormat(), MAX(1, w), MAX(1, h)));
|
||||
image->pixelFormat(), std::max(1, w), std::max(1, h)));
|
||||
newImage->setMaskColor(image->maskColor());
|
||||
|
||||
doc::algorithm::fixup_image_transparent_colors(image);
|
||||
|
@ -291,8 +291,8 @@ void fill_rotated_ellipse(int cx, int cy, int a, int b, double angle, void* data
|
||||
r.first = r.second = x;
|
||||
}
|
||||
else {
|
||||
r.first = MIN(r.first, x);
|
||||
r.second = MAX(r.second, x);
|
||||
r.first = std::min(r.first, x);
|
||||
r.second = std::max(r.second, x);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2020 Igara Studio S.A.
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -8,11 +9,11 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "base/base.h"
|
||||
#include "doc/algorithm/rotate.h"
|
||||
#include "doc/image_impl.h"
|
||||
#include "doc/primitives.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
namespace doc {
|
||||
@ -173,10 +174,10 @@ void rotsprite_image(Image* bmp, const Image* spr, const Image* mask,
|
||||
if (!buf[i])
|
||||
buf[i].reset(new ImageBuffer(1));
|
||||
|
||||
int xmin = MIN(x1, MIN(x2, MIN(x3, x4)));
|
||||
int xmax = MAX(x1, MAX(x2, MAX(x3, x4)));
|
||||
int ymin = MIN(y1, MIN(y2, MIN(y3, y4)));
|
||||
int ymax = MAX(y1, MAX(y2, MAX(y3, y4)));
|
||||
int xmin = std::min(x1, std::min(x2, std::min(x3, x4)));
|
||||
int xmax = std::max(x1, std::max(x2, std::max(x3, x4)));
|
||||
int ymin = std::min(y1, std::min(y2, std::min(y3, y4)));
|
||||
int ymax = std::max(y1, std::max(y2, std::max(y3, y4)));
|
||||
int rot_width = xmax - xmin;
|
||||
int rot_height = ymax - ymin;
|
||||
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
#include "doc/blend_funcs.h"
|
||||
|
||||
#include "base/base.h"
|
||||
#include "base/debug.h"
|
||||
#include "doc/blend_internals.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
namespace {
|
||||
@ -30,8 +30,8 @@ namespace {
|
||||
#define blend_multiply(b, s, t) (MUL_UN8((b), (s), (t)))
|
||||
#define blend_screen(b, s, t) ((b) + (s) - MUL_UN8((b), (s), (t)))
|
||||
#define blend_overlay(b, s, t) (blend_hard_light(s, b, t))
|
||||
#define blend_darken(b, s) (MIN((b), (s)))
|
||||
#define blend_lighten(b, s) (MAX((b), (s)))
|
||||
#define blend_darken(b, s) (std::min((b), (s)))
|
||||
#define blend_lighten(b, s) (std::max((b), (s)))
|
||||
#define blend_hard_light(b, s, t) ((s) < 128 ? \
|
||||
blend_multiply((b), (s)<<1, (t)): \
|
||||
blend_screen((b), ((s)<<1)-255, (t)))
|
||||
@ -365,14 +365,14 @@ static double lum(double r, double g, double b)
|
||||
|
||||
static double sat(double r, double g, double b)
|
||||
{
|
||||
return MAX(r, MAX(g, b)) - MIN(r, MIN(g, b));
|
||||
return std::max(r, std::max(g, b)) - std::min(r, std::min(g, b));
|
||||
}
|
||||
|
||||
static void clip_color(double& r, double& g, double& b)
|
||||
{
|
||||
double l = lum(r, g, b);
|
||||
double n = MIN(r, MIN(g, b));
|
||||
double x = MAX(r, MAX(g, b));
|
||||
double n = std::min(r, std::min(g, b));
|
||||
double x = std::max(r, std::max(g, b));
|
||||
|
||||
if (n < 0) {
|
||||
r = l + (((r - l) * l) / (l - n));
|
||||
@ -399,7 +399,11 @@ static void set_lum(double& r, double& g, double& b, double l)
|
||||
// TODO replace this with a better impl (and test this, not sure if it's correct)
|
||||
static void set_sat(double& r, double& g, double& b, double s)
|
||||
{
|
||||
#undef MIN
|
||||
#undef MAX
|
||||
#undef MID
|
||||
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
|
||||
#define MAX(x,y) (((x) > (y)) ? (x) : (y))
|
||||
#define MID(x,y,z) ((x) > (y) ? ((y) > (z) ? (y) : ((x) > (z) ? \
|
||||
(z) : (x))) : ((y) > (z) ? ((z) > (x) ? (z) : \
|
||||
(x)): (y)))
|
||||
@ -495,7 +499,9 @@ color_t rgba_blender_addition(color_t backdrop, color_t src, int opacity)
|
||||
int r = rgba_getr(backdrop) + rgba_getr(src);
|
||||
int g = rgba_getg(backdrop) + rgba_getg(src);
|
||||
int b = rgba_getb(backdrop) + rgba_getb(src);
|
||||
src = rgba(MIN(r, 255), MIN(g, 255), MIN(b, 255), 0) | (src & rgba_a_mask);
|
||||
src = rgba(std::min(r, 255),
|
||||
std::min(g, 255),
|
||||
std::min(b, 255), 0) | (src & rgba_a_mask);
|
||||
return rgba_blender_normal(backdrop, src, opacity);
|
||||
}
|
||||
|
||||
@ -707,14 +713,14 @@ color_t graya_blender_exclusion(color_t backdrop, color_t src, int opacity)
|
||||
color_t graya_blender_addition(color_t backdrop, color_t src, int opacity)
|
||||
{
|
||||
int v = graya_getv(backdrop) + graya_getv(src);
|
||||
src = graya(MIN(v, 255), 0) | (src & graya_a_mask);
|
||||
src = graya(std::min(v, 255), 0) | (src & graya_a_mask);
|
||||
return graya_blender_normal(backdrop, src, opacity);
|
||||
}
|
||||
|
||||
color_t graya_blender_subtract(color_t backdrop, color_t src, int opacity)
|
||||
{
|
||||
int v = graya_getv(backdrop) - graya_getv(src);
|
||||
src = graya(MAX(v, 0), 0) | (src & graya_a_mask);
|
||||
src = graya(std::max(v, 0), 0) | (src & graya_a_mask);
|
||||
return graya_blender_normal(backdrop, src, opacity);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2020 Igara Studio S.A.
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -12,6 +13,7 @@
|
||||
#include "base/serialization.h"
|
||||
#include "doc/palette.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
@ -36,7 +38,7 @@ Palette* load_act_file(const char *filename)
|
||||
int colors = ActMaxColors;
|
||||
// If there's extra bytes, it's the number of colors to use
|
||||
if (!f.eof()) {
|
||||
colors = MIN(read16(f), ActMaxColors);
|
||||
colors = std::min(read16(f), (uint16_t)ActMaxColors);
|
||||
}
|
||||
|
||||
std::unique_ptr<Palette> pal(new Palette(frame_t(0), colors));
|
||||
@ -63,7 +65,7 @@ bool save_act_file(const Palette *pal, const char *filename)
|
||||
uint8_t rgb[ActMaxColors * 3] = { 0 };
|
||||
uint8_t *c = rgb;
|
||||
|
||||
int colors = MIN(pal->size(), ActMaxColors);
|
||||
int colors = std::min(pal->size(), ActMaxColors);
|
||||
for (int i = 0; i < colors; ++i) {
|
||||
uint32_t col = pal->getEntry(i);
|
||||
|
||||
|
@ -78,7 +78,7 @@ Palette* load_col_file(const char* filename)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pal = new Palette(frame_t(0), MIN(d.quot, 256));
|
||||
pal = new Palette(frame_t(0), std::min(d.quot, 256));
|
||||
|
||||
for (c=0; c<pal->size(); c++) {
|
||||
r = fgetc(f);
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2020 Igara Studio S.A.
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -10,13 +11,13 @@
|
||||
|
||||
#include "doc/image_io.h"
|
||||
|
||||
#include "base/base.h"
|
||||
#include "base/exception.h"
|
||||
#include "base/serialization.h"
|
||||
#include "doc/cancel_io.h"
|
||||
#include "doc/image.h"
|
||||
#include "zlib.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
@ -145,7 +146,7 @@ Image* read_image(std::istream& is, bool setId)
|
||||
uint8_t* address_end = image->getPixelAddress(0, 0) + uncompressed_size;
|
||||
|
||||
while (remain > 0) {
|
||||
int len = MIN(remain, (int)compressed.size());
|
||||
int len = std::min(remain, int(compressed.size()));
|
||||
if (is.read((char*)&compressed[0], len).fail()) {
|
||||
ASSERT(false);
|
||||
throw base::Exception("Error reading stream to restore image");
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2020 Igara Studio S.A.
|
||||
// Copyright (c) 2001-2017 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -111,8 +112,8 @@ void Palette::copyColorsTo(Palette* dst) const
|
||||
int Palette::countDiff(const Palette* other, int* from, int* to) const
|
||||
{
|
||||
int c, diff = 0;
|
||||
int min = MIN(this->m_colors.size(), other->m_colors.size());
|
||||
int max = MAX(this->m_colors.size(), other->m_colors.size());
|
||||
int min = std::min(this->m_colors.size(), other->m_colors.size());
|
||||
int max = std::max(this->m_colors.size(), other->m_colors.size());
|
||||
|
||||
if (from) *from = -1;
|
||||
if (to) *to = -1;
|
||||
@ -244,7 +245,7 @@ int Palette::findBestfit(int r, int g, int b, int a, int mask_index) const
|
||||
|
||||
int bestfit = 0;
|
||||
int lowest = std::numeric_limits<int>::max();
|
||||
int size = MIN(256, m_colors.size());
|
||||
int size = std::min(256, int(m_colors.size()));
|
||||
|
||||
for (int i=0; i<size; ++i) {
|
||||
color_t rgb = m_colors[i];
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "doc/palette.h"
|
||||
#include "doc/palette_picks.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace doc {
|
||||
|
||||
Remap create_remap_to_move_picks(const PalettePicks& picks, int beforeIndex)
|
||||
@ -71,7 +73,7 @@ Remap create_remap_to_change_palette(
|
||||
const int oldMaskIndex,
|
||||
const bool remapMaskIndex)
|
||||
{
|
||||
Remap remap(MAX(oldPalette->size(), newPalette->size()));
|
||||
Remap remap(std::max(oldPalette->size(), newPalette->size()));
|
||||
int maskIndex = oldMaskIndex;
|
||||
|
||||
if (maskIndex >= 0) {
|
||||
|
@ -394,7 +394,7 @@ void Sprite::removeFrame(frame_t frame)
|
||||
|
||||
void Sprite::setTotalFrames(frame_t frames)
|
||||
{
|
||||
frames = MAX(frame_t(1), frames);
|
||||
frames = std::max(frame_t(1), frames);
|
||||
m_frlens.resize(frames);
|
||||
|
||||
if (frames > m_frames) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -107,8 +108,8 @@ void MedianFilter::setSize(int width, int height)
|
||||
ASSERT(width >= 1);
|
||||
ASSERT(height >= 1);
|
||||
|
||||
m_width = MAX(1, width);
|
||||
m_height = MAX(1, height);
|
||||
m_width = std::max(1, width);
|
||||
m_height = std::max(1, height);
|
||||
m_ncolors = width*height;
|
||||
|
||||
for (int c = 0; c < 4; ++c)
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Render Library
|
||||
// Copyright (c) 2019 Igara Studio S.A.
|
||||
// Copyright (c) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -436,8 +436,9 @@ void PaletteOptimizer::calculate(Palette* palette, int maskIndex)
|
||||
if (maskIndex < palette->size())
|
||||
palette->setEntry(maskIndex, rgba(0, 0, 0, (m_withAlpha ? 0: 255)));
|
||||
}
|
||||
else
|
||||
palette->resize(MAX(1, usedColors));
|
||||
else {
|
||||
palette->resize(std::max(1, usedColors));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace render
|
||||
|
Loading…
x
Reference in New Issue
Block a user