aseprite/src/raster/palette.h

68 lines
2.2 KiB
C
Raw Normal View History

2008-03-22 21:44:03 +00:00
/* ASE - Allegro Sprite Editor
* Copyright (C) 2001-2009 David Capello
2008-03-22 21:44:03 +00:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
2009-08-17 21:38:00 +00:00
#ifndef RASTER_PALETTE_H_INCLUDED
#define RASTER_PALETTE_H_INCLUDED
2008-03-22 21:44:03 +00:00
#include "jinete/jbase.h"
#include "raster/gfxobj.h"
#include <allegro/color.h>
#define MAX_PALETTE_COLORS 256
class Palette : public GfxObj
2008-03-22 21:44:03 +00:00
{
public:
2008-03-22 21:44:03 +00:00
int frame;
int ncolors;
ase_uint32 color[MAX_PALETTE_COLORS];
Palette(int frame, int ncolors);
Palette(const Palette& palette);
virtual ~Palette();
2008-03-22 21:44:03 +00:00
};
2008-09-30 21:01:54 +00:00
Palette* palette_new(int frame, int ncolors);
Palette* palette_new_copy(const Palette* pal);
void palette_free(Palette* pal);
2008-03-22 21:44:03 +00:00
2008-09-30 21:01:54 +00:00
void palette_black(Palette* pal);
2008-03-22 21:44:03 +00:00
2008-09-30 21:01:54 +00:00
void palette_copy_colors(Palette* pal, const Palette* src);
int palette_count_diff(const Palette* p1, const Palette* p2, int *from, int *to);
2008-03-22 21:44:03 +00:00
2008-09-30 21:01:54 +00:00
void palette_set_ncolors(Palette* pal, int ncolors);
void palette_set_frame(Palette* pal, int frame);
2008-03-22 21:44:03 +00:00
2008-09-30 21:01:54 +00:00
ase_uint32 palette_get_entry(const Palette* pal, int i);
void palette_set_entry(Palette* pal, int i, ase_uint32 color);
2008-03-22 21:44:03 +00:00
2008-09-30 21:01:54 +00:00
void palette_make_horz_ramp(Palette* palette, int from, int to);
void palette_make_vert_ramp(Palette* palette, int from, int to, int columns);
void palette_make_rect_ramp(Palette* palette, int from, int to, int columns);
2008-03-22 21:44:03 +00:00
2008-09-30 21:01:54 +00:00
struct RGB *palette_to_allegro(const Palette* pal, struct RGB *rgb);
Palette* palette_from_allegro(Palette* pal, const struct RGB *rgb);
2008-03-22 21:44:03 +00:00
2008-09-30 21:01:54 +00:00
Palette* palette_load(const char *filename);
bool palette_save(Palette* palette, const char *filename);
2008-03-22 21:44:03 +00:00
2008-09-30 21:01:54 +00:00
int palette_find_bestfit(const Palette* pal, int r, int g, int b);
2008-03-22 21:44:03 +00:00
2009-08-17 21:38:00 +00:00
#endif