mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-04 08:46:09 +00:00
Now screen shots are generated directly in PNG format.
This commit is contained in:
parent
37be418a5a
commit
bbdd7a3f83
@ -1,3 +1,8 @@
|
||||
2007-12-16 David A. Capello <dacap@users.sourceforge.net>
|
||||
|
||||
* src/commands/cmd_screen_shot.c (cmd_screen_shot_execute): Now
|
||||
saves screen shots in PNG format.
|
||||
|
||||
2007-12-13 David A. Capello <dacap@users.sourceforge.net>
|
||||
|
||||
* src/dialogs/scrsaver.c: Removed.
|
||||
|
@ -26,6 +26,9 @@
|
||||
|
||||
#include "commands/commands.h"
|
||||
#include "core/core.h"
|
||||
#include "file/file.h"
|
||||
#include "raster/raster.h"
|
||||
#include "util/misc.h"
|
||||
|
||||
#endif
|
||||
|
||||
@ -35,7 +38,6 @@ static void cmd_screen_shot_execute(const char *argument)
|
||||
char buf[512];
|
||||
PALETTE pal;
|
||||
BITMAP *bmp;
|
||||
int c;
|
||||
|
||||
/* save the active flag which indicate if the mouse is freeze or not */
|
||||
old_flag = freeze_mouse_flag;
|
||||
@ -48,7 +50,7 @@ static void cmd_screen_shot_execute(const char *argument)
|
||||
|
||||
/* get a file name for the capture */
|
||||
for (c=0; c<10000; c++) {
|
||||
usprintf(buf, "shot%04d.%s", c, "pcx");
|
||||
usprintf(buf, "shot%04d.%s", c, "png");
|
||||
if (!exists(buf))
|
||||
break;
|
||||
}
|
||||
@ -58,7 +60,47 @@ static void cmd_screen_shot_execute(const char *argument)
|
||||
|
||||
/* save in a bitmap the visible screen portion */
|
||||
bmp = create_sub_bitmap(ji_screen, 0, 0, JI_SCREEN_W, JI_SCREEN_H);
|
||||
save_bitmap(buf, bmp, pal);
|
||||
|
||||
/* creates a sprite with one layer, one image to save the bitmap as a PNG */
|
||||
{
|
||||
int imgtype = bitmap_color_depth(bmp) == 8 ? IMAGE_INDEXED: IMAGE_RGB;
|
||||
Sprite *sprite = sprite_new_with_layer(imgtype, bmp->w, bmp->h);
|
||||
Image *image = GetImage2(sprite, NULL, NULL, NULL);
|
||||
int x, y, r, g, b;
|
||||
|
||||
memcpy(sprite_get_palette(sprite, 0), pal, sizeof(PALETTE));
|
||||
|
||||
/* convert Allegro "BITMAP" to ASE "Image" */
|
||||
if (imgtype == IMAGE_RGB) {
|
||||
ase_uint32 *address = (ase_uint32 *)image->dat;
|
||||
for (y=0; y<image->h; ++y) {
|
||||
for (x=0; x<image->w; ++x) {
|
||||
c = getpixel(bmp, x, y);
|
||||
r = getr(c);
|
||||
g = getg(c);
|
||||
b = getb(c);
|
||||
*(address++) = _rgba(r, g, b, 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (imgtype == IMAGE_INDEXED) {
|
||||
ase_uint8 *address = (ase_uint8 *)image->dat;
|
||||
for (y=0; y<image->h; ++y) {
|
||||
for (x=0; x<image->w; ++x) {
|
||||
*(address++) = getpixel(bmp, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* save the sprite */
|
||||
sprite_set_filename(sprite, buf);
|
||||
sprite_save(sprite);
|
||||
|
||||
/* destroy the sprite */
|
||||
sprite_free(sprite);
|
||||
}
|
||||
|
||||
/* destroy the bitmap */
|
||||
destroy_bitmap(bmp);
|
||||
|
||||
/* restore the freeze flag by the previous value */
|
||||
|
Loading…
Reference in New Issue
Block a user