mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-06 21:39:57 +00:00
Added color_is_valid() function to know if a color is inside the valid range of palette indices.
This commit is contained in:
parent
70240c9639
commit
c975930fc3
@ -139,6 +139,22 @@ int color_type(color_t color)
|
||||
return GET_COLOR_TYPE(color);
|
||||
}
|
||||
|
||||
// Returns false only if the color is a index and it is outside the
|
||||
// valid range (outside the maximum number of colors in the current
|
||||
// palette)
|
||||
bool color_is_valid(color_t color)
|
||||
{
|
||||
switch (GET_COLOR_TYPE(color)) {
|
||||
|
||||
case COLOR_TYPE_INDEX: {
|
||||
size_t i = GET_COLOR_DATA_INDEX(color);
|
||||
return (i >= 0 && i < get_current_palette()->size());
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool color_equals(color_t c1, color_t c2)
|
||||
{
|
||||
return
|
||||
|
@ -39,6 +39,7 @@ char *color_to_string(color_t color, char *buf, int size);
|
||||
color_t string_to_color(const char *str);
|
||||
|
||||
int color_type(color_t color);
|
||||
bool color_is_valid(color_t color);
|
||||
bool color_equals(color_t c1, color_t c2);
|
||||
|
||||
color_t color_mask();
|
||||
|
Loading…
x
Reference in New Issue
Block a user