Added CurrentSpriteRgbMap class.

This commit is contained in:
David Capello 2009-06-11 00:33:29 +00:00
parent 9ba545025b
commit b4a0d2f7d7
8 changed files with 29 additions and 32 deletions

View File

@ -1,3 +1,7 @@
2009-06-10 David A. Capello <davidcapello@gmail.com>
* src/modules/palettes.h: Added CurrentSpriteRgbMap class.
2009-06-01 David A. Capello <davidcapello@gmail.com>
* src/ase/current_sprite.h (CurrentSprite): Added.

View File

@ -92,9 +92,10 @@ static void cmd_change_image_type_execute(const char *argument)
else
dithermethod = DITHERING_ORDERED;
use_current_sprite_rgb_map();
sprite_set_imgtype(current_sprite, destimgtype, dithermethod);
restore_rgb_map();
{
CurrentSpriteRgbMap rgbmap;
sprite_set_imgtype(current_sprite, destimgtype, dithermethod);
}
app_refresh_screen();
}

View File

@ -226,11 +226,11 @@ static Image *render_text(Sprite* sprite, FONT *f, const char *text, int color)
DO(ase_uint16, _graya(_graya_getv(color), getg32(c)));
break;
case IMAGE_INDEXED:
use_current_sprite_rgb_map();
case IMAGE_INDEXED: {
CurrentSpriteRgbMap rgbmap;
DO(ase_uint8, c == makecol32(255, 0, 255) ? 0: color);
restore_rgb_map();
break;
}
}
release_bitmap(bmp);

View File

@ -511,9 +511,10 @@ void draw_color(BITMAP *bmp, int x1, int y1, int x2, int y2,
rectfill(graph, 0, 0, w-1, h-1, get_color_for_allegro(32, color2));
}
use_current_sprite_rgb_map();
blit(graph, bmp, 0, 0, x1, y1, w, h);
restore_rgb_map();
{
CurrentSpriteRgbMap rgbmap;
blit(graph, bmp, 0, 0, x1, y1, w, h);
}
destroy_bitmap(graph);
break;
@ -529,9 +530,10 @@ void draw_color(BITMAP *bmp, int x1, int y1, int x2, int y2,
rectfill(graph, 0, 0, w-1, h-1, get_color_for_allegro(32, color2));
}
use_current_sprite_rgb_map();
blit(graph, bmp, 0, 0, x1, y1, w, h);
restore_rgb_map();
{
CurrentSpriteRgbMap rgbmap;
blit(graph, bmp, 0, 0, x1, y1, w, h);
}
destroy_bitmap(graph);
break;

View File

@ -247,23 +247,12 @@ void set_current_color(int index, int r, int g, int b)
/**********************************************************************/
void use_current_sprite_rgb_map()
CurrentSpriteRgbMap::CurrentSpriteRgbMap()
{
rgb_map = orig_rgb_map;
}
void use_sprite_rgb_map(Sprite *sprite)
{
Palette *pal = sprite_get_palette(sprite, sprite->frame);
PALETTE rgbpal;
rgb_map = my_rgb_map;
regen_my_rgb_map = TRUE;
create_rgb_table(my_rgb_map, palette_to_allegro(pal, rgbpal), NULL);
}
void restore_rgb_map()
CurrentSpriteRgbMap::~CurrentSpriteRgbMap()
{
rgb_map = my_rgb_map;

View File

@ -39,9 +39,12 @@ bool set_current_palette(Palette* palette, int forced);
void set_black_palette();
void set_current_color(int index, int r, int g, int b);
void use_current_sprite_rgb_map();
void use_sprite_rgb_map(Sprite* sprite);
void restore_rgb_map();
class CurrentSpriteRgbMap
{
public:
CurrentSpriteRgbMap();
~CurrentSpriteRgbMap();
};
#endif /* MODULES_PALETTES_H */

View File

@ -229,9 +229,8 @@ void clipboard::paste(Sprite* sprite)
clipboard_image->w,
clipboard_image->h);
use_current_sprite_rgb_map();
CurrentSpriteRgbMap rgbmap;
image_convert(clipboard_image, src_image);
restore_rgb_map();
}
// do the interactive-transform loop (where the user can move the floating image)

View File

@ -335,7 +335,7 @@ void editor_draw_sprite(JWidget widget, int x1, int y1, int x2, int y2)
#else
acquire_bitmap(ji_screen);
use_current_sprite_rgb_map();
CurrentSpriteRgbMap rgbmap;
if (bitmap_color_depth(screen) == 8) {
image_to_allegro(rendered, ji_screen, dest_x, dest_y);
}
@ -349,7 +349,6 @@ void editor_draw_sprite(JWidget widget, int x1, int y1, int x2, int y2)
image_to_allegro(rendered, ji_screen, dest_x, dest_y);
unselect_palette();
}
restore_rgb_map();
release_bitmap(ji_screen);