mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-16 05:42:32 +00:00
Move doc::rgba_to_graya_* functions from .h to .cpp
This commit is contained in:
parent
847f176f0d
commit
c6720b543a
@ -1,4 +1,5 @@
|
||||
# Aseprite Document Library
|
||||
# Copyright (C) 2020 Igara Studio S.A.
|
||||
# Copyright (C) 2001-2018 David Capello
|
||||
|
||||
if(WIN32)
|
||||
@ -28,6 +29,7 @@ add_library(doc-lib
|
||||
cel_data_io.cpp
|
||||
cel_io.cpp
|
||||
cels_range.cpp
|
||||
color.cpp
|
||||
compressed_image.cpp
|
||||
conversion_to_surface.cpp
|
||||
document.cpp
|
||||
|
46
src/doc/color.cpp
Normal file
46
src/doc/color.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2020 Igara Studio S.A.
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "doc/color.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace doc {
|
||||
|
||||
color_t rgba_to_graya_using_hsv(const color_t c)
|
||||
{
|
||||
const uint8_t M = std::max(rgba_getr(c),
|
||||
std::max(rgba_getg(c),
|
||||
rgba_getb(c)));
|
||||
return graya(M,
|
||||
rgba_geta(c));
|
||||
}
|
||||
|
||||
color_t rgba_to_graya_using_hsl(const color_t c)
|
||||
{
|
||||
const int m = std::min(rgba_getr(c),
|
||||
std::min(rgba_getg(c),
|
||||
rgba_getb(c)));
|
||||
const int M = std::max(rgba_getr(c),
|
||||
std::max(rgba_getg(c),
|
||||
rgba_getb(c)));
|
||||
return graya((M + m) / 2,
|
||||
rgba_geta(c));
|
||||
}
|
||||
|
||||
color_t rgba_to_graya_using_luma(const color_t c)
|
||||
{
|
||||
return graya(rgb_luma(rgba_getr(c),
|
||||
rgba_getg(c),
|
||||
rgba_getb(c)),
|
||||
rgba_geta(c));
|
||||
}
|
||||
|
||||
} // namespace doc
|
@ -11,8 +11,6 @@
|
||||
|
||||
#include "base/ints.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace doc {
|
||||
|
||||
// The greatest int type to storage a color for an image in the
|
||||
@ -95,31 +93,9 @@ namespace doc {
|
||||
|
||||
typedef color_t (*rgba_to_graya_func)(const color_t c);
|
||||
|
||||
inline color_t rgba_to_graya_using_hsv(const color_t c) {
|
||||
const uint8_t M = std::max(rgba_getr(c),
|
||||
std::max(rgba_getg(c),
|
||||
rgba_getb(c)));
|
||||
return graya(M,
|
||||
rgba_geta(c));
|
||||
}
|
||||
|
||||
inline color_t rgba_to_graya_using_hsl(const color_t c) {
|
||||
const int m = std::min(rgba_getr(c),
|
||||
std::min(rgba_getg(c),
|
||||
rgba_getb(c)));
|
||||
const int M = std::max(rgba_getr(c),
|
||||
std::max(rgba_getg(c),
|
||||
rgba_getb(c)));
|
||||
return graya((M + m) / 2,
|
||||
rgba_geta(c));
|
||||
}
|
||||
|
||||
inline color_t rgba_to_graya_using_luma(const color_t c) {
|
||||
return graya(rgb_luma(rgba_getr(c),
|
||||
rgba_getg(c),
|
||||
rgba_getb(c)),
|
||||
rgba_geta(c));
|
||||
}
|
||||
color_t rgba_to_graya_using_hsv(const color_t c);
|
||||
color_t rgba_to_graya_using_hsl(const color_t c);
|
||||
color_t rgba_to_graya_using_luma(const color_t c);
|
||||
|
||||
} // namespace doc
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user