mirror of
https://github.com/aseprite/aseprite.git
synced 2024-10-06 06:50:07 +00:00
Added ase_uint8, ase_uint16, ase_uint32
This commit is contained in:
parent
1851db4ac7
commit
ece7c72b0f
@ -134,6 +134,7 @@ THANKFULNESS
|
|||||||
Elio Cuevas Gómez
|
Elio Cuevas Gómez
|
||||||
Emmanuel Rousseau (God_Cells)
|
Emmanuel Rousseau (God_Cells)
|
||||||
Hernán Echegoyemberry
|
Hernán Echegoyemberry
|
||||||
|
Jon Rafkind (kazzmir)
|
||||||
Jonathan Taylor
|
Jonathan Taylor
|
||||||
Jorge Ramírez Flores
|
Jorge Ramírez Flores
|
||||||
Juraj Michalek
|
Juraj Michalek
|
||||||
@ -144,3 +145,4 @@ THANKFULNESS
|
|||||||
Nora Amendez
|
Nora Amendez
|
||||||
Peter Wang (tjaden)
|
Peter Wang (tjaden)
|
||||||
Robert J Ohannessian (Bob)
|
Robert J Ohannessian (Bob)
|
||||||
|
Trent Gamblin (trentg)
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
2007-12-11 David A. Capello <dacap@users.sourceforge.net>
|
||||||
|
|
||||||
|
* src/raster/sprite.c (sprite_set_imgtype): Added convertion of
|
||||||
|
the background color.
|
||||||
|
|
||||||
|
* config.h: Added ase_uint8, ase_uint16, ase_uint32 to support 64
|
||||||
|
bits CPU (problems with amd64 reported by Jon Rafkind).
|
||||||
|
|
||||||
2007-12-08 David A. Capello <dacap@users.sourceforge.net>
|
2007-12-08 David A. Capello <dacap@users.sourceforge.net>
|
||||||
|
|
||||||
* src/file/png_format.c (save_PNG): Fixed a problem when saving
|
* src/file/png_format.c (save_PNG): Fixed a problem when saving
|
||||||
|
4
TODO.txt
4
TODO.txt
@ -2,6 +2,10 @@ High priority work
|
|||||||
------------------
|
------------------
|
||||||
|
|
||||||
- search for TODO;
|
- search for TODO;
|
||||||
|
- Problems:
|
||||||
|
- 100% CPU
|
||||||
|
- test UNDO in 64bits plataforms (reported by Jon Rafkind);
|
||||||
|
- Add menus for play animation, a menu for all animation stuff
|
||||||
- add support for PNG files.
|
- add support for PNG files.
|
||||||
- ver por el nuevo load_font de Allegro.
|
- ver por el nuevo load_font de Allegro.
|
||||||
- complete palette operations, and palette editor (it needs a slider
|
- complete palette operations, and palette editor (it needs a slider
|
||||||
|
6
config.h
6
config.h
@ -47,3 +47,9 @@ const char *msgids_get(const char *id); /* src/intl/msgids.[ch] */
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#undef PI
|
#undef PI
|
||||||
#define PI 3.14159265358979323846
|
#define PI 3.14159265358979323846
|
||||||
|
|
||||||
|
#include <allegro/base.h>
|
||||||
|
|
||||||
|
typedef uint8_t ase_uint8;
|
||||||
|
typedef uint16_t ase_uint16;
|
||||||
|
typedef uint32_t ase_uint32;
|
||||||
|
@ -51,10 +51,17 @@
|
|||||||
</box>
|
</box>
|
||||||
</box>
|
</box>
|
||||||
</box>
|
</box>
|
||||||
<slider min="0" max="1" name="frame" />
|
<box horizontal >
|
||||||
<box horizontal homogeneous>
|
<label text="Frame:" />
|
||||||
<button text="&OK" name="button_ok" magnetic />
|
<slider min="0" max="1" name="frame" expansive />
|
||||||
<button text="&Cancel" />
|
</box>
|
||||||
|
|
||||||
|
<box horizontal>
|
||||||
|
<box horizontal expansive />
|
||||||
|
<box horizontal homogeneous>
|
||||||
|
<button text="&OK" name="button_ok" magnetic width="60" />
|
||||||
|
<button text="&Cancel" />
|
||||||
|
</box>
|
||||||
</box>
|
</box>
|
||||||
</box>
|
</box>
|
||||||
</window>
|
</window>
|
||||||
|
1
fix.sh
1
fix.sh
@ -120,4 +120,3 @@ gen_makefile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
gen_makefile makefile conf
|
gen_makefile makefile conf
|
||||||
gen_makefile jinete/makefile
|
|
||||||
|
12
makefile.gcc
12
makefile.gcc
@ -25,8 +25,8 @@ ifdef PROFILE
|
|||||||
LFLAGS += -pg
|
LFLAGS += -pg
|
||||||
else
|
else
|
||||||
ifdef DEBUGMODE
|
ifdef DEBUGMODE
|
||||||
CFLAGS += -g
|
CFLAGS += -g3
|
||||||
LFLAGS += -g
|
LFLAGS += -g3
|
||||||
else
|
else
|
||||||
CFLAGS += -s -O3
|
CFLAGS += -s -O3
|
||||||
LFLAGS += -s -O3
|
LFLAGS += -s -O3
|
||||||
@ -41,6 +41,10 @@ ifdef USE_PRECOMPILED_HEADER
|
|||||||
CFLAGS += -DUSE_PRECOMPILED_HEADER
|
CFLAGS += -DUSE_PRECOMPILED_HEADER
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef USE_X86_INT_MULT
|
||||||
|
CFLAGS += -DUSE_X86_INT_MULT
|
||||||
|
endif
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# Rules to make third party libraries
|
# Rules to make third party libraries
|
||||||
|
|
||||||
@ -93,6 +97,7 @@ VPATH = src \
|
|||||||
src/jinete/themes \
|
src/jinete/themes \
|
||||||
src/modules \
|
src/modules \
|
||||||
src/raster \
|
src/raster \
|
||||||
|
src/raster/x86 \
|
||||||
src/script \
|
src/script \
|
||||||
src/util \
|
src/util \
|
||||||
src/widgets \
|
src/widgets \
|
||||||
@ -139,6 +144,9 @@ endif
|
|||||||
$(OBJ_DIR)/%$(OBJ): %.c
|
$(OBJ_DIR)/%$(OBJ): %.c
|
||||||
$(CC) $(CFLAGS) -o $@ -c $<
|
$(CC) $(CFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
$(OBJ_DIR)/%$(OBJ): %.s
|
||||||
|
$(CC) $(CFLAGS) -x assembler-with-cpp -o $@ -c $<
|
||||||
|
|
||||||
$(OBJ_DIR)/art.%$(OBJ): %.c
|
$(OBJ_DIR)/art.%$(OBJ): %.c
|
||||||
$(CC) $(CFLAGS) -o $@ -c $<
|
$(CC) $(CFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
@ -213,6 +213,10 @@ COMMON_SOURCES = \
|
|||||||
src/widgets/target.c \
|
src/widgets/target.c \
|
||||||
src/widgets/toolbar.c
|
src/widgets/toolbar.c
|
||||||
|
|
||||||
|
ifdef USE_X86_INT_MULT
|
||||||
|
COMMON_SOURCES += src/raster/x86/int_mult.s
|
||||||
|
endif
|
||||||
|
|
||||||
COMMON_OBJS = $(addprefix $(OBJ_DIR)/, \
|
COMMON_OBJS = $(addprefix $(OBJ_DIR)/, \
|
||||||
$(addsuffix $(OBJ), \
|
$(addsuffix $(OBJ), \
|
||||||
$(notdir $(basename $(COMMON_SOURCES)))))
|
$(notdir $(basename $(COMMON_SOURCES)))))
|
||||||
|
@ -56,7 +56,7 @@ static void cmd_about_execute(const char *argument)
|
|||||||
jfree(authors_txt);
|
jfree(authors_txt);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
view = textbox = NULL;
|
view = textbox = separator2 = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
label3 = jlabel_new(COPYRIGHT);
|
label3 = jlabel_new(COPYRIGHT);
|
||||||
|
@ -86,12 +86,12 @@ static void cmd_change_image_type_execute(const char *argument)
|
|||||||
destimgtype = IMAGE_RGB;
|
destimgtype = IMAGE_RGB;
|
||||||
else if (jwidget_is_selected(radio2))
|
else if (jwidget_is_selected(radio2))
|
||||||
destimgtype = IMAGE_GRAYSCALE;
|
destimgtype = IMAGE_GRAYSCALE;
|
||||||
else if (jwidget_is_selected(radio3))
|
else
|
||||||
destimgtype = IMAGE_INDEXED;
|
destimgtype = IMAGE_INDEXED;
|
||||||
|
|
||||||
if (jwidget_is_selected(dither1))
|
if (jwidget_is_selected(dither1))
|
||||||
dithermethod = DITHERING_NONE;
|
dithermethod = DITHERING_NONE;
|
||||||
else if (jwidget_is_selected(dither2))
|
else
|
||||||
dithermethod = DITHERING_ORDERED;
|
dithermethod = DITHERING_ORDERED;
|
||||||
|
|
||||||
use_current_sprite_rgb_map();
|
use_current_sprite_rgb_map();
|
||||||
|
@ -20,27 +20,22 @@
|
|||||||
|
|
||||||
#ifndef USE_PRECOMPILED_HEADER
|
#ifndef USE_PRECOMPILED_HEADER
|
||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jbase.h"
|
||||||
|
|
||||||
#include "commands/commands.h"
|
#include "commands/commands.h"
|
||||||
#include "core/app.h"
|
#include "dialogs/dpaledit.h"
|
||||||
#include "modules/sprites.h"
|
#include "modules/sprites.h"
|
||||||
#include "raster/sprite.h"
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool cmd_palette_editor_enabled(const char *argument)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cmd_palette_editor_execute(const char *argument)
|
static void cmd_palette_editor_execute(const char *argument)
|
||||||
{
|
{
|
||||||
|
dialogs_palette_editor();
|
||||||
}
|
}
|
||||||
|
|
||||||
Command cmd_palette_editor = {
|
Command cmd_palette_editor = {
|
||||||
CMD_PALETTE_EDITOR,
|
CMD_PALETTE_EDITOR,
|
||||||
cmd_palette_editor_enabled,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
cmd_palette_editor_execute,
|
cmd_palette_editor_execute,
|
||||||
NULL
|
NULL
|
||||||
|
@ -178,7 +178,7 @@ static Image *render_text (FONT *f, const char *text, int color)
|
|||||||
#define DO(type, colfunc) \
|
#define DO(type, colfunc) \
|
||||||
{ \
|
{ \
|
||||||
register int c; \
|
register int c; \
|
||||||
unsigned long *src = (unsigned long *)bmp->dat; \
|
ase_uint32 *src = (ase_uint32 *)bmp->dat; \
|
||||||
type *dst = (type *)image->dat; \
|
type *dst = (type *)image->dat; \
|
||||||
for (i=0; i<pixels; i++) { \
|
for (i=0; i<pixels; i++) { \
|
||||||
c = *src; \
|
c = *src; \
|
||||||
@ -192,13 +192,13 @@ static Image *render_text (FONT *f, const char *text, int color)
|
|||||||
Image *image;
|
Image *image;
|
||||||
BITMAP *bmp;
|
BITMAP *bmp;
|
||||||
|
|
||||||
w = text_length (f, text);
|
w = text_length(f, text);
|
||||||
h = text_height (f);
|
h = text_height(f);
|
||||||
pixels = w*h;
|
pixels = w*h;
|
||||||
if (!pixels)
|
if (!pixels)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
bmp = create_bitmap_ex (32, w, h);
|
bmp = create_bitmap_ex(32, w, h);
|
||||||
if (!bmp)
|
if (!bmp)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -208,36 +208,36 @@ static Image *render_text (FONT *f, const char *text, int color)
|
|||||||
clear_to_color(bmp, makecol32 (255, 0, 255));
|
clear_to_color(bmp, makecol32 (255, 0, 255));
|
||||||
textout(bmp, f, text, 0, 0, makecol32 (255, 255, 255));
|
textout(bmp, f, text, 0, 0, makecol32 (255, 255, 255));
|
||||||
|
|
||||||
image = image_new (current_sprite->imgtype, w, h);
|
image = image_new(current_sprite->imgtype, w, h);
|
||||||
if (!image) {
|
if (!image) {
|
||||||
destroy_bitmap (bmp);
|
destroy_bitmap(bmp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
image_clear (image, 0);
|
image_clear(image, 0);
|
||||||
acquire_bitmap (bmp);
|
acquire_bitmap(bmp);
|
||||||
|
|
||||||
switch (image->imgtype) {
|
switch (image->imgtype) {
|
||||||
|
|
||||||
case IMAGE_RGB:
|
case IMAGE_RGB:
|
||||||
DO(unsigned long, _rgba(_rgba_getr(color),
|
DO(ase_uint32, _rgba(_rgba_getr(color),
|
||||||
_rgba_getg(color),
|
_rgba_getg(color),
|
||||||
_rgba_getb(color), getg32(c)));
|
_rgba_getb(color), getg32(c)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IMAGE_GRAYSCALE:
|
case IMAGE_GRAYSCALE:
|
||||||
DO(unsigned short, _graya(_graya_getk(color), getg32(c)));
|
DO(ase_uint16, _graya(_graya_getk(color), getg32(c)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IMAGE_INDEXED:
|
case IMAGE_INDEXED:
|
||||||
use_current_sprite_rgb_map();
|
use_current_sprite_rgb_map();
|
||||||
DO(unsigned char, c == makecol32(255, 0, 255) ? 0: color);
|
DO(ase_uint8, c == makecol32(255, 0, 255) ? 0: color);
|
||||||
restore_rgb_map();
|
restore_rgb_map();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
release_bitmap (bmp);
|
release_bitmap(bmp);
|
||||||
destroy_bitmap (bmp);
|
destroy_bitmap(bmp);
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,38 +248,38 @@ static FONT *my_load_font (const char *filename)
|
|||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
/* directories to search */
|
/* directories to search */
|
||||||
dirs = dirs_new ();
|
dirs = dirs_new();
|
||||||
|
|
||||||
dirs_add_path (dirs, filename);
|
dirs_add_path(dirs, filename);
|
||||||
|
|
||||||
usprintf (buf, "fonts/%s", filename);
|
usprintf(buf, "fonts/%s", filename);
|
||||||
dirs_cat_dirs (dirs, filename_in_datadir (buf));
|
dirs_cat_dirs(dirs, filename_in_datadir(buf));
|
||||||
|
|
||||||
usprintf (buf, "fonts/%s", get_filename (filename));
|
usprintf(buf, "fonts/%s", get_filename (filename));
|
||||||
dirs_cat_dirs (dirs, filename_in_datadir (buf));
|
dirs_cat_dirs(dirs, filename_in_datadir(buf));
|
||||||
|
|
||||||
/* search the font */
|
/* search the font */
|
||||||
for (dir=dirs; dir; dir=dir->next) {
|
for (dir=dirs; dir; dir=dir->next) {
|
||||||
/* load the font */
|
/* load the font */
|
||||||
f = ji_font_load (dir->path);
|
f = ji_font_load(dir->path);
|
||||||
if (f)
|
if (f)
|
||||||
break;
|
break;
|
||||||
else {
|
else {
|
||||||
if (exists (dir->path))
|
if (exists(dir->path))
|
||||||
PRINTF ("Unknown font format \"%s\"\n", dir->path);
|
PRINTF("Unknown font format \"%s\"\n", dir->path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dirs_free (dirs);
|
dirs_free(dirs);
|
||||||
|
|
||||||
/* error loading font */
|
/* error loading font */
|
||||||
if (!f)
|
if (!f)
|
||||||
console_printf (_("Error loading font.\n"));
|
console_printf(_("Error loading font.\n"));
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void button_font_command (JWidget widget)
|
static void button_font_command(JWidget widget)
|
||||||
{
|
{
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
||||||
@ -287,15 +287,15 @@ static void button_font_command (JWidget widget)
|
|||||||
get_config_string ("DrawText", "Font", ""),
|
get_config_string ("DrawText", "Font", ""),
|
||||||
"pcx,bmp,tga,lbm,ttf");
|
"pcx,bmp,tga,lbm,ttf");
|
||||||
if (filename) {
|
if (filename) {
|
||||||
set_config_string ("DrawText", "Font", filename);
|
set_config_string("DrawText", "Font", filename);
|
||||||
update_button_text ();
|
update_button_text();
|
||||||
jfree (filename);
|
jfree(filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_button_text (void)
|
static void update_button_text(void)
|
||||||
{
|
{
|
||||||
const char *font_str = get_config_string ("DrawText", "Font", "allegro.pcx");
|
const char *font_str = get_config_string("DrawText", "Font", "allegro.pcx");
|
||||||
|
|
||||||
jwidget_set_text (font_button, get_filename (font_str));
|
jwidget_set_text(font_button, get_filename(font_str));
|
||||||
}
|
}
|
||||||
|
@ -100,10 +100,10 @@ static void speed_timer_callback (void)
|
|||||||
speed_timer++;
|
speed_timer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
END_OF_STATIC_FUNCTION (speed_timer_callback);
|
END_OF_STATIC_FUNCTION(speed_timer_callback);
|
||||||
|
|
||||||
static void my_play_fli (const char *filename, bool loop, bool fullscreen,
|
static void my_play_fli(const char *filename, bool loop, bool fullscreen,
|
||||||
bool (*callback) ())
|
bool (*callback)())
|
||||||
{
|
{
|
||||||
unsigned char cmap[768];
|
unsigned char cmap[768];
|
||||||
unsigned char omap[768];
|
unsigned char omap[768];
|
||||||
@ -117,16 +117,16 @@ static void my_play_fli (const char *filename, bool loop, bool fullscreen,
|
|||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
/* open the file to read in binary mode */
|
/* open the file to read in binary mode */
|
||||||
f = fopen (filename, "rb");
|
f = fopen(filename, "rb");
|
||||||
if (!f)
|
if (!f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* read the header */
|
/* read the header */
|
||||||
fli_read_header (f, &fli_header);
|
fli_read_header(f, &fli_header);
|
||||||
fseek (f, 128, SEEK_SET);
|
fseek(f, 128, SEEK_SET);
|
||||||
|
|
||||||
bmp = create_bitmap_ex (8, fli_header.width, fli_header.height);
|
bmp = create_bitmap_ex(8, fli_header.width, fli_header.height);
|
||||||
old = create_bitmap_ex (8, fli_header.width, fli_header.height);
|
old = create_bitmap_ex(8, fli_header.width, fli_header.height);
|
||||||
|
|
||||||
/* stretch routine doesn't support bitmaps of different color depths */
|
/* stretch routine doesn't support bitmaps of different color depths */
|
||||||
if (bitmap_color_depth(ji_screen) != 8)
|
if (bitmap_color_depth(ji_screen) != 8)
|
||||||
@ -161,9 +161,9 @@ static void my_play_fli (const char *filename, bool loop, bool fullscreen,
|
|||||||
|
|
||||||
while (!done) {
|
while (!done) {
|
||||||
/* read the frame */
|
/* read the frame */
|
||||||
fli_read_frame (f, &fli_header,
|
fli_read_frame(f, &fli_header,
|
||||||
(unsigned char *)old->dat, omap,
|
(unsigned char *)old->dat, omap,
|
||||||
(unsigned char *)bmp->dat, cmap);
|
(unsigned char *)bmp->dat, cmap);
|
||||||
|
|
||||||
if ((!frpos) || (memcmp (omap, cmap, 768) != 0)) {
|
if ((!frpos) || (memcmp (omap, cmap, 768) != 0)) {
|
||||||
for (c=i=0; c<256; c++) {
|
for (c=i=0; c<256; c++) {
|
||||||
|
@ -261,84 +261,84 @@ void set_color_curve(Curve *curve)
|
|||||||
data.cmap[c] = MID(0, data.cmap[c], 255);
|
data.cmap[c] = MID(0, data.cmap[c], 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_color_curve4 (Effect *effect)
|
void apply_color_curve4(Effect *effect)
|
||||||
{
|
{
|
||||||
unsigned long *src_address;
|
ase_uint32 *src_address;
|
||||||
unsigned long *dst_address;
|
ase_uint32 *dst_address;
|
||||||
int x, c, r, g, b, a;
|
int x, c, r, g, b, a;
|
||||||
|
|
||||||
src_address = ((unsigned long **)effect->src->line)[effect->row+effect->y]+effect->x;
|
src_address = ((ase_uint32 **)effect->src->line)[effect->row+effect->y]+effect->x;
|
||||||
dst_address = ((unsigned long **)effect->dst->line)[effect->row+effect->y]+effect->x;
|
dst_address = ((ase_uint32 **)effect->dst->line)[effect->row+effect->y]+effect->x;
|
||||||
|
|
||||||
for (x=0; x<effect->w; x++) {
|
for (x=0; x<effect->w; x++) {
|
||||||
if (effect->mask_address) {
|
if (effect->mask_address) {
|
||||||
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
||||||
src_address++;
|
src_address++;
|
||||||
dst_address++;
|
dst_address++;
|
||||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
c = *(src_address++);
|
c = *(src_address++);
|
||||||
|
|
||||||
r = _rgba_getr (c);
|
r = _rgba_getr(c);
|
||||||
g = _rgba_getg (c);
|
g = _rgba_getg(c);
|
||||||
b = _rgba_getb (c);
|
b = _rgba_getb(c);
|
||||||
a = _rgba_geta (c);
|
a = _rgba_geta(c);
|
||||||
|
|
||||||
if (effect->target.r) r = data.cmap[r];
|
if (effect->target.r) r = data.cmap[r];
|
||||||
if (effect->target.g) g = data.cmap[g];
|
if (effect->target.g) g = data.cmap[g];
|
||||||
if (effect->target.b) b = data.cmap[b];
|
if (effect->target.b) b = data.cmap[b];
|
||||||
if (effect->target.a) a = data.cmap[a];
|
if (effect->target.a) a = data.cmap[a];
|
||||||
|
|
||||||
*(dst_address++) = _rgba (r, g, b, a);
|
*(dst_address++) = _rgba(r, g, b, a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_color_curve2 (Effect *effect)
|
void apply_color_curve2 (Effect *effect)
|
||||||
{
|
{
|
||||||
unsigned short *src_address;
|
ase_uint16 *src_address;
|
||||||
unsigned short *dst_address;
|
ase_uint16 *dst_address;
|
||||||
int x, c, k, a;
|
int x, c, k, a;
|
||||||
|
|
||||||
src_address = ((unsigned short **)effect->src->line)[effect->row+effect->y]+effect->x;
|
src_address = ((ase_uint16 **)effect->src->line)[effect->row+effect->y]+effect->x;
|
||||||
dst_address = ((unsigned short **)effect->dst->line)[effect->row+effect->y]+effect->x;
|
dst_address = ((ase_uint16 **)effect->dst->line)[effect->row+effect->y]+effect->x;
|
||||||
|
|
||||||
for (x=0; x<effect->w; x++) {
|
for (x=0; x<effect->w; x++) {
|
||||||
if (effect->mask_address) {
|
if (effect->mask_address) {
|
||||||
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
||||||
src_address++;
|
src_address++;
|
||||||
dst_address++;
|
dst_address++;
|
||||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
c = *(src_address++);
|
c = *(src_address++);
|
||||||
|
|
||||||
k = _graya_getk (c);
|
k = _graya_getk(c);
|
||||||
a = _graya_geta (c);
|
a = _graya_geta(c);
|
||||||
|
|
||||||
if (effect->target.k) k = data.cmap[k];
|
if (effect->target.k) k = data.cmap[k];
|
||||||
if (effect->target.a) a = data.cmap[a];
|
if (effect->target.a) a = data.cmap[a];
|
||||||
|
|
||||||
*(dst_address++) = _graya (k, a);
|
*(dst_address++) = _graya(k, a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_color_curve1 (Effect *effect)
|
void apply_color_curve1(Effect *effect)
|
||||||
{
|
{
|
||||||
unsigned char *src_address;
|
ase_uint8 *src_address;
|
||||||
unsigned char *dst_address;
|
ase_uint8 *dst_address;
|
||||||
int x, c, r, g, b;
|
int x, c, r, g, b;
|
||||||
|
|
||||||
src_address = ((unsigned char **)effect->src->line)[effect->row+effect->y]+effect->x;
|
src_address = ((ase_uint8 **)effect->src->line)[effect->row+effect->y]+effect->x;
|
||||||
dst_address = ((unsigned char **)effect->dst->line)[effect->row+effect->y]+effect->x;
|
dst_address = ((ase_uint8 **)effect->dst->line)[effect->row+effect->y]+effect->x;
|
||||||
|
|
||||||
for (x=0; x<effect->w; x++) {
|
for (x=0; x<effect->w; x++) {
|
||||||
if (effect->mask_address) {
|
if (effect->mask_address) {
|
||||||
@ -368,6 +368,6 @@ void apply_color_curve1 (Effect *effect)
|
|||||||
c = orig_rgb_map->data[r>>3][g>>3][b>>3];
|
c = orig_rgb_map->data[r>>3][g>>3][b>>3];
|
||||||
}
|
}
|
||||||
|
|
||||||
*(dst_address++) = MID (0, c, 255);
|
*(dst_address++) = MID(0, c, 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ ConvMatr *convmatr_new(int w, int h)
|
|||||||
ConvMatr *convmatr;
|
ConvMatr *convmatr;
|
||||||
int c, size;
|
int c, size;
|
||||||
|
|
||||||
convmatr = (ConvMatr *)jnew (ConvMatr, 1);
|
convmatr = (ConvMatr *)jnew(ConvMatr, 1);
|
||||||
if (!convmatr)
|
if (!convmatr)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -318,13 +318,13 @@ JList get_convmatr_stock(void)
|
|||||||
continue; \
|
continue; \
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_convolution_matrix4 (Effect *effect)
|
void apply_convolution_matrix4(Effect *effect)
|
||||||
{
|
{
|
||||||
ConvMatr *matrix = data.convmatr;
|
ConvMatr *matrix = data.convmatr;
|
||||||
Image *src = effect->src;
|
Image *src = effect->src;
|
||||||
Image *dst = effect->dst;
|
Image *dst = effect->dst;
|
||||||
unsigned long *src_address;
|
ase_uint32 *src_address;
|
||||||
unsigned long *dst_address;
|
ase_uint32 *dst_address;
|
||||||
int x, y, dx, dy, color;
|
int x, y, dx, dy, color;
|
||||||
int getx, gety, addx, addy;
|
int getx, gety, addx, addy;
|
||||||
int r, g, b, a;
|
int r, g, b, a;
|
||||||
@ -334,7 +334,7 @@ void apply_convolution_matrix4 (Effect *effect)
|
|||||||
if (matrix) {
|
if (matrix) {
|
||||||
w = effect->x+effect->w;
|
w = effect->x+effect->w;
|
||||||
y = effect->y+effect->row;
|
y = effect->y+effect->row;
|
||||||
dst_address = ((unsigned long **)dst->line)[y]+effect->x;
|
dst_address = ((ase_uint32 **)dst->line)[y]+effect->x;
|
||||||
|
|
||||||
for (x=effect->x; x<w; x++) {
|
for (x=effect->x; x<w; x++) {
|
||||||
/* avoid the unmask region */
|
/* avoid the unmask region */
|
||||||
@ -350,16 +350,17 @@ void apply_convolution_matrix4 (Effect *effect)
|
|||||||
|
|
||||||
r = g = b = a = 0;
|
r = g = b = a = 0;
|
||||||
|
|
||||||
GET_CONVMATR_DATA (unsigned long,
|
GET_CONVMATR_DATA
|
||||||
if (_rgba_geta (color) == 0)
|
(ase_uint32,
|
||||||
div -= *mdata;
|
if (_rgba_geta(color) == 0)
|
||||||
else {
|
div -= *mdata;
|
||||||
r += _rgba_getr (color) * (*mdata);
|
else {
|
||||||
g += _rgba_getg (color) * (*mdata);
|
r += _rgba_getr(color) * (*mdata);
|
||||||
b += _rgba_getb (color) * (*mdata);
|
g += _rgba_getg(color) * (*mdata);
|
||||||
a += _rgba_geta (color) * (*mdata);
|
b += _rgba_getb(color) * (*mdata);
|
||||||
}
|
a += _rgba_geta(color) * (*mdata);
|
||||||
);
|
}
|
||||||
|
);
|
||||||
|
|
||||||
if (effect->target.r) {
|
if (effect->target.r) {
|
||||||
r = r / div + matrix->bias;
|
r = r / div + matrix->bias;
|
||||||
@ -399,8 +400,8 @@ void apply_convolution_matrix2 (Effect *effect)
|
|||||||
ConvMatr *matrix = data.convmatr;
|
ConvMatr *matrix = data.convmatr;
|
||||||
Image *src = effect->src;
|
Image *src = effect->src;
|
||||||
Image *dst = effect->dst;
|
Image *dst = effect->dst;
|
||||||
unsigned short *src_address;
|
ase_uint16 *src_address;
|
||||||
unsigned short *dst_address;
|
ase_uint16 *dst_address;
|
||||||
int x, y, dx, dy, color;
|
int x, y, dx, dy, color;
|
||||||
int getx, gety, addx, addy;
|
int getx, gety, addx, addy;
|
||||||
int k, a;
|
int k, a;
|
||||||
@ -410,7 +411,7 @@ void apply_convolution_matrix2 (Effect *effect)
|
|||||||
if (matrix) {
|
if (matrix) {
|
||||||
w = effect->x+effect->w;
|
w = effect->x+effect->w;
|
||||||
y = effect->y+effect->row;
|
y = effect->y+effect->row;
|
||||||
dst_address = ((unsigned short **)dst->line)[y]+effect->x;
|
dst_address = ((ase_uint16 **)dst->line)[y]+effect->x;
|
||||||
|
|
||||||
for (x=effect->x; x<w; x++) {
|
for (x=effect->x; x<w; x++) {
|
||||||
/* avoid the unmask region */
|
/* avoid the unmask region */
|
||||||
@ -426,14 +427,15 @@ void apply_convolution_matrix2 (Effect *effect)
|
|||||||
|
|
||||||
k = a = 0;
|
k = a = 0;
|
||||||
|
|
||||||
GET_CONVMATR_DATA (unsigned short,
|
GET_CONVMATR_DATA
|
||||||
if (_graya_geta (color) == 0)
|
(ase_uint16,
|
||||||
div -= *mdata;
|
if (_graya_geta(color) == 0)
|
||||||
else {
|
div -= *mdata;
|
||||||
k += _graya_getk (color) * (*mdata);
|
else {
|
||||||
a += _graya_geta (color) * (*mdata);
|
k += _graya_getk(color) * (*mdata);
|
||||||
}
|
a += _graya_geta(color) * (*mdata);
|
||||||
);
|
}
|
||||||
|
);
|
||||||
|
|
||||||
if (effect->target.k) {
|
if (effect->target.k) {
|
||||||
k = k / div + matrix->bias;
|
k = k / div + matrix->bias;
|
||||||
@ -454,13 +456,13 @@ void apply_convolution_matrix2 (Effect *effect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_convolution_matrix1 (Effect *effect)
|
void apply_convolution_matrix1(Effect *effect)
|
||||||
{
|
{
|
||||||
ConvMatr *matrix = data.convmatr;
|
ConvMatr *matrix = data.convmatr;
|
||||||
Image *src = effect->src;
|
Image *src = effect->src;
|
||||||
Image *dst = effect->dst;
|
Image *dst = effect->dst;
|
||||||
unsigned char *src_address;
|
ase_uint8 *src_address;
|
||||||
unsigned char *dst_address;
|
ase_uint8 *dst_address;
|
||||||
int x, y, dx, dy, color;
|
int x, y, dx, dy, color;
|
||||||
int getx, gety, addx, addy;
|
int getx, gety, addx, addy;
|
||||||
int r, g, b, index;
|
int r, g, b, index;
|
||||||
@ -470,7 +472,7 @@ void apply_convolution_matrix1 (Effect *effect)
|
|||||||
if (matrix) {
|
if (matrix) {
|
||||||
w = effect->x+effect->w;
|
w = effect->x+effect->w;
|
||||||
y = effect->y+effect->row;
|
y = effect->y+effect->row;
|
||||||
dst_address = ((unsigned char **)dst->line)[y]+effect->x;
|
dst_address = ((ase_uint8 **)dst->line)[y]+effect->x;
|
||||||
|
|
||||||
for (x=effect->x; x<w; x++) {
|
for (x=effect->x; x<w; x++) {
|
||||||
/* avoid the unmask region */
|
/* avoid the unmask region */
|
||||||
@ -487,7 +489,7 @@ void apply_convolution_matrix1 (Effect *effect)
|
|||||||
r = g = b = index = 0;
|
r = g = b = index = 0;
|
||||||
|
|
||||||
GET_CONVMATR_DATA
|
GET_CONVMATR_DATA
|
||||||
(unsigned char,
|
(ase_uint8,
|
||||||
r += _rgb_scale_6[current_palette[color].r] * (*mdata);
|
r += _rgb_scale_6[current_palette[color].r] * (*mdata);
|
||||||
g += _rgb_scale_6[current_palette[color].g] * (*mdata);
|
g += _rgb_scale_6[current_palette[color].g] * (*mdata);
|
||||||
b += _rgb_scale_6[current_palette[color].b] * (*mdata);
|
b += _rgb_scale_6[current_palette[color].b] * (*mdata);
|
||||||
@ -496,7 +498,7 @@ void apply_convolution_matrix1 (Effect *effect)
|
|||||||
|
|
||||||
if (effect->target.index) {
|
if (effect->target.index) {
|
||||||
index = index / matrix->div + matrix->bias;
|
index = index / matrix->div + matrix->bias;
|
||||||
index = MID (0, index, 255);
|
index = MID(0, index, 255);
|
||||||
|
|
||||||
*(dst_address++) = index;
|
*(dst_address++) = index;
|
||||||
}
|
}
|
||||||
@ -510,14 +512,14 @@ void apply_convolution_matrix1 (Effect *effect)
|
|||||||
|
|
||||||
if (effect->target.g) {
|
if (effect->target.g) {
|
||||||
g = g / div + matrix->bias;
|
g = g / div + matrix->bias;
|
||||||
g = MID (0, g, 255);
|
g = MID(0, g, 255);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
g = _rgb_scale_6[current_palette[color].g];
|
g = _rgb_scale_6[current_palette[color].g];
|
||||||
|
|
||||||
if (effect->target.b) {
|
if (effect->target.b) {
|
||||||
b = b / div + matrix->bias;
|
b = b / div + matrix->bias;
|
||||||
b = MID (0, b, 255);
|
b = MID(0, b, 255);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
b = _rgb_scale_6[current_palette[color].b];
|
b = _rgb_scale_6[current_palette[color].b];
|
||||||
|
@ -245,13 +245,13 @@ void effect_begin_for_preview (Effect *effect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool effect_apply_step (Effect *effect)
|
bool effect_apply_step(Effect *effect)
|
||||||
{
|
{
|
||||||
if ((effect->row >= 0) && (effect->row < effect->h)) {
|
if ((effect->row >= 0) && (effect->row < effect->h)) {
|
||||||
if ((effect->mask) && (effect->mask->bitmap)) {
|
if ((effect->mask) && (effect->mask->bitmap)) {
|
||||||
effect->d = div (effect->x-effect->mask->x+effect->offset_x, 8);
|
effect->d = div (effect->x-effect->mask->x+effect->offset_x, 8);
|
||||||
effect->mask_address =
|
effect->mask_address =
|
||||||
((unsigned char **)effect->mask->bitmap->line)
|
((ase_uint8 **)effect->mask->bitmap->line)
|
||||||
[effect->row+effect->y-effect->mask->y+effect->offset_y]+effect->d.quot;
|
[effect->row+effect->y-effect->mask->y+effect->offset_y]+effect->d.quot;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -26,14 +26,14 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void apply_invert_color4 (Effect *effect)
|
void apply_invert_color4(Effect *effect)
|
||||||
{
|
{
|
||||||
unsigned long *src_address;
|
ase_uint32 *src_address;
|
||||||
unsigned long *dst_address;
|
ase_uint32 *dst_address;
|
||||||
int x, c, r, g, b, a;
|
int x, c, r, g, b, a;
|
||||||
|
|
||||||
src_address = ((unsigned long **)effect->src->line)[effect->row+effect->y]+effect->x;
|
src_address = ((ase_uint32 **)effect->src->line)[effect->row+effect->y]+effect->x;
|
||||||
dst_address = ((unsigned long **)effect->dst->line)[effect->row+effect->y]+effect->x;
|
dst_address = ((ase_uint32 **)effect->dst->line)[effect->row+effect->y]+effect->x;
|
||||||
|
|
||||||
for (x=0; x<effect->w; x++) {
|
for (x=0; x<effect->w; x++) {
|
||||||
if (effect->mask_address) {
|
if (effect->mask_address) {
|
||||||
@ -63,14 +63,14 @@ void apply_invert_color4 (Effect *effect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_invert_color2 (Effect *effect)
|
void apply_invert_color2(Effect *effect)
|
||||||
{
|
{
|
||||||
unsigned short *src_address;
|
ase_uint16 *src_address;
|
||||||
unsigned short *dst_address;
|
ase_uint16 *dst_address;
|
||||||
int x, c, k, a;
|
int x, c, k, a;
|
||||||
|
|
||||||
src_address = ((unsigned short **)effect->src->line)[effect->row+effect->y]+effect->x;
|
src_address = ((ase_uint16 **)effect->src->line)[effect->row+effect->y]+effect->x;
|
||||||
dst_address = ((unsigned short **)effect->dst->line)[effect->row+effect->y]+effect->x;
|
dst_address = ((ase_uint16 **)effect->dst->line)[effect->row+effect->y]+effect->x;
|
||||||
|
|
||||||
for (x=0; x<effect->w; x++) {
|
for (x=0; x<effect->w; x++) {
|
||||||
if (effect->mask_address) {
|
if (effect->mask_address) {
|
||||||
@ -96,25 +96,25 @@ void apply_invert_color2 (Effect *effect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_invert_color1 (Effect *effect)
|
void apply_invert_color1(Effect *effect)
|
||||||
{
|
{
|
||||||
unsigned char *src_address;
|
ase_uint8 *src_address;
|
||||||
unsigned char *dst_address;
|
ase_uint8 *dst_address;
|
||||||
int x, c, r, g, b;
|
int x, c, r, g, b;
|
||||||
|
|
||||||
src_address = ((unsigned char **)effect->src->line)[effect->row+effect->y]+effect->x;
|
src_address = ((ase_uint8 **)effect->src->line)[effect->row+effect->y]+effect->x;
|
||||||
dst_address = ((unsigned char **)effect->dst->line)[effect->row+effect->y]+effect->x;
|
dst_address = ((ase_uint8 **)effect->dst->line)[effect->row+effect->y]+effect->x;
|
||||||
|
|
||||||
for (x=0; x<effect->w; x++) {
|
for (x=0; x<effect->w; x++) {
|
||||||
if (effect->mask_address) {
|
if (effect->mask_address) {
|
||||||
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
||||||
src_address++;
|
src_address++;
|
||||||
dst_address++;
|
dst_address++;
|
||||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
c = *(src_address++);
|
c = *(src_address++);
|
||||||
|
@ -36,7 +36,7 @@ static struct {
|
|||||||
unsigned char *channel[4];
|
unsigned char *channel[4];
|
||||||
} data = { FALSE, 0, 0, 0, { NULL, NULL, NULL, NULL } };
|
} data = { FALSE, 0, 0, 0, { NULL, NULL, NULL, NULL } };
|
||||||
|
|
||||||
void set_median_size (int w, int h)
|
void set_median_size(int w, int h)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ void set_median_size (int w, int h)
|
|||||||
if (data.channel[c])
|
if (data.channel[c])
|
||||||
jfree (data.channel[c]);
|
jfree (data.channel[c]);
|
||||||
|
|
||||||
data.channel[c] = jmalloc (sizeof (unsigned char) * data.ncolors);
|
data.channel[c] = jmalloc(sizeof(unsigned char) * data.ncolors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,19 +58,19 @@ static int cmp_channel (const void *p1, const void *p2)
|
|||||||
return (*(unsigned char *)p2) - (*(unsigned char *)p1);
|
return (*(unsigned char *)p2) - (*(unsigned char *)p1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_median4 (Effect *effect)
|
void apply_median4(Effect *effect)
|
||||||
{
|
{
|
||||||
Image *src = effect->src;
|
Image *src = effect->src;
|
||||||
Image *dst = effect->dst;
|
Image *dst = effect->dst;
|
||||||
unsigned long *src_address;
|
ase_uint32 *src_address;
|
||||||
unsigned long *dst_address;
|
ase_uint32 *dst_address;
|
||||||
int x, y, dx, dy, color;
|
int x, y, dx, dy, color;
|
||||||
int c, w, r, g, b, a;
|
int c, w, r, g, b, a;
|
||||||
int getx, gety, addx, addy;
|
int getx, gety, addx, addy;
|
||||||
|
|
||||||
w = effect->x+effect->w;
|
w = effect->x+effect->w;
|
||||||
y = effect->y+effect->row;
|
y = effect->y+effect->row;
|
||||||
dst_address = ((unsigned long **)dst->line)[y]+effect->x;
|
dst_address = ((ase_uint32 **)dst->line)[y]+effect->x;
|
||||||
|
|
||||||
for (x=effect->x; x<w; x++) {
|
for (x=effect->x; x<w; x++) {
|
||||||
/* avoid the unmask region */
|
/* avoid the unmask region */
|
||||||
@ -86,14 +86,15 @@ void apply_median4 (Effect *effect)
|
|||||||
|
|
||||||
c = 0;
|
c = 0;
|
||||||
|
|
||||||
GET_MATRIX_DATA (unsigned long, data.w, data.h, data.w/2, data.h/2,
|
GET_MATRIX_DATA
|
||||||
color = *src_address;
|
(ase_uint32, data.w, data.h, data.w/2, data.h/2,
|
||||||
data.channel[0][c] = _rgba_getr (color);
|
color = *src_address;
|
||||||
data.channel[1][c] = _rgba_getg (color);
|
data.channel[0][c] = _rgba_getr (color);
|
||||||
data.channel[2][c] = _rgba_getb (color);
|
data.channel[1][c] = _rgba_getg (color);
|
||||||
data.channel[3][c] = _rgba_geta (color);
|
data.channel[2][c] = _rgba_getb (color);
|
||||||
c++;
|
data.channel[3][c] = _rgba_geta (color);
|
||||||
);
|
c++;
|
||||||
|
);
|
||||||
|
|
||||||
for (c=0; c<4; c++)
|
for (c=0; c<4; c++)
|
||||||
qsort (data.channel[c], data.ncolors, sizeof (unsigned char), cmp_channel);
|
qsort (data.channel[c], data.ncolors, sizeof (unsigned char), cmp_channel);
|
||||||
@ -124,19 +125,19 @@ void apply_median4 (Effect *effect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_median2 (Effect *effect)
|
void apply_median2(Effect *effect)
|
||||||
{
|
{
|
||||||
Image *src = effect->src;
|
Image *src = effect->src;
|
||||||
Image *dst = effect->dst;
|
Image *dst = effect->dst;
|
||||||
unsigned short *src_address;
|
ase_uint16 *src_address;
|
||||||
unsigned short *dst_address;
|
ase_uint16 *dst_address;
|
||||||
int x, y, dx, dy, color;
|
int x, y, dx, dy, color;
|
||||||
int c, w, k, a;
|
int c, w, k, a;
|
||||||
int getx, gety, addx, addy;
|
int getx, gety, addx, addy;
|
||||||
|
|
||||||
w = effect->x+effect->w;
|
w = effect->x+effect->w;
|
||||||
y = effect->y+effect->row;
|
y = effect->y+effect->row;
|
||||||
dst_address = ((unsigned short **)dst->line)[y]+effect->x;
|
dst_address = ((ase_uint16 **)dst->line)[y]+effect->x;
|
||||||
|
|
||||||
for (x=effect->x; x<w; x++) {
|
for (x=effect->x; x<w; x++) {
|
||||||
/* avoid the unmask region */
|
/* avoid the unmask region */
|
||||||
@ -152,12 +153,13 @@ void apply_median2 (Effect *effect)
|
|||||||
|
|
||||||
c = 0;
|
c = 0;
|
||||||
|
|
||||||
GET_MATRIX_DATA (unsigned short, data.w, data.h, data.w/2, data.h/2,
|
GET_MATRIX_DATA
|
||||||
color = *src_address;
|
(ase_uint16, data.w, data.h, data.w/2, data.h/2,
|
||||||
data.channel[0][c] = _graya_getk (color);
|
color = *src_address;
|
||||||
data.channel[1][c] = _graya_geta (color);
|
data.channel[0][c] = _graya_getk(color);
|
||||||
c++;
|
data.channel[1][c] = _graya_geta(color);
|
||||||
);
|
c++;
|
||||||
|
);
|
||||||
|
|
||||||
for (c=0; c<2; c++)
|
for (c=0; c<2; c++)
|
||||||
qsort (data.channel[c], data.ncolors, sizeof (unsigned char), cmp_channel);
|
qsort (data.channel[c], data.ncolors, sizeof (unsigned char), cmp_channel);
|
||||||
@ -178,19 +180,19 @@ void apply_median2 (Effect *effect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_median1 (Effect *effect)
|
void apply_median1(Effect *effect)
|
||||||
{
|
{
|
||||||
Image *src = effect->src;
|
Image *src = effect->src;
|
||||||
Image *dst = effect->dst;
|
Image *dst = effect->dst;
|
||||||
unsigned char *src_address;
|
ase_uint8 *src_address;
|
||||||
unsigned char *dst_address;
|
ase_uint8 *dst_address;
|
||||||
int x, y, dx, dy, color;
|
int x, y, dx, dy, color;
|
||||||
int c, w, r, g, b;
|
int c, w, r, g, b;
|
||||||
int getx, gety, addx, addy;
|
int getx, gety, addx, addy;
|
||||||
|
|
||||||
w = effect->x+effect->w;
|
w = effect->x+effect->w;
|
||||||
y = effect->y+effect->row;
|
y = effect->y+effect->row;
|
||||||
dst_address = ((unsigned char **)dst->line)[y]+effect->x;
|
dst_address = ((ase_uint8 **)dst->line)[y]+effect->x;
|
||||||
|
|
||||||
for (x=effect->x; x<w; x++) {
|
for (x=effect->x; x<w; x++) {
|
||||||
/* avoid the unmask region */
|
/* avoid the unmask region */
|
||||||
@ -206,24 +208,25 @@ void apply_median1 (Effect *effect)
|
|||||||
|
|
||||||
c = 0;
|
c = 0;
|
||||||
|
|
||||||
GET_MATRIX_DATA (unsigned char, data.w, data.h, data.w/2, data.h/2,
|
GET_MATRIX_DATA
|
||||||
color = *src_address;
|
(ase_uint8, data.w, data.h, data.w/2, data.h/2,
|
||||||
if (effect->target.index) {
|
color = *src_address;
|
||||||
data.channel[0][c] = color;
|
if (effect->target.index) {
|
||||||
}
|
data.channel[0][c] = color;
|
||||||
else {
|
}
|
||||||
data.channel[0][c] = _rgb_scale_6[current_palette[color].r];
|
else {
|
||||||
data.channel[1][c] = _rgb_scale_6[current_palette[color].g];
|
data.channel[0][c] = _rgb_scale_6[current_palette[color].r];
|
||||||
data.channel[2][c] = _rgb_scale_6[current_palette[color].b];
|
data.channel[1][c] = _rgb_scale_6[current_palette[color].g];
|
||||||
}
|
data.channel[2][c] = _rgb_scale_6[current_palette[color].b];
|
||||||
c++;
|
}
|
||||||
);
|
c++;
|
||||||
|
);
|
||||||
|
|
||||||
if (effect->target.index)
|
if (effect->target.index)
|
||||||
qsort (data.channel[0], data.ncolors, sizeof (unsigned char), cmp_channel);
|
qsort(data.channel[0], data.ncolors, sizeof(unsigned char), cmp_channel);
|
||||||
else {
|
else {
|
||||||
for (c=0; c<3; c++)
|
for (c=0; c<3; c++)
|
||||||
qsort (data.channel[c], data.ncolors, sizeof (unsigned char), cmp_channel);
|
qsort (data.channel[c], data.ncolors, sizeof(unsigned char), cmp_channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (effect->target.index) {
|
if (effect->target.index) {
|
||||||
|
@ -38,40 +38,40 @@ void set_replace_colors (int from, int to, int fuzziness)
|
|||||||
data.fuzziness = MID (0, fuzziness, 255);
|
data.fuzziness = MID (0, fuzziness, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_replace_color4 (Effect *effect)
|
void apply_replace_color4(Effect *effect)
|
||||||
{
|
{
|
||||||
unsigned long *src_address;
|
ase_uint32 *src_address;
|
||||||
unsigned long *dst_address;
|
ase_uint32 *dst_address;
|
||||||
int src_r, src_g, src_b, src_a;
|
int src_r, src_g, src_b, src_a;
|
||||||
int dst_r, dst_g, dst_b, dst_a;
|
int dst_r, dst_g, dst_b, dst_a;
|
||||||
int x, c;
|
int x, c;
|
||||||
|
|
||||||
src_address = ((unsigned long **)effect->src->line)[effect->row+effect->y]+effect->x;
|
src_address = ((ase_uint32 **)effect->src->line)[effect->row+effect->y]+effect->x;
|
||||||
dst_address = ((unsigned long **)effect->dst->line)[effect->row+effect->y]+effect->x;
|
dst_address = ((ase_uint32 **)effect->dst->line)[effect->row+effect->y]+effect->x;
|
||||||
|
|
||||||
dst_r = _rgba_getr (data.from);
|
dst_r = _rgba_getr(data.from);
|
||||||
dst_g = _rgba_getg (data.from);
|
dst_g = _rgba_getg(data.from);
|
||||||
dst_b = _rgba_getb (data.from);
|
dst_b = _rgba_getb(data.from);
|
||||||
dst_a = _rgba_geta (data.from);
|
dst_a = _rgba_geta(data.from);
|
||||||
|
|
||||||
for (x=0; x<effect->w; x++) {
|
for (x=0; x<effect->w; x++) {
|
||||||
if (effect->mask_address) {
|
if (effect->mask_address) {
|
||||||
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
||||||
src_address++;
|
src_address++;
|
||||||
dst_address++;
|
dst_address++;
|
||||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
c = *(src_address++);
|
c = *(src_address++);
|
||||||
|
|
||||||
src_r = _rgba_getr (c);
|
src_r = _rgba_getr(c);
|
||||||
src_g = _rgba_getg (c);
|
src_g = _rgba_getg(c);
|
||||||
src_b = _rgba_getb (c);
|
src_b = _rgba_getb(c);
|
||||||
src_a = _rgba_geta (c);
|
src_a = _rgba_geta(c);
|
||||||
|
|
||||||
if ((src_r >= dst_r-data.fuzziness) && (src_r <= dst_r+data.fuzziness) &&
|
if ((src_r >= dst_r-data.fuzziness) && (src_r <= dst_r+data.fuzziness) &&
|
||||||
(src_g >= dst_g-data.fuzziness) && (src_g <= dst_g+data.fuzziness) &&
|
(src_g >= dst_g-data.fuzziness) && (src_g <= dst_g+data.fuzziness) &&
|
||||||
@ -83,36 +83,36 @@ void apply_replace_color4 (Effect *effect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_replace_color2 (Effect *effect)
|
void apply_replace_color2(Effect *effect)
|
||||||
{
|
{
|
||||||
unsigned short *src_address;
|
ase_uint16 *src_address;
|
||||||
unsigned short *dst_address;
|
ase_uint16 *dst_address;
|
||||||
int src_k, src_a;
|
int src_k, src_a;
|
||||||
int dst_k, dst_a;
|
int dst_k, dst_a;
|
||||||
int x, c;
|
int x, c;
|
||||||
|
|
||||||
src_address = ((unsigned short **)effect->src->line)[effect->row+effect->y]+effect->x;
|
src_address = ((ase_uint16 **)effect->src->line)[effect->row+effect->y]+effect->x;
|
||||||
dst_address = ((unsigned short **)effect->dst->line)[effect->row+effect->y]+effect->x;
|
dst_address = ((ase_uint16 **)effect->dst->line)[effect->row+effect->y]+effect->x;
|
||||||
|
|
||||||
dst_k = _graya_getk (data.from);
|
dst_k = _graya_getk(data.from);
|
||||||
dst_a = _graya_geta (data.from);
|
dst_a = _graya_geta(data.from);
|
||||||
|
|
||||||
for (x=0; x<effect->w; x++) {
|
for (x=0; x<effect->w; x++) {
|
||||||
if (effect->mask_address) {
|
if (effect->mask_address) {
|
||||||
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
||||||
src_address++;
|
src_address++;
|
||||||
dst_address++;
|
dst_address++;
|
||||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
c = *(src_address++);
|
c = *(src_address++);
|
||||||
|
|
||||||
src_k = _graya_getk (c);
|
src_k = _graya_getk(c);
|
||||||
src_a = _graya_geta (c);
|
src_a = _graya_geta(c);
|
||||||
|
|
||||||
if ((src_k >= dst_k-data.fuzziness) && (src_k <= dst_k+data.fuzziness) &&
|
if ((src_k >= dst_k-data.fuzziness) && (src_k <= dst_k+data.fuzziness) &&
|
||||||
(src_a >= dst_a-data.fuzziness) && (src_a <= dst_a+data.fuzziness))
|
(src_a >= dst_a-data.fuzziness) && (src_a <= dst_a+data.fuzziness))
|
||||||
@ -122,25 +122,25 @@ void apply_replace_color2 (Effect *effect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_replace_color1 (Effect *effect)
|
void apply_replace_color1(Effect *effect)
|
||||||
{
|
{
|
||||||
unsigned char *src_address;
|
ase_uint8 *src_address;
|
||||||
unsigned char *dst_address;
|
ase_uint8 *dst_address;
|
||||||
int x, c;
|
int x, c;
|
||||||
|
|
||||||
src_address = ((unsigned char **)effect->src->line)[effect->row+effect->y]+effect->x;
|
src_address = ((ase_uint8 **)effect->src->line)[effect->row+effect->y]+effect->x;
|
||||||
dst_address = ((unsigned char **)effect->dst->line)[effect->row+effect->y]+effect->x;
|
dst_address = ((ase_uint8 **)effect->dst->line)[effect->row+effect->y]+effect->x;
|
||||||
|
|
||||||
for (x=0; x<effect->w; x++) {
|
for (x=0; x<effect->w; x++) {
|
||||||
if (effect->mask_address) {
|
if (effect->mask_address) {
|
||||||
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
|
||||||
src_address++;
|
src_address++;
|
||||||
dst_address++;
|
dst_address++;
|
||||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_image_bitmap_next_bit (effect->d, effect->mask_address);
|
_image_bitmap_next_bit(effect->d, effect->mask_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
c = *(src_address++);
|
c = *(src_address++);
|
||||||
|
@ -48,25 +48,25 @@ typedef struct ASE_Header
|
|||||||
{
|
{
|
||||||
long pos;
|
long pos;
|
||||||
|
|
||||||
unsigned long size;
|
ase_uint32 size;
|
||||||
unsigned short magic;
|
ase_uint16 magic;
|
||||||
unsigned short frames;
|
ase_uint16 frames;
|
||||||
unsigned short width;
|
ase_uint16 width;
|
||||||
unsigned short height;
|
ase_uint16 height;
|
||||||
unsigned short depth;
|
ase_uint16 depth;
|
||||||
unsigned long flags;
|
ase_uint32 flags;
|
||||||
unsigned short speed; /* deprecated, use "duration" of FrameHeader */
|
ase_uint16 speed; /* deprecated, use "duration" of FrameHeader */
|
||||||
unsigned long next;
|
ase_uint32 next;
|
||||||
unsigned long frit;
|
ase_uint32 frit;
|
||||||
unsigned char bgcolor[4];
|
ase_uint8 bgcolor[4];
|
||||||
} ASE_Header;
|
} ASE_Header;
|
||||||
|
|
||||||
typedef struct ASE_FrameHeader
|
typedef struct ASE_FrameHeader
|
||||||
{
|
{
|
||||||
unsigned long size;
|
ase_uint32 size;
|
||||||
unsigned short magic;
|
ase_uint16 magic;
|
||||||
unsigned short chunks;
|
ase_uint16 chunks;
|
||||||
unsigned short duration;
|
ase_uint16 duration;
|
||||||
} ASE_FrameHeader;
|
} ASE_FrameHeader;
|
||||||
|
|
||||||
static Sprite *load_ASE(const char *filename);
|
static Sprite *load_ASE(const char *filename);
|
||||||
|
@ -56,11 +56,11 @@ FileFormat format_bmp =
|
|||||||
|
|
||||||
typedef struct BITMAPFILEHEADER
|
typedef struct BITMAPFILEHEADER
|
||||||
{
|
{
|
||||||
unsigned long bfType;
|
ase_uint32 bfType;
|
||||||
unsigned long bfSize;
|
ase_uint32 bfSize;
|
||||||
unsigned short bfReserved1;
|
ase_uint16 bfReserved1;
|
||||||
unsigned short bfReserved2;
|
ase_uint16 bfReserved2;
|
||||||
unsigned long bfOffBits;
|
ase_uint32 bfOffBits;
|
||||||
} BITMAPFILEHEADER;
|
} BITMAPFILEHEADER;
|
||||||
|
|
||||||
/* Used for both OS/2 and Windows BMP.
|
/* Used for both OS/2 and Windows BMP.
|
||||||
@ -68,38 +68,38 @@ typedef struct BITMAPFILEHEADER
|
|||||||
*/
|
*/
|
||||||
typedef struct BITMAPINFOHEADER
|
typedef struct BITMAPINFOHEADER
|
||||||
{
|
{
|
||||||
unsigned long biWidth;
|
ase_uint32 biWidth;
|
||||||
unsigned long biHeight;
|
ase_uint32 biHeight;
|
||||||
unsigned short biBitCount;
|
ase_uint16 biBitCount;
|
||||||
unsigned long biCompression;
|
ase_uint32 biCompression;
|
||||||
} BITMAPINFOHEADER;
|
} BITMAPINFOHEADER;
|
||||||
|
|
||||||
typedef struct WINBMPINFOHEADER /* size: 40 */
|
typedef struct WINBMPINFOHEADER /* size: 40 */
|
||||||
{
|
{
|
||||||
unsigned long biWidth;
|
ase_uint32 biWidth;
|
||||||
unsigned long biHeight;
|
ase_uint32 biHeight;
|
||||||
unsigned short biPlanes;
|
ase_uint16 biPlanes;
|
||||||
unsigned short biBitCount;
|
ase_uint16 biBitCount;
|
||||||
unsigned long biCompression;
|
ase_uint32 biCompression;
|
||||||
unsigned long biSizeImage;
|
ase_uint32 biSizeImage;
|
||||||
unsigned long biXPelsPerMeter;
|
ase_uint32 biXPelsPerMeter;
|
||||||
unsigned long biYPelsPerMeter;
|
ase_uint32 biYPelsPerMeter;
|
||||||
unsigned long biClrUsed;
|
ase_uint32 biClrUsed;
|
||||||
unsigned long biClrImportant;
|
ase_uint32 biClrImportant;
|
||||||
} WINBMPINFOHEADER;
|
} WINBMPINFOHEADER;
|
||||||
|
|
||||||
typedef struct OS2BMPINFOHEADER /* size: 12 */
|
typedef struct OS2BMPINFOHEADER /* size: 12 */
|
||||||
{
|
{
|
||||||
unsigned short biWidth;
|
ase_uint16 biWidth;
|
||||||
unsigned short biHeight;
|
ase_uint16 biHeight;
|
||||||
unsigned short biPlanes;
|
ase_uint16 biPlanes;
|
||||||
unsigned short biBitCount;
|
ase_uint16 biBitCount;
|
||||||
} OS2BMPINFOHEADER;
|
} OS2BMPINFOHEADER;
|
||||||
|
|
||||||
/* read_bmfileheader:
|
/* read_bmfileheader:
|
||||||
* Reads a BMP file header and check that it has the BMP magic number.
|
* Reads a BMP file header and check that it has the BMP magic number.
|
||||||
*/
|
*/
|
||||||
static int read_bmfileheader (PACKFILE *f, BITMAPFILEHEADER *fileheader)
|
static int read_bmfileheader(PACKFILE *f, BITMAPFILEHEADER *fileheader)
|
||||||
{
|
{
|
||||||
fileheader->bfType = pack_igetw(f);
|
fileheader->bfType = pack_igetw(f);
|
||||||
fileheader->bfSize= pack_igetl(f);
|
fileheader->bfSize= pack_igetl(f);
|
||||||
@ -116,7 +116,7 @@ static int read_bmfileheader (PACKFILE *f, BITMAPFILEHEADER *fileheader)
|
|||||||
/* read_win_bminfoheader:
|
/* read_win_bminfoheader:
|
||||||
* Reads information from a BMP file header.
|
* Reads information from a BMP file header.
|
||||||
*/
|
*/
|
||||||
static int read_win_bminfoheader (PACKFILE *f, BITMAPINFOHEADER *infoheader)
|
static int read_win_bminfoheader(PACKFILE *f, BITMAPINFOHEADER *infoheader)
|
||||||
{
|
{
|
||||||
WINBMPINFOHEADER win_infoheader;
|
WINBMPINFOHEADER win_infoheader;
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ static int read_win_bminfoheader (PACKFILE *f, BITMAPINFOHEADER *infoheader)
|
|||||||
/* read_os2_bminfoheader:
|
/* read_os2_bminfoheader:
|
||||||
* Reads information from an OS/2 format BMP file header.
|
* Reads information from an OS/2 format BMP file header.
|
||||||
*/
|
*/
|
||||||
static int read_os2_bminfoheader (PACKFILE *f, BITMAPINFOHEADER *infoheader)
|
static int read_os2_bminfoheader(PACKFILE *f, BITMAPINFOHEADER *infoheader)
|
||||||
{
|
{
|
||||||
OS2BMPINFOHEADER os2_infoheader;
|
OS2BMPINFOHEADER os2_infoheader;
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ static int read_os2_bminfoheader (PACKFILE *f, BITMAPINFOHEADER *infoheader)
|
|||||||
/* read_bmicolors:
|
/* read_bmicolors:
|
||||||
* Loads the color palette for 1,4,8 bit formats.
|
* Loads the color palette for 1,4,8 bit formats.
|
||||||
*/
|
*/
|
||||||
static void read_bmicolors (int ncols, PACKFILE *f,int win_flag)
|
static void read_bmicolors(int ncols, PACKFILE *f,int win_flag)
|
||||||
{
|
{
|
||||||
int i, r, g, b;
|
int i, r, g, b;
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ static void read_bmicolors (int ncols, PACKFILE *f,int win_flag)
|
|||||||
/* read_1bit_line:
|
/* read_1bit_line:
|
||||||
* Support function for reading the 1 bit bitmap file format.
|
* Support function for reading the 1 bit bitmap file format.
|
||||||
*/
|
*/
|
||||||
static void read_1bit_line (int length, PACKFILE *f, Image *image, int line)
|
static void read_1bit_line(int length, PACKFILE *f, Image *image, int line)
|
||||||
{
|
{
|
||||||
unsigned char b[32];
|
unsigned char b[32];
|
||||||
unsigned long n;
|
unsigned long n;
|
||||||
@ -203,7 +203,7 @@ static void read_1bit_line (int length, PACKFILE *f, Image *image, int line)
|
|||||||
/* read_4bit_line:
|
/* read_4bit_line:
|
||||||
* Support function for reading the 4 bit bitmap file format.
|
* Support function for reading the 4 bit bitmap file format.
|
||||||
*/
|
*/
|
||||||
static void read_4bit_line (int length, PACKFILE *f, Image *image, int line)
|
static void read_4bit_line(int length, PACKFILE *f, Image *image, int line)
|
||||||
{
|
{
|
||||||
unsigned char b[8];
|
unsigned char b[8];
|
||||||
unsigned long n;
|
unsigned long n;
|
||||||
@ -231,7 +231,7 @@ static void read_4bit_line (int length, PACKFILE *f, Image *image, int line)
|
|||||||
/* read_8bit_line:
|
/* read_8bit_line:
|
||||||
* Support function for reading the 8 bit bitmap file format.
|
* Support function for reading the 8 bit bitmap file format.
|
||||||
*/
|
*/
|
||||||
static void read_8bit_line (int length, PACKFILE *f, Image *image, int line)
|
static void read_8bit_line(int length, PACKFILE *f, Image *image, int line)
|
||||||
{
|
{
|
||||||
unsigned char b[4];
|
unsigned char b[4];
|
||||||
unsigned long n;
|
unsigned long n;
|
||||||
@ -256,7 +256,7 @@ static void read_8bit_line (int length, PACKFILE *f, Image *image, int line)
|
|||||||
* Support function for reading the 24 bit bitmap file format, doing
|
* Support function for reading the 24 bit bitmap file format, doing
|
||||||
* our best to convert it down to a 256 color palette.
|
* our best to convert it down to a 256 color palette.
|
||||||
*/
|
*/
|
||||||
static void read_24bit_line (int length, PACKFILE *f, Image *image, int line)
|
static void read_24bit_line(int length, PACKFILE *f, Image *image, int line)
|
||||||
{
|
{
|
||||||
int i, nbytes;
|
int i, nbytes;
|
||||||
RGB c;
|
RGB c;
|
||||||
@ -280,7 +280,7 @@ static void read_24bit_line (int length, PACKFILE *f, Image *image, int line)
|
|||||||
/* read_image:
|
/* read_image:
|
||||||
* For reading the noncompressed BMP image format.
|
* For reading the noncompressed BMP image format.
|
||||||
*/
|
*/
|
||||||
static void read_image (PACKFILE *f, Image *image, AL_CONST BITMAPINFOHEADER *infoheader)
|
static void read_image(PACKFILE *f, Image *image, AL_CONST BITMAPINFOHEADER *infoheader)
|
||||||
{
|
{
|
||||||
int i, line;
|
int i, line;
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ static void read_image (PACKFILE *f, Image *image, AL_CONST BITMAPINFOHEADER *in
|
|||||||
/* read_RLE8_compressed_image:
|
/* read_RLE8_compressed_image:
|
||||||
* For reading the 8 bit RLE compressed BMP image format.
|
* For reading the 8 bit RLE compressed BMP image format.
|
||||||
*/
|
*/
|
||||||
static void read_RLE8_compressed_image (PACKFILE *f, Image *image, AL_CONST BITMAPINFOHEADER *infoheader)
|
static void read_RLE8_compressed_image(PACKFILE *f, Image *image, AL_CONST BITMAPINFOHEADER *infoheader)
|
||||||
{
|
{
|
||||||
unsigned char count, val, val0;
|
unsigned char count, val, val0;
|
||||||
int j, pos, line;
|
int j, pos, line;
|
||||||
@ -382,7 +382,7 @@ static void read_RLE8_compressed_image (PACKFILE *f, Image *image, AL_CONST BITM
|
|||||||
/* read_RLE4_compressed_image:
|
/* read_RLE4_compressed_image:
|
||||||
* For reading the 4 bit RLE compressed BMP image format.
|
* For reading the 4 bit RLE compressed BMP image format.
|
||||||
*/
|
*/
|
||||||
static void read_RLE4_compressed_image (PACKFILE *f, Image *image, AL_CONST BITMAPINFOHEADER *infoheader)
|
static void read_RLE4_compressed_image(PACKFILE *f, Image *image, AL_CONST BITMAPINFOHEADER *infoheader)
|
||||||
{
|
{
|
||||||
unsigned char b[8];
|
unsigned char b[8];
|
||||||
unsigned char count;
|
unsigned char count;
|
||||||
@ -455,7 +455,7 @@ static void read_RLE4_compressed_image (PACKFILE *f, Image *image, AL_CONST BITM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void read_bitfields_image (PACKFILE *f, Image *image, int bpp, BITMAPINFOHEADER *infoheader)
|
static void read_bitfields_image(PACKFILE *f, Image *image, int bpp, BITMAPINFOHEADER *infoheader)
|
||||||
{
|
{
|
||||||
int k, i;
|
int k, i;
|
||||||
int bytesPerPixel;
|
int bytesPerPixel;
|
||||||
@ -694,15 +694,15 @@ static int save_BMP(Sprite *sprite)
|
|||||||
for (j=0; j<image->w; j++) {
|
for (j=0; j<image->w; j++) {
|
||||||
if (bpp == 8) {
|
if (bpp == 8) {
|
||||||
if (image->imgtype == IMAGE_INDEXED)
|
if (image->imgtype == IMAGE_INDEXED)
|
||||||
pack_putc (image->method->getpixel (image, j, i), f);
|
pack_putc(image->method->getpixel(image, j, i), f);
|
||||||
else if (image->imgtype == IMAGE_GRAYSCALE)
|
else if (image->imgtype == IMAGE_GRAYSCALE)
|
||||||
pack_putc (_graya_getk (image->method->getpixel (image, j, i)), f);
|
pack_putc(_graya_getk(image->method->getpixel(image, j, i)), f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
c = image->method->getpixel (image, j, i);
|
c = image->method->getpixel(image, j, i);
|
||||||
pack_putc (_rgba_getb (c), f);
|
pack_putc(_rgba_getb(c), f);
|
||||||
pack_putc (_rgba_getg (c), f);
|
pack_putc(_rgba_getg(c), f);
|
||||||
pack_putc (_rgba_getr (c), f);
|
pack_putc(_rgba_getr(c), f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ static int save_ICO(Sprite *sprite)
|
|||||||
image_clear(bmp, 0);
|
image_clear(bmp, 0);
|
||||||
layer_render(sprite->set, bmp, 0, 0, n);
|
layer_render(sprite->set, bmp, 0, 0, n);
|
||||||
|
|
||||||
depth = 8;//bitmap_color_depth(bmp);
|
depth = 8; /* bitmap_color_depth(bmp); */
|
||||||
bpp = (depth == 8) ? 8 : 24;
|
bpp = (depth == 8) ? 8 : 24;
|
||||||
bw = (((bmp->w * bpp / 8) + 3) / 4) * 4;
|
bw = (((bmp->w * bpp / 8) + 3) / 4) * 4;
|
||||||
bitsw = ((((bmp->w + 7) / 8) + 3) / 4) * 4;
|
bitsw = ((((bmp->w + 7) / 8) + 3) / 4) * 4;
|
||||||
|
@ -189,13 +189,13 @@ static Sprite *load_JPEG(const char *filename)
|
|||||||
|
|
||||||
/* RGB */
|
/* RGB */
|
||||||
if (image->imgtype == IMAGE_RGB) {
|
if (image->imgtype == IMAGE_RGB) {
|
||||||
unsigned char *src_address;
|
ase_uint8 *src_address;
|
||||||
unsigned long *dst_address;
|
ase_uint32 *dst_address;
|
||||||
int x, y, r, g, b;
|
int x, y, r, g, b;
|
||||||
|
|
||||||
for (y=0; y<(int)num_scanlines; y++) {
|
for (y=0; y<(int)num_scanlines; y++) {
|
||||||
src_address = ((unsigned char **)buffer)[y];
|
src_address = ((ase_uint8 **)buffer)[y];
|
||||||
dst_address = ((unsigned long **)image->line)[cinfo.output_scanline-1+y];
|
dst_address = ((ase_uint32 **)image->line)[cinfo.output_scanline-1+y];
|
||||||
|
|
||||||
for (x=0; x<image->w; x++) {
|
for (x=0; x<image->w; x++) {
|
||||||
r = *(src_address++);
|
r = *(src_address++);
|
||||||
@ -207,13 +207,13 @@ static Sprite *load_JPEG(const char *filename)
|
|||||||
}
|
}
|
||||||
/* Grayscale */
|
/* Grayscale */
|
||||||
else {
|
else {
|
||||||
unsigned char *src_address;
|
ase_uint8 *src_address;
|
||||||
unsigned short *dst_address;
|
ase_uint16 *dst_address;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
for (y=0; y<(int)num_scanlines; y++) {
|
for (y=0; y<(int)num_scanlines; y++) {
|
||||||
src_address = ((unsigned char **)buffer)[y];
|
src_address = ((ase_uint8 **)buffer)[y];
|
||||||
dst_address = ((unsigned short **)image->line)[cinfo.output_scanline-1+y];
|
dst_address = ((ase_uint16 **)image->line)[cinfo.output_scanline-1+y];
|
||||||
|
|
||||||
for (x=0; x<image->w; x++)
|
for (x=0; x<image->w; x++)
|
||||||
*(dst_address++) = _graya(*(src_address++), 255);
|
*(dst_address++) = _graya(*(src_address++), 255);
|
||||||
@ -325,12 +325,12 @@ static int save_JPEG(Sprite *sprite)
|
|||||||
while (cinfo.next_scanline < cinfo.image_height) {
|
while (cinfo.next_scanline < cinfo.image_height) {
|
||||||
/* RGB */
|
/* RGB */
|
||||||
if (image->imgtype == IMAGE_RGB) {
|
if (image->imgtype == IMAGE_RGB) {
|
||||||
unsigned long *src_address;
|
ase_uint32 *src_address;
|
||||||
unsigned char *dst_address;
|
ase_uint8 *dst_address;
|
||||||
int x, y;
|
int x, y;
|
||||||
for (y=0; y<(int)buffer_height; y++) {
|
for (y=0; y<(int)buffer_height; y++) {
|
||||||
src_address = ((unsigned long **)image->line)[cinfo.next_scanline+y];
|
src_address = ((ase_uint32 **)image->line)[cinfo.next_scanline+y];
|
||||||
dst_address = ((unsigned char **)buffer)[y];
|
dst_address = ((ase_uint8 **)buffer)[y];
|
||||||
for (x=0; x<image->w; x++) {
|
for (x=0; x<image->w; x++) {
|
||||||
c = *(src_address++);
|
c = *(src_address++);
|
||||||
*(dst_address++) = _rgba_getr(c);
|
*(dst_address++) = _rgba_getr(c);
|
||||||
@ -341,12 +341,12 @@ static int save_JPEG(Sprite *sprite)
|
|||||||
}
|
}
|
||||||
/* Grayscale */
|
/* Grayscale */
|
||||||
else {
|
else {
|
||||||
unsigned short *src_address;
|
ase_uint16 *src_address;
|
||||||
unsigned char *dst_address;
|
ase_uint8 *dst_address;
|
||||||
int x, y;
|
int x, y;
|
||||||
for (y=0; y<(int)buffer_height; y++) {
|
for (y=0; y<(int)buffer_height; y++) {
|
||||||
src_address = ((unsigned short **)image->line)[cinfo.next_scanline+y];
|
src_address = ((ase_uint16 **)image->line)[cinfo.next_scanline+y];
|
||||||
dst_address = ((unsigned char **)buffer)[y];
|
dst_address = ((ase_uint8 **)buffer)[y];
|
||||||
for (x=0; x<image->w; x++)
|
for (x=0; x<image->w; x++)
|
||||||
*(dst_address++) = _graya_getk(*(src_address++));
|
*(dst_address++) = _graya_getk(*(src_address++));
|
||||||
}
|
}
|
||||||
|
@ -127,14 +127,14 @@ static Sprite *load_PCX(const char *filename)
|
|||||||
if (bpp == 8) {
|
if (bpp == 8) {
|
||||||
while (c--) {
|
while (c--) {
|
||||||
if (x < image->w)
|
if (x < image->w)
|
||||||
*(((unsigned char **)image->line)[y]+x) = ch;
|
*(((ase_uint8 **)image->line)[y]+x) = ch;
|
||||||
x++;
|
x++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while (c--) {
|
while (c--) {
|
||||||
if (xx < image->w)
|
if (xx < image->w)
|
||||||
*(((unsigned long **)image->line)[y]+xx) |= (ch & 0xff) << po;
|
*(((ase_uint32 **)image->line)[y]+xx) |= (ch & 0xff) << po;
|
||||||
x++;
|
x++;
|
||||||
if (x == bytes_per_line) {
|
if (x == bytes_per_line) {
|
||||||
xx = 0;
|
xx = 0;
|
||||||
@ -169,13 +169,13 @@ static Sprite *load_PCX(const char *filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (*allegro_errno) {
|
if (*allegro_errno) {
|
||||||
console_printf (_("Error reading bytes.\n"));
|
console_printf(_("Error reading bytes.\n"));
|
||||||
pack_fclose (f);
|
pack_fclose(f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pack_fclose (f);
|
pack_fclose(f);
|
||||||
return file_sequence_sprite ();
|
return file_sequence_sprite();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int save_PCX(Sprite *sprite)
|
static int save_PCX(Sprite *sprite)
|
||||||
@ -189,13 +189,13 @@ static int save_PCX(Sprite *sprite)
|
|||||||
char runchar;
|
char runchar;
|
||||||
char ch = 0;
|
char ch = 0;
|
||||||
|
|
||||||
f = pack_fopen (sprite->filename, F_WRITE);
|
f = pack_fopen(sprite->filename, F_WRITE);
|
||||||
if (!f) {
|
if (!f) {
|
||||||
console_printf (_("Error creating file.\n"));
|
console_printf(_("Error creating file.\n"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
image = file_sequence_image_to_save ();
|
image = file_sequence_image_to_save();
|
||||||
|
|
||||||
if (sprite->imgtype == IMAGE_RGB) {
|
if (sprite->imgtype == IMAGE_RGB) {
|
||||||
depth = 24;
|
depth = 24;
|
||||||
@ -249,16 +249,16 @@ static int save_PCX(Sprite *sprite)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (x < image->w) {
|
if (x < image->w) {
|
||||||
c = image->method->getpixel (image, x, y);
|
c = image->method->getpixel(image, x, y);
|
||||||
ch = _rgba_getr (c);
|
ch = _rgba_getr(c);
|
||||||
}
|
}
|
||||||
else if (x<image->w*2) {
|
else if (x<image->w*2) {
|
||||||
c = image->method->getpixel (image, x-image->w, y);
|
c = image->method->getpixel(image, x-image->w, y);
|
||||||
ch = _rgba_getg (c);
|
ch = _rgba_getg(c);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
c = image->method->getpixel (image, x-image->w*2, y);
|
c = image->method->getpixel(image, x-image->w*2, y);
|
||||||
ch = _rgba_getb (c);
|
ch = _rgba_getb(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (runcount == 0) {
|
if (runcount == 0) {
|
||||||
@ -284,7 +284,7 @@ static int save_PCX(Sprite *sprite)
|
|||||||
pack_putc(runchar, f);
|
pack_putc(runchar, f);
|
||||||
|
|
||||||
if (image->h > 1)
|
if (image->h > 1)
|
||||||
do_progress (100 * y / (image->h-1));
|
do_progress(100 * y / (image->h-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (depth == 8) { /* 256 color palette */
|
if (depth == 8) { /* 256 color palette */
|
||||||
@ -298,10 +298,10 @@ static int save_PCX(Sprite *sprite)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pack_fclose (f);
|
pack_fclose(f);
|
||||||
|
|
||||||
if (*allegro_errno) {
|
if (*allegro_errno) {
|
||||||
console_printf (_("Error writing bytes.\n"));
|
console_printf(_("Error writing bytes.\n"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -217,8 +217,8 @@ static Sprite *load_PNG(const char *filename)
|
|||||||
|
|
||||||
/* RGB_ALPHA */
|
/* RGB_ALPHA */
|
||||||
if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
|
if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
|
||||||
register unsigned char *src_address = row_pointer;
|
register ase_uint8 *src_address = row_pointer;
|
||||||
register unsigned long *dst_address = ((unsigned long **)image->line)[y];
|
register ase_uint32 *dst_address = ((ase_uint32 **)image->line)[y];
|
||||||
register int x, r, g, b, a;
|
register int x, r, g, b, a;
|
||||||
|
|
||||||
for (x=0; x<width; x++) {
|
for (x=0; x<width; x++) {
|
||||||
@ -231,8 +231,8 @@ static Sprite *load_PNG(const char *filename)
|
|||||||
}
|
}
|
||||||
/* RGB */
|
/* RGB */
|
||||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) {
|
else if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) {
|
||||||
register unsigned char *src_address = row_pointer;
|
register ase_uint8 *src_address = row_pointer;
|
||||||
register unsigned long *dst_address = ((unsigned long **)image->line)[y];
|
register ase_uint32 *dst_address = ((ase_uint32 **)image->line)[y];
|
||||||
register int x, r, g, b;
|
register int x, r, g, b;
|
||||||
|
|
||||||
for (x=0; x<width; x++) {
|
for (x=0; x<width; x++) {
|
||||||
@ -244,8 +244,8 @@ static Sprite *load_PNG(const char *filename)
|
|||||||
}
|
}
|
||||||
/* GRAY_ALPHA */
|
/* GRAY_ALPHA */
|
||||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
|
else if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
|
||||||
register unsigned char *src_address = row_pointer;
|
register ase_uint8 *src_address = row_pointer;
|
||||||
register unsigned short *dst_address = ((unsigned short **)image->line)[y];
|
register ase_uint16 *dst_address = ((ase_uint16 **)image->line)[y];
|
||||||
register int x, k, a;
|
register int x, k, a;
|
||||||
|
|
||||||
for (x=0; x<width; x++) {
|
for (x=0; x<width; x++) {
|
||||||
@ -256,8 +256,8 @@ static Sprite *load_PNG(const char *filename)
|
|||||||
}
|
}
|
||||||
/* GRAY */
|
/* GRAY */
|
||||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY) {
|
else if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY) {
|
||||||
register unsigned char *src_address = row_pointer;
|
register ase_uint8 *src_address = row_pointer;
|
||||||
register unsigned short *dst_address = ((unsigned short **)image->line)[y];
|
register ase_uint16 *dst_address = ((ase_uint16 **)image->line)[y];
|
||||||
int x, k;
|
int x, k;
|
||||||
|
|
||||||
for (x=0; x<width; x++) {
|
for (x=0; x<width; x++) {
|
||||||
@ -267,8 +267,8 @@ static Sprite *load_PNG(const char *filename)
|
|||||||
}
|
}
|
||||||
/* PALETTE */
|
/* PALETTE */
|
||||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
|
else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
|
||||||
register unsigned char *src_address = row_pointer;
|
register ase_uint8 *src_address = row_pointer;
|
||||||
register unsigned char *dst_address = ((unsigned char **)image->line)[y];
|
register ase_uint8 *dst_address = ((ase_uint8 **)image->line)[y];
|
||||||
register int x, c;
|
register int x, c;
|
||||||
|
|
||||||
for (x=0; x<width; x++) {
|
for (x=0; x<width; x++) {
|
||||||
@ -414,8 +414,8 @@ static int save_PNG(Sprite *sprite)
|
|||||||
for (y = 0; y < height; y++) {
|
for (y = 0; y < height; y++) {
|
||||||
/* RGB_ALPHA */
|
/* RGB_ALPHA */
|
||||||
if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
|
if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
|
||||||
register unsigned long *src_address = ((unsigned long **)image->line)[y];
|
register ase_uint32 *src_address = ((ase_uint32 **)image->line)[y];
|
||||||
register unsigned char *dst_address = row_pointer;
|
register ase_uint8 *dst_address = row_pointer;
|
||||||
register int x, c;
|
register int x, c;
|
||||||
|
|
||||||
for (x=0; x<width; x++) {
|
for (x=0; x<width; x++) {
|
||||||
@ -428,8 +428,8 @@ static int save_PNG(Sprite *sprite)
|
|||||||
}
|
}
|
||||||
/* RGB */
|
/* RGB */
|
||||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) {
|
else if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) {
|
||||||
register unsigned long *src_address = ((unsigned long **)image->line)[y];
|
register ase_uint32 *src_address = ((ase_uint32 **)image->line)[y];
|
||||||
register unsigned char *dst_address = row_pointer;
|
register ase_uint8 *dst_address = row_pointer;
|
||||||
register int x, c;
|
register int x, c;
|
||||||
|
|
||||||
for (x=0; x<width; x++) {
|
for (x=0; x<width; x++) {
|
||||||
@ -441,8 +441,8 @@ static int save_PNG(Sprite *sprite)
|
|||||||
}
|
}
|
||||||
/* GRAY_ALPHA */
|
/* GRAY_ALPHA */
|
||||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
|
else if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
|
||||||
register unsigned short *src_address = ((unsigned short **)image->line)[y];
|
register ase_uint16 *src_address = ((ase_uint16 **)image->line)[y];
|
||||||
register unsigned char *dst_address = row_pointer;
|
register ase_uint8 *dst_address = row_pointer;
|
||||||
register int x, c;
|
register int x, c;
|
||||||
|
|
||||||
for (x=0; x<width; x++) {
|
for (x=0; x<width; x++) {
|
||||||
@ -453,8 +453,8 @@ static int save_PNG(Sprite *sprite)
|
|||||||
}
|
}
|
||||||
/* GRAY */
|
/* GRAY */
|
||||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY) {
|
else if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY) {
|
||||||
register unsigned short *src_address = ((unsigned short **)image->line)[y];
|
register ase_uint16 *src_address = ((ase_uint16 **)image->line)[y];
|
||||||
register unsigned char *dst_address = row_pointer;
|
register ase_uint8 *dst_address = row_pointer;
|
||||||
register int x, c;
|
register int x, c;
|
||||||
|
|
||||||
for (x=0; x<width; x++) {
|
for (x=0; x<width; x++) {
|
||||||
@ -464,8 +464,8 @@ static int save_PNG(Sprite *sprite)
|
|||||||
}
|
}
|
||||||
/* PALETTE */
|
/* PALETTE */
|
||||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
|
else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
|
||||||
register unsigned char *src_address = ((unsigned char **)image->line)[y];
|
register ase_uint8 *src_address = ((ase_uint8 **)image->line)[y];
|
||||||
register unsigned char *dst_address = row_pointer;
|
register ase_uint8 *dst_address = row_pointer;
|
||||||
register int x;
|
register int x;
|
||||||
|
|
||||||
for (x=0; x<width; x++)
|
for (x=0; x<width; x++)
|
||||||
|
@ -69,8 +69,8 @@ static void rle_tga_read(unsigned char *address, int w, int type, PACKFILE *f)
|
|||||||
if (type == 1)
|
if (type == 1)
|
||||||
*(address++) = value;
|
*(address++) = value;
|
||||||
else {
|
else {
|
||||||
*((unsigned short *)address) = value;
|
*((ase_uint16 *)address) = value;
|
||||||
address += sizeof(unsigned short);
|
address += sizeof(ase_uint16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,8 +83,8 @@ static void rle_tga_read(unsigned char *address, int w, int type, PACKFILE *f)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (g=0; g<count; g++) {
|
for (g=0; g<count; g++) {
|
||||||
*((unsigned short *)address) = pack_getc(f);
|
*((ase_uint16 *)address) = pack_getc(f);
|
||||||
address += sizeof(unsigned short);
|
address += sizeof(ase_uint16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ static void rle_tga_read(unsigned char *address, int w, int type, PACKFILE *f)
|
|||||||
/* rle_tga_read32:
|
/* rle_tga_read32:
|
||||||
* Helper for reading 32 bit RLE data from TGA files.
|
* Helper for reading 32 bit RLE data from TGA files.
|
||||||
*/
|
*/
|
||||||
static void rle_tga_read32 (unsigned long *address, int w, PACKFILE *f)
|
static void rle_tga_read32 (ase_uint32 *address, int w, PACKFILE *f)
|
||||||
{
|
{
|
||||||
unsigned char value[4];
|
unsigned char value[4];
|
||||||
int count;
|
int count;
|
||||||
@ -123,7 +123,7 @@ static void rle_tga_read32 (unsigned long *address, int w, PACKFILE *f)
|
|||||||
/* rle_tga_read24:
|
/* rle_tga_read24:
|
||||||
* Helper for reading 24 bit RLE data from TGA files.
|
* Helper for reading 24 bit RLE data from TGA files.
|
||||||
*/
|
*/
|
||||||
static void rle_tga_read24 (unsigned long *address, int w, PACKFILE *f)
|
static void rle_tga_read24(ase_uint32 *address, int w, PACKFILE *f)
|
||||||
{
|
{
|
||||||
unsigned char value[4];
|
unsigned char value[4];
|
||||||
int count;
|
int count;
|
||||||
@ -152,10 +152,10 @@ static void rle_tga_read24 (unsigned long *address, int w, PACKFILE *f)
|
|||||||
/* rle_tga_read16:
|
/* rle_tga_read16:
|
||||||
* Helper for reading 16 bit RLE data from TGA files.
|
* Helper for reading 16 bit RLE data from TGA files.
|
||||||
*/
|
*/
|
||||||
static void rle_tga_read16 (unsigned long *address, int w, PACKFILE *f)
|
static void rle_tga_read16(ase_uint32 *address, int w, PACKFILE *f)
|
||||||
{
|
{
|
||||||
unsigned int value;
|
unsigned int value;
|
||||||
unsigned short color;
|
ase_uint32 color;
|
||||||
int count;
|
int count;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
|
|
||||||
@ -165,21 +165,21 @@ static void rle_tga_read16 (unsigned long *address, int w, PACKFILE *f)
|
|||||||
count = (count & 0x7F) + 1;
|
count = (count & 0x7F) + 1;
|
||||||
c += count;
|
c += count;
|
||||||
value = pack_igetw(f);
|
value = pack_igetw(f);
|
||||||
color = _rgba (_rgb_scale_5[((value >> 10) & 0x1F)],
|
color = _rgba(_rgb_scale_5[((value >> 10) & 0x1F)],
|
||||||
_rgb_scale_5[((value >> 5) & 0x1F)],
|
_rgb_scale_5[((value >> 5) & 0x1F)],
|
||||||
_rgb_scale_5[(value & 0x1F)], 255);
|
_rgb_scale_5[(value & 0x1F)], 255);
|
||||||
|
|
||||||
while (count--)
|
while (count--)
|
||||||
*(address++) = color;
|
*(address++) = color;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
count++;
|
count++;
|
||||||
c += count;
|
c += count;
|
||||||
while (count--) {
|
while (count--) {
|
||||||
value = pack_igetw(f);
|
value = pack_igetw(f);
|
||||||
color = _rgba (_rgb_scale_5[((value >> 10) & 0x1F)],
|
color = _rgba(_rgb_scale_5[((value >> 10) & 0x1F)],
|
||||||
_rgb_scale_5[((value >> 5) & 0x1F)],
|
_rgb_scale_5[((value >> 5) & 0x1F)],
|
||||||
_rgb_scale_5[(value & 0x1F)], 255);
|
_rgb_scale_5[(value & 0x1F)], 255);
|
||||||
*(address++) = color;
|
*(address++) = color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ static void rle_tga_read16 (unsigned long *address, int w, PACKFILE *f)
|
|||||||
* structure and storing the palette data in the specified palette (this
|
* structure and storing the palette data in the specified palette (this
|
||||||
* should be an array of at least 256 RGB structures).
|
* should be an array of at least 256 RGB structures).
|
||||||
*/
|
*/
|
||||||
static Sprite *load_TGA (const char *filename)
|
static Sprite *load_TGA(const char *filename)
|
||||||
{
|
{
|
||||||
unsigned char image_id[256], image_palette[256][3], rgb[4];
|
unsigned char image_id[256], image_palette[256][3], rgb[4];
|
||||||
unsigned char id_length, palette_type, image_type, palette_entry_size;
|
unsigned char id_length, palette_type, image_type, palette_entry_size;
|
||||||
@ -337,7 +337,7 @@ static Sprite *load_TGA (const char *filename)
|
|||||||
pack_fread (image->line[yc], image_width, f);
|
pack_fread (image->line[yc], image_width, f);
|
||||||
else {
|
else {
|
||||||
for (x=0; x<image_width; x++)
|
for (x=0; x<image_width; x++)
|
||||||
*(((unsigned short **)image->line)[yc]+x) =
|
*(((ase_uint16 **)image->line)[yc]+x) =
|
||||||
_graya (pack_getc(f), 255);
|
_graya (pack_getc(f), 255);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -345,36 +345,36 @@ static Sprite *load_TGA (const char *filename)
|
|||||||
case 2:
|
case 2:
|
||||||
if (bpp == 32) {
|
if (bpp == 32) {
|
||||||
if (compressed) {
|
if (compressed) {
|
||||||
rle_tga_read32(image->line[yc], image_width, f);
|
rle_tga_read32((ase_uint32 *)image->line[yc], image_width, f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (x=0; x<image_width; x++) {
|
for (x=0; x<image_width; x++) {
|
||||||
pack_fread(rgb, 4, f);
|
pack_fread(rgb, 4, f);
|
||||||
*(((unsigned long **)image->line)[yc]+x) =
|
*(((ase_uint32 **)image->line)[yc]+x) =
|
||||||
_rgba(rgb[2], rgb[1], rgb[0], rgb[3]);
|
_rgba(rgb[2], rgb[1], rgb[0], rgb[3]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (bpp == 24) {
|
else if (bpp == 24) {
|
||||||
if (compressed) {
|
if (compressed) {
|
||||||
rle_tga_read24(image->line[yc], image_width, f);
|
rle_tga_read24((ase_uint32 *)image->line[yc], image_width, f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (x=0; x<image_width; x++) {
|
for (x=0; x<image_width; x++) {
|
||||||
pack_fread(rgb, 3, f);
|
pack_fread(rgb, 3, f);
|
||||||
*(((unsigned long **)image->line)[yc]+x) =
|
*(((ase_uint32 **)image->line)[yc]+x) =
|
||||||
_rgba (rgb[2], rgb[1], rgb[0], 255);
|
_rgba (rgb[2], rgb[1], rgb[0], 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (compressed) {
|
if (compressed) {
|
||||||
rle_tga_read16(image->line[yc], image_width, f);
|
rle_tga_read16((ase_uint32 *)image->line[yc], image_width, f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (x=0; x<image_width; x++) {
|
for (x=0; x<image_width; x++) {
|
||||||
c = pack_igetw(f);
|
c = pack_igetw(f);
|
||||||
*(((unsigned long **)image->line)[yc]+x) =
|
*(((ase_uint32 **)image->line)[yc]+x) =
|
||||||
_rgba (((c >> 10) & 0x1F),
|
_rgba (((c >> 10) & 0x1F),
|
||||||
((c >> 5) & 0x1F),
|
((c >> 5) & 0x1F),
|
||||||
(c & 0x1F), 255);
|
(c & 0x1F), 255);
|
||||||
|
@ -109,7 +109,7 @@ END_OF_STATIC_FUNCTION(display_switch_in_callback);
|
|||||||
*/
|
*/
|
||||||
int init_module_gui(void)
|
int init_module_gui(void)
|
||||||
{
|
{
|
||||||
int min_possible_dsk_res;
|
int min_possible_dsk_res = 0;
|
||||||
int c, w, h, bpp, autodetect;
|
int c, w, h, bpp, autodetect;
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
|
|
||||||
|
@ -1309,7 +1309,7 @@ static void fourchain_line(int x1, int y1, int x2, int y2, void *data)
|
|||||||
|
|
||||||
static void my_image_hline4_opaque(int x1, int y, int x2, void *data)
|
static void my_image_hline4_opaque(int x1, int y, int x2, void *data)
|
||||||
{
|
{
|
||||||
register unsigned long *address = ((unsigned long **)tool_image->line)[y]+x1;
|
register ase_uint32 *address = ((ase_uint32 **)tool_image->line)[y]+x1;
|
||||||
register int x = x2 - x1 + 1;
|
register int x = x2 - x1 + 1;
|
||||||
int c = tool_color;
|
int c = tool_color;
|
||||||
|
|
||||||
@ -1319,7 +1319,7 @@ static void my_image_hline4_opaque(int x1, int y, int x2, void *data)
|
|||||||
|
|
||||||
static void my_image_hline2_opaque(int x1, int y, int x2, void *data)
|
static void my_image_hline2_opaque(int x1, int y, int x2, void *data)
|
||||||
{
|
{
|
||||||
register unsigned short *address = ((unsigned short **)tool_image->line)[y]+x1;
|
register ase_uint16 *address = ((ase_uint16 **)tool_image->line)[y]+x1;
|
||||||
register int x = x2 - x1 + 1;
|
register int x = x2 - x1 + 1;
|
||||||
int c = tool_color;
|
int c = tool_color;
|
||||||
|
|
||||||
@ -1329,7 +1329,7 @@ static void my_image_hline2_opaque(int x1, int y, int x2, void *data)
|
|||||||
|
|
||||||
static void my_image_hline1_opaque(int x1, int y, int x2, void *data)
|
static void my_image_hline1_opaque(int x1, int y, int x2, void *data)
|
||||||
{
|
{
|
||||||
memset (((unsigned char **)tool_image->line)[y]+x1, tool_color, x2-x1+1);
|
memset(((ase_uint8 **)tool_image->line)[y]+x1, tool_color, x2-x1+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
@ -1338,7 +1338,7 @@ static void my_image_hline1_opaque(int x1, int y, int x2, void *data)
|
|||||||
|
|
||||||
static void my_image_hline4_glass(int x1, int y, int x2, void *data)
|
static void my_image_hline4_glass(int x1, int y, int x2, void *data)
|
||||||
{
|
{
|
||||||
register unsigned long *address = ((unsigned long **)tool_image->line)[y]+x1;
|
register ase_uint32 *address = ((ase_uint32 **)tool_image->line)[y]+x1;
|
||||||
register int x = x2 - x1 + 1;
|
register int x = x2 - x1 + 1;
|
||||||
int c = _rgba (_rgba_getr (tool_color),
|
int c = _rgba (_rgba_getr (tool_color),
|
||||||
_rgba_getg (tool_color),
|
_rgba_getg (tool_color),
|
||||||
@ -1353,7 +1353,7 @@ static void my_image_hline4_glass(int x1, int y, int x2, void *data)
|
|||||||
|
|
||||||
static void my_image_hline2_glass(int x1, int y, int x2, void *data)
|
static void my_image_hline2_glass(int x1, int y, int x2, void *data)
|
||||||
{
|
{
|
||||||
register unsigned short *address = ((unsigned short **)tool_image->line)[y]+x1;
|
register ase_uint16 *address = ((ase_uint16 **)tool_image->line)[y]+x1;
|
||||||
register int x = x2 - x1 + 1;
|
register int x = x2 - x1 + 1;
|
||||||
int c = _graya (_graya_getk (tool_color), glass_dirty);
|
int c = _graya (_graya_getk (tool_color), glass_dirty);
|
||||||
int o = _graya_geta (tool_color);
|
int o = _graya_geta (tool_color);
|
||||||
@ -1366,17 +1366,17 @@ static void my_image_hline2_glass(int x1, int y, int x2, void *data)
|
|||||||
|
|
||||||
static void my_image_hline1_glass(int x1, int y, int x2, void *data)
|
static void my_image_hline1_glass(int x1, int y, int x2, void *data)
|
||||||
{
|
{
|
||||||
register unsigned char *address = ((unsigned char **)tool_image->line)[y]+x1;
|
register ase_uint8 *address = ((ase_uint8 **)tool_image->line)[y]+x1;
|
||||||
register int x = x2 - x1 + 1;
|
register int x = x2 - x1 + 1;
|
||||||
int c, tc = _rgba (_rgb_scale_6[_current_palette[_index_cmap[tool_color]].r],
|
int c, tc = _rgba(_rgb_scale_6[_current_palette[_index_cmap[tool_color]].r],
|
||||||
_rgb_scale_6[_current_palette[_index_cmap[tool_color]].g],
|
_rgb_scale_6[_current_palette[_index_cmap[tool_color]].g],
|
||||||
_rgb_scale_6[_current_palette[_index_cmap[tool_color]].b], 255);
|
_rgb_scale_6[_current_palette[_index_cmap[tool_color]].b], 255);
|
||||||
|
|
||||||
while (x--) {
|
while (x--) {
|
||||||
c = _rgba_blend_normal (_rgba (_rgb_scale_6[_current_palette[*address].r],
|
c = _rgba_blend_normal(_rgba(_rgb_scale_6[_current_palette[*address].r],
|
||||||
_rgb_scale_6[_current_palette[*address].g],
|
_rgb_scale_6[_current_palette[*address].g],
|
||||||
_rgb_scale_6[_current_palette[*address].b], 255),
|
_rgb_scale_6[_current_palette[*address].b], 255),
|
||||||
tc, glass_dirty);
|
tc, glass_dirty);
|
||||||
|
|
||||||
/* *(address++) = rgb_map->data[_rgba_getr (c)>>3] */
|
/* *(address++) = rgb_map->data[_rgba_getr (c)>>3] */
|
||||||
/* [_rgba_getg (c)>>3] */
|
/* [_rgba_getg (c)>>3] */
|
||||||
@ -1393,9 +1393,9 @@ static void my_image_hline1_glass(int x1, int y, int x2, void *data)
|
|||||||
/* Semi draw mode */
|
/* Semi draw mode */
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
||||||
static void my_image_hline4_semi (int x1, int y, int x2, void *data)
|
static void my_image_hline4_semi(int x1, int y, int x2, void *data)
|
||||||
{
|
{
|
||||||
register unsigned long *address = ((unsigned long **)tool_image->line)[y]+x1;
|
register ase_uint32 *address = ((ase_uint32 **)tool_image->line)[y]+x1;
|
||||||
register int x;
|
register int x;
|
||||||
|
|
||||||
for (x=x1; x<=x2; x++) {
|
for (x=x1; x<=x2; x++) {
|
||||||
@ -1405,9 +1405,9 @@ static void my_image_hline4_semi (int x1, int y, int x2, void *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void my_image_hline2_semi (int x1, int y, int x2, void *data)
|
static void my_image_hline2_semi(int x1, int y, int x2, void *data)
|
||||||
{
|
{
|
||||||
register unsigned short *address = ((unsigned short **)tool_image->line)[y]+x1;
|
register ase_uint16 *address = ((ase_uint16 **)tool_image->line)[y]+x1;
|
||||||
register int x;
|
register int x;
|
||||||
|
|
||||||
for (x=x1; x<=x2; x++) {
|
for (x=x1; x<=x2; x++) {
|
||||||
@ -1417,9 +1417,9 @@ static void my_image_hline2_semi (int x1, int y, int x2, void *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void my_image_hline1_semi (int x1, int y, int x2, void *data)
|
static void my_image_hline1_semi(int x1, int y, int x2, void *data)
|
||||||
{
|
{
|
||||||
register unsigned char *address = ((unsigned char **)tool_image->line)[y]+x1;
|
register ase_uint8 *address = ((ase_uint8 **)tool_image->line)[y]+x1;
|
||||||
register int x;
|
register int x;
|
||||||
|
|
||||||
for (x=x1; x<=x2; x++) {
|
for (x=x1; x<=x2; x++) {
|
||||||
|
@ -70,7 +70,7 @@ static int flooder (Image *image, int x, int y,
|
|||||||
|
|
||||||
case IMAGE_RGB:
|
case IMAGE_RGB:
|
||||||
{
|
{
|
||||||
unsigned long *address = ((unsigned long **)image->line)[y];
|
ase_uint32 *address = ((ase_uint32 **)image->line)[y];
|
||||||
|
|
||||||
/* check start pixel */
|
/* check start pixel */
|
||||||
if ((int)*(address+x) != src_color)
|
if ((int)*(address+x) != src_color)
|
||||||
@ -92,7 +92,7 @@ static int flooder (Image *image, int x, int y,
|
|||||||
|
|
||||||
case IMAGE_GRAYSCALE:
|
case IMAGE_GRAYSCALE:
|
||||||
{
|
{
|
||||||
unsigned short *address = ((unsigned short **)image->line)[y];
|
ase_uint16 *address = ((ase_uint16 **)image->line)[y];
|
||||||
|
|
||||||
/* check start pixel */
|
/* check start pixel */
|
||||||
if ((int)*(address+x) != src_color)
|
if ((int)*(address+x) != src_color)
|
||||||
@ -114,7 +114,7 @@ static int flooder (Image *image, int x, int y,
|
|||||||
|
|
||||||
case IMAGE_INDEXED:
|
case IMAGE_INDEXED:
|
||||||
{
|
{
|
||||||
unsigned char *address = ((unsigned char **)image->line)[y];
|
ase_uint8 *address = ((ase_uint8 **)image->line)[y];
|
||||||
|
|
||||||
/* check start pixel */
|
/* check start pixel */
|
||||||
if ((int)*(address+x) != src_color)
|
if ((int)*(address+x) != src_color)
|
||||||
@ -139,7 +139,7 @@ static int flooder (Image *image, int x, int y,
|
|||||||
right--;
|
right--;
|
||||||
|
|
||||||
/* draw the line */
|
/* draw the line */
|
||||||
(*proc) (left, y, right, data);
|
(*proc)(left, y, right, data);
|
||||||
|
|
||||||
/* store it in the list of flooded segments */
|
/* store it in the list of flooded segments */
|
||||||
c = y;
|
c = y;
|
||||||
@ -178,8 +178,8 @@ static int flooder (Image *image, int x, int y,
|
|||||||
* segments which have already been drawn in order to minimise the required
|
* segments which have already been drawn in order to minimise the required
|
||||||
* number of tests.
|
* number of tests.
|
||||||
*/
|
*/
|
||||||
static int check_flood_line (Image *image, int y, int left, int right,
|
static int check_flood_line(Image *image, int y, int left, int right,
|
||||||
int src_color, void *data, AlgoHLine proc)
|
int src_color, void *data, AlgoHLine proc)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
FLOODED_LINE *p;
|
FLOODED_LINE *p;
|
||||||
@ -214,7 +214,7 @@ static int check_flood_line (Image *image, int y, int left, int right,
|
|||||||
/* floodfill:
|
/* floodfill:
|
||||||
* Fills an enclosed area (starting at point x, y) with the specified color.
|
* Fills an enclosed area (starting at point x, y) with the specified color.
|
||||||
*/
|
*/
|
||||||
void algo_floodfill (Image *image, int x, int y, void *data, AlgoHLine proc)
|
void algo_floodfill(Image *image, int x, int y, void *data, AlgoHLine proc)
|
||||||
{
|
{
|
||||||
int src_color;
|
int src_color;
|
||||||
int c, done;
|
int c, done;
|
||||||
@ -241,7 +241,7 @@ void algo_floodfill (Image *image, int x, int y, void *data, AlgoHLine proc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* start up the flood algorithm */
|
/* start up the flood algorithm */
|
||||||
flooder (image, x, y, src_color, data, proc);
|
flooder(image, x, y, src_color, data, proc);
|
||||||
|
|
||||||
/* continue as long as there are some segments still to test */
|
/* continue as long as there are some segments still to test */
|
||||||
do {
|
do {
|
||||||
@ -255,8 +255,8 @@ void algo_floodfill (Image *image, int x, int y, void *data, AlgoHLine proc)
|
|||||||
/* check below the segment? */
|
/* check below the segment? */
|
||||||
if (p->flags & FLOOD_TODO_BELOW) {
|
if (p->flags & FLOOD_TODO_BELOW) {
|
||||||
p->flags &= ~FLOOD_TODO_BELOW;
|
p->flags &= ~FLOOD_TODO_BELOW;
|
||||||
if (check_flood_line (image, p->y+1, p->lpos, p->rpos,
|
if (check_flood_line(image, p->y+1, p->lpos, p->rpos,
|
||||||
src_color, data, proc)) {
|
src_color, data, proc)) {
|
||||||
done = FALSE;
|
done = FALSE;
|
||||||
p = FLOOD_LINE(c);
|
p = FLOOD_LINE(c);
|
||||||
}
|
}
|
||||||
@ -265,8 +265,8 @@ void algo_floodfill (Image *image, int x, int y, void *data, AlgoHLine proc)
|
|||||||
/* check above the segment? */
|
/* check above the segment? */
|
||||||
if (p->flags & FLOOD_TODO_ABOVE) {
|
if (p->flags & FLOOD_TODO_ABOVE) {
|
||||||
p->flags &= ~FLOOD_TODO_ABOVE;
|
p->flags &= ~FLOOD_TODO_ABOVE;
|
||||||
if (check_flood_line (image, p->y-1, p->lpos, p->rpos,
|
if (check_flood_line(image, p->y-1, p->lpos, p->rpos,
|
||||||
src_color, data, proc)) {
|
src_color, data, proc)) {
|
||||||
done = FALSE;
|
done = FALSE;
|
||||||
/* special case shortcut for going backwards */
|
/* special case shortcut for going backwards */
|
||||||
if ((c < image->h) && (c > 0))
|
if ((c < image->h) && (c > 0))
|
||||||
|
@ -32,11 +32,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_X86_INT_MULT
|
#ifdef USE_X86_INT_MULT
|
||||||
# undef INT_MULT(a, b, t)
|
# undef INT_MULT
|
||||||
# define INT_MULT(a, b, t) (_int_mult (a, b))
|
# define INT_MULT(a, b, t) (_int_mult (a, b))
|
||||||
# define T_VAR
|
# define T_VAR
|
||||||
# define NT_VAR register int t;
|
# define NT_VAR register int t;
|
||||||
extern int _int_mult (int a, int b);
|
extern int _int_mult(int a, int b);
|
||||||
#else
|
#else
|
||||||
# define T_VAR register int t;
|
# define T_VAR register int t;
|
||||||
# define NT_VAR
|
# define NT_VAR
|
||||||
|
@ -32,45 +32,45 @@
|
|||||||
|
|
||||||
#define ADD_COLUMN() \
|
#define ADD_COLUMN() \
|
||||||
row->cols++; \
|
row->cols++; \
|
||||||
row->col = jrealloc (row->col, sizeof (struct DirtyCol) * row->cols); \
|
row->col = jrealloc(row->col, sizeof(struct DirtyCol) * row->cols); \
|
||||||
\
|
\
|
||||||
if (u < row->cols-1) \
|
if (u < row->cols-1) \
|
||||||
memmove (row->col+u+1, row->col+u, \
|
memmove(row->col+u+1, row->col+u, \
|
||||||
sizeof (struct DirtyCol) * (row->cols-1-u));
|
sizeof(struct DirtyCol) * (row->cols-1-u));
|
||||||
|
|
||||||
#define ADD_ROW() \
|
#define ADD_ROW() \
|
||||||
dirty->rows++; \
|
dirty->rows++; \
|
||||||
dirty->row = jrealloc (dirty->row, \
|
dirty->row = jrealloc(dirty->row, \
|
||||||
sizeof (struct DirtyRow) * dirty->rows); \
|
sizeof(struct DirtyRow) * dirty->rows); \
|
||||||
\
|
\
|
||||||
if (v < dirty->rows-1) \
|
if (v < dirty->rows-1) \
|
||||||
memmove (dirty->row+v+1, dirty->row+v, \
|
memmove(dirty->row+v+1, dirty->row+v, \
|
||||||
sizeof (struct DirtyRow) * (dirty->rows-1-v));
|
sizeof(struct DirtyRow) * (dirty->rows-1-v));
|
||||||
|
|
||||||
#define RESTORE_IMAGE(u) \
|
#define RESTORE_IMAGE(u) \
|
||||||
if (row->col[u].flags & DIRTY_VALID_COLUMN) { \
|
if (row->col[u].flags & DIRTY_VALID_COLUMN) { \
|
||||||
row->col[u].flags ^= DIRTY_VALID_COLUMN; \
|
row->col[u].flags ^= DIRTY_VALID_COLUMN; \
|
||||||
\
|
\
|
||||||
memcpy (row->col[u].ptr, \
|
memcpy(row->col[u].ptr, \
|
||||||
row->col[u].data, \
|
row->col[u].data, \
|
||||||
DIRTY_LINE_SIZE (row->col[u].w)); \
|
DIRTY_LINE_SIZE(row->col[u].w)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define JOIN_WITH_NEXT() \
|
#define JOIN_WITH_NEXT() \
|
||||||
{ \
|
{ \
|
||||||
RESTORE_IMAGE (u+1); \
|
RESTORE_IMAGE(u+1); \
|
||||||
\
|
\
|
||||||
row->col[u].w += row->col[u+1].w; \
|
row->col[u].w += row->col[u+1].w; \
|
||||||
\
|
\
|
||||||
if (row->col[u+1].data) \
|
if (row->col[u+1].data) \
|
||||||
jfree (row->col[u+1].data); \
|
jfree(row->col[u+1].data); \
|
||||||
\
|
\
|
||||||
if (u+1 < row->cols-1) \
|
if (u+1 < row->cols-1) \
|
||||||
memmove (row->col+u+1, row->col+u+2, \
|
memmove(row->col+u+1, row->col+u+2, \
|
||||||
sizeof (struct DirtyCol) * (row->cols-2-u)); \
|
sizeof(struct DirtyCol) * (row->cols-2-u)); \
|
||||||
\
|
\
|
||||||
row->cols--; \
|
row->cols--; \
|
||||||
row->col = jrealloc (row->col, sizeof (struct DirtyCol) * row->cols); \
|
row->col = jrealloc(row->col, sizeof(struct DirtyCol) * row->cols); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EAT_COLUMNS() \
|
#define EAT_COLUMNS() \
|
||||||
@ -88,25 +88,25 @@
|
|||||||
/* "eat" columns */ \
|
/* "eat" columns */ \
|
||||||
if (u2 > u) { \
|
if (u2 > u) { \
|
||||||
for (u3=u+1; u3<=u2; u3++) { \
|
for (u3=u+1; u3<=u2; u3++) { \
|
||||||
RESTORE_IMAGE (u3); \
|
RESTORE_IMAGE(u3); \
|
||||||
if (row->col[u3].data) \
|
if (row->col[u3].data) \
|
||||||
jfree (row->col[u3].data); \
|
jfree(row->col[u3].data); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
to_x2 = MAX (to_x2, row->col[u2].x+row->col[u2].w-1); \
|
to_x2 = MAX(to_x2, row->col[u2].x+row->col[u2].w-1); \
|
||||||
\
|
\
|
||||||
if (u2 < row->cols-1) \
|
if (u2 < row->cols-1) \
|
||||||
memmove (row->col+u+1, row->col+u2+1, \
|
memmove(row->col+u+1, row->col+u2+1, \
|
||||||
sizeof (struct DirtyCol) * (row->cols-u2-1)); \
|
sizeof(struct DirtyCol) * (row->cols-u2-1)); \
|
||||||
\
|
\
|
||||||
row->cols -= u2 - u; \
|
row->cols -= u2 - u; \
|
||||||
row->col = jrealloc (row->col, \
|
row->col = jrealloc(row->col, \
|
||||||
sizeof (struct DirtyCol) * row->cols); \
|
sizeof(struct DirtyCol) * row->cols); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
row->col[u].w = to_x2 - row->col[u].x + 1; \
|
row->col[u].w = to_x2 - row->col[u].x + 1; \
|
||||||
row->col[u].data = jrealloc (row->col[u].data, \
|
row->col[u].data = jrealloc(row->col[u].data, \
|
||||||
DIRTY_LINE_SIZE (row->col[u].w));
|
DIRTY_LINE_SIZE(row->col[u].w));
|
||||||
|
|
||||||
typedef struct AlgoData
|
typedef struct AlgoData
|
||||||
{
|
{
|
||||||
@ -115,28 +115,28 @@ typedef struct AlgoData
|
|||||||
int thickness;
|
int thickness;
|
||||||
} AlgoData;
|
} AlgoData;
|
||||||
|
|
||||||
static void algo_putpixel (int x, int y, AlgoData *data);
|
static void algo_putpixel(int x, int y, AlgoData *data);
|
||||||
/* static void algo_putthick (int x, int y, AlgoData *data); */
|
/* static void algo_putthick(int x, int y, AlgoData *data); */
|
||||||
static void algo_putbrush (int x, int y, AlgoData *data);
|
static void algo_putbrush(int x, int y, AlgoData *data);
|
||||||
|
|
||||||
static void *swap_hline (Image *image);
|
static void *swap_hline(Image *image);
|
||||||
static void swap_hline1 (void *image, void *data, int x1, int x2);
|
static void swap_hline1(void *image, void *data, int x1, int x2);
|
||||||
static void swap_hline2 (void *image, void *data, int x1, int x2);
|
static void swap_hline2(void *image, void *data, int x1, int x2);
|
||||||
static void swap_hline4 (void *image, void *data, int x1, int x2);
|
static void swap_hline4(void *image, void *data, int x1, int x2);
|
||||||
|
|
||||||
Dirty *dirty_new (Image *image, int x1, int y1, int x2, int y2, int tiled)
|
Dirty *dirty_new(Image *image, int x1, int y1, int x2, int y2, int tiled)
|
||||||
{
|
{
|
||||||
Dirty *dirty;
|
Dirty *dirty;
|
||||||
|
|
||||||
dirty = (Dirty *)jnew (Dirty, 1);
|
dirty = (Dirty *)jnew(Dirty, 1);
|
||||||
if (!dirty)
|
if (!dirty)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
dirty->image = image;
|
dirty->image = image;
|
||||||
dirty->x1 = MID (0, x1, image->w-1);
|
dirty->x1 = MID(0, x1, image->w-1);
|
||||||
dirty->y1 = MID (0, y1, image->h-1);
|
dirty->y1 = MID(0, y1, image->h-1);
|
||||||
dirty->x2 = MID (x1, x2, image->w-1);
|
dirty->x2 = MID(x1, x2, image->w-1);
|
||||||
dirty->y2 = MID (y1, y2, image->h-1);
|
dirty->y2 = MID(y1, y2, image->h-1);
|
||||||
dirty->tiled = tiled;
|
dirty->tiled = tiled;
|
||||||
dirty->rows = 0;
|
dirty->rows = 0;
|
||||||
dirty->row = NULL;
|
dirty->row = NULL;
|
||||||
@ -145,22 +145,22 @@ Dirty *dirty_new (Image *image, int x1, int y1, int x2, int y2, int tiled)
|
|||||||
return dirty;
|
return dirty;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dirty *dirty_new_copy (Dirty *src)
|
Dirty *dirty_new_copy(Dirty *src)
|
||||||
{
|
{
|
||||||
int u, v, size;
|
int u, v, size;
|
||||||
Dirty *dst;
|
Dirty *dst;
|
||||||
|
|
||||||
dst = dirty_new (src->image, src->x1, src->y1, src->x2, src->y2, src->tiled);
|
dst = dirty_new(src->image, src->x1, src->y1, src->x2, src->y2, src->tiled);
|
||||||
if (!dst)
|
if (!dst)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
dst->rows = src->rows;
|
dst->rows = src->rows;
|
||||||
dst->row = jmalloc (sizeof (struct DirtyRow) * src->rows);
|
dst->row = jmalloc(sizeof (struct DirtyRow) * src->rows);
|
||||||
|
|
||||||
for (v=0; v<dst->rows; v++) {
|
for (v=0; v<dst->rows; v++) {
|
||||||
dst->row[v].y = src->row[v].y;
|
dst->row[v].y = src->row[v].y;
|
||||||
dst->row[v].cols = src->row[v].cols;
|
dst->row[v].cols = src->row[v].cols;
|
||||||
dst->row[v].col = jmalloc (sizeof (struct DirtyCol) * dst->row[v].cols);
|
dst->row[v].col = jmalloc(sizeof(struct DirtyCol) * dst->row[v].cols);
|
||||||
|
|
||||||
for (u=0; u<dst->row[v].cols; u++) {
|
for (u=0; u<dst->row[v].cols; u++) {
|
||||||
dst->row[v].col[u].x = src->row[v].col[u].x;
|
dst->row[v].col[u].x = src->row[v].col[u].x;
|
||||||
@ -168,36 +168,36 @@ Dirty *dirty_new_copy (Dirty *src)
|
|||||||
dst->row[v].col[u].flags = src->row[v].col[u].flags;
|
dst->row[v].col[u].flags = src->row[v].col[u].flags;
|
||||||
dst->row[v].col[u].ptr = src->row[v].col[u].ptr;
|
dst->row[v].col[u].ptr = src->row[v].col[u].ptr;
|
||||||
|
|
||||||
size = dst->row[v].col[u].w << IMAGE_SHIFT (dst->image);
|
size = dst->row[v].col[u].w << IMAGE_SHIFT(dst->image);
|
||||||
|
|
||||||
dst->row[v].col[u].data = jmalloc (size);
|
dst->row[v].col[u].data = jmalloc (size);
|
||||||
|
|
||||||
memcpy (dst->row[v].col[u].data, src->row[v].col[u].data, size);
|
memcpy(dst->row[v].col[u].data, src->row[v].col[u].data, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dirty_free (Dirty *dirty)
|
void dirty_free(Dirty *dirty)
|
||||||
{
|
{
|
||||||
int u, v;
|
int u, v;
|
||||||
|
|
||||||
if (dirty->row) {
|
if (dirty->row) {
|
||||||
for (v=0; v<dirty->rows; v++) {
|
for (v=0; v<dirty->rows; v++) {
|
||||||
for (u=0; u<dirty->row[v].cols; u++)
|
for (u=0; u<dirty->row[v].cols; u++)
|
||||||
jfree (dirty->row[v].col[u].data);
|
jfree(dirty->row[v].col[u].data);
|
||||||
|
|
||||||
jfree (dirty->row[v].col);
|
jfree(dirty->row[v].col);
|
||||||
}
|
}
|
||||||
|
|
||||||
jfree (dirty->row);
|
jfree(dirty->row);
|
||||||
}
|
}
|
||||||
|
|
||||||
jfree (dirty);
|
jfree(dirty);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dirty_putpixel (Dirty *dirty, int x, int y)
|
void dirty_putpixel(Dirty *dirty, int x, int y)
|
||||||
{
|
{
|
||||||
struct DirtyRow *row;
|
struct DirtyRow *row;
|
||||||
int u, v;
|
int u, v;
|
||||||
@ -226,9 +226,9 @@ void dirty_putpixel (Dirty *dirty, int x, int y)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if ((dirty->mask->bitmap) &&
|
if ((dirty->mask->bitmap) &&
|
||||||
!(dirty->mask->bitmap->method->getpixel (dirty->mask->bitmap,
|
!(dirty->mask->bitmap->method->getpixel(dirty->mask->bitmap,
|
||||||
x-dirty->mask->x,
|
x-dirty->mask->x,
|
||||||
y-dirty->mask->y)))
|
y-dirty->mask->y)))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ void dirty_putpixel (Dirty *dirty, int x, int y)
|
|||||||
|
|
||||||
/* we must add a new row? */
|
/* we must add a new row? */
|
||||||
if (!row) {
|
if (!row) {
|
||||||
ADD_ROW ();
|
ADD_ROW();
|
||||||
|
|
||||||
dirty->row[v].y = y;
|
dirty->row[v].y = y;
|
||||||
dirty->row[v].cols = 0;
|
dirty->row[v].cols = 0;
|
||||||
@ -261,16 +261,16 @@ void dirty_putpixel (Dirty *dirty, int x, int y)
|
|||||||
return;
|
return;
|
||||||
/* the pixel is to right of the column */
|
/* the pixel is to right of the column */
|
||||||
else if (x == row->col[u].x+row->col[u].w) {
|
else if (x == row->col[u].x+row->col[u].w) {
|
||||||
RESTORE_IMAGE (u);
|
RESTORE_IMAGE(u);
|
||||||
|
|
||||||
row->col[u].w++;
|
row->col[u].w++;
|
||||||
|
|
||||||
/* there is a left column? */
|
/* there is a left column? */
|
||||||
if (u < row->cols-1 && x+1 == row->col[u+1].x)
|
if (u < row->cols-1 && x+1 == row->col[u+1].x)
|
||||||
JOIN_WITH_NEXT ();
|
JOIN_WITH_NEXT();
|
||||||
|
|
||||||
row->col[u].data = jrealloc (row->col[u].data,
|
row->col[u].data = jrealloc(row->col[u].data,
|
||||||
DIRTY_LINE_SIZE (row->col[u].w));
|
DIRTY_LINE_SIZE(row->col[u].w));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* the pixel is to left of the column */
|
/* the pixel is to left of the column */
|
||||||
@ -300,11 +300,10 @@ void dirty_putpixel (Dirty *dirty, int x, int y)
|
|||||||
row->col[u].ptr = IMAGE_ADDRESS (dirty->image, x, y);
|
row->col[u].ptr = IMAGE_ADDRESS (dirty->image, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dirty_hline (Dirty *dirty, int x1, int y, int x2)
|
void dirty_hline(Dirty *dirty, int x1, int y, int x2)
|
||||||
{
|
{
|
||||||
struct DirtyRow *row;
|
struct DirtyRow *row;
|
||||||
int x, u, v, w/* , len */;
|
int x, u, v, w;
|
||||||
/* int u1, u2; */
|
|
||||||
int u2, u3, to_x2;
|
int u2, u3, to_x2;
|
||||||
|
|
||||||
if (dirty->tiled) {
|
if (dirty->tiled) {
|
||||||
@ -320,7 +319,7 @@ void dirty_hline (Dirty *dirty, int x1, int y, int x2)
|
|||||||
|
|
||||||
w = x2-x1+1;
|
w = x2-x1+1;
|
||||||
if (w >= dirty->image->w)
|
if (w >= dirty->image->w)
|
||||||
dirty_hline (dirty, 0, y, dirty->image->w-1);
|
dirty_hline(dirty, 0, y, dirty->image->w-1);
|
||||||
else {
|
else {
|
||||||
x = x1;
|
x = x1;
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
@ -329,10 +328,10 @@ void dirty_hline (Dirty *dirty, int x1, int y, int x2)
|
|||||||
x = x % dirty->image->w;
|
x = x % dirty->image->w;
|
||||||
|
|
||||||
if (x+w-1 <= dirty->image->w-1)
|
if (x+w-1 <= dirty->image->w-1)
|
||||||
dirty_hline (dirty, x, y, x+w-1);
|
dirty_hline(dirty, x, y, x+w-1);
|
||||||
else {
|
else {
|
||||||
dirty_hline (dirty, x, y, dirty->image->w-1);
|
dirty_hline(dirty, x, y, dirty->image->w-1);
|
||||||
dirty_hline (dirty, 0, y, w-(dirty->image->w-x)-1);
|
dirty_hline(dirty, 0, y, w-(dirty->image->w-x)-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,15 +365,15 @@ void dirty_hline (Dirty *dirty, int x1, int y, int x2)
|
|||||||
|
|
||||||
if (dirty->mask->bitmap) {
|
if (dirty->mask->bitmap) {
|
||||||
for (; x1<=x2; x1++)
|
for (; x1<=x2; x1++)
|
||||||
if (dirty->mask->bitmap->method->getpixel (dirty->mask->bitmap,
|
if (dirty->mask->bitmap->method->getpixel(dirty->mask->bitmap,
|
||||||
x1-dirty->mask->x,
|
x1-dirty->mask->x,
|
||||||
y-dirty->mask->y))
|
y-dirty->mask->y))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
for (; x2>=x1; x2--)
|
for (; x2>=x1; x2--)
|
||||||
if (dirty->mask->bitmap->method->getpixel (dirty->mask->bitmap,
|
if (dirty->mask->bitmap->method->getpixel(dirty->mask->bitmap,
|
||||||
x2-dirty->mask->x,
|
x2-dirty->mask->x,
|
||||||
y-dirty->mask->y))
|
y-dirty->mask->y))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,7 +394,7 @@ void dirty_hline (Dirty *dirty, int x1, int y, int x2)
|
|||||||
|
|
||||||
/* we must add a new row? */
|
/* we must add a new row? */
|
||||||
if (!row) {
|
if (!row) {
|
||||||
ADD_ROW ();
|
ADD_ROW();
|
||||||
|
|
||||||
dirty->row[v].y = y;
|
dirty->row[v].y = y;
|
||||||
dirty->row[v].cols = 0;
|
dirty->row[v].cols = 0;
|
||||||
@ -409,9 +408,9 @@ void dirty_hline (Dirty *dirty, int x1, int y, int x2)
|
|||||||
|
|
||||||
if (dirty->mask && dirty->mask->bitmap) {
|
if (dirty->mask && dirty->mask->bitmap) {
|
||||||
for (x=x1; x<=x2; x++) {
|
for (x=x1; x<=x2; x++) {
|
||||||
if (!dirty->mask->bitmap->method->getpixel (dirty->mask->bitmap,
|
if (!dirty->mask->bitmap->method->getpixel(dirty->mask->bitmap,
|
||||||
x-dirty->mask->x,
|
x-dirty->mask->x,
|
||||||
y-dirty->mask->y)) {
|
y-dirty->mask->y)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,7 +421,7 @@ void dirty_hline (Dirty *dirty, int x1, int y, int x2)
|
|||||||
goto done;
|
goto done;
|
||||||
/* the pixel is in the right of the column */
|
/* the pixel is in the right of the column */
|
||||||
else if (x == row->col[u].x+row->col[u].w) {
|
else if (x == row->col[u].x+row->col[u].w) {
|
||||||
RESTORE_IMAGE (u);
|
RESTORE_IMAGE(u);
|
||||||
|
|
||||||
row->col[u].w++;
|
row->col[u].w++;
|
||||||
|
|
||||||
@ -431,27 +430,27 @@ void dirty_hline (Dirty *dirty, int x1, int y, int x2)
|
|||||||
if (row->col[u+1].flags & DIRTY_VALID_COLUMN) {
|
if (row->col[u+1].flags & DIRTY_VALID_COLUMN) {
|
||||||
row->col[u+1].flags ^= DIRTY_VALID_COLUMN;
|
row->col[u+1].flags ^= DIRTY_VALID_COLUMN;
|
||||||
|
|
||||||
memcpy (row->col[u+1].ptr,
|
memcpy(row->col[u+1].ptr,
|
||||||
row->col[u+1].data,
|
row->col[u+1].data,
|
||||||
DIRTY_LINE_SIZE (row->col[u+1].w));
|
DIRTY_LINE_SIZE(row->col[u+1].w));
|
||||||
}
|
}
|
||||||
|
|
||||||
row->col[u].w += row->col[u+1].w;
|
row->col[u].w += row->col[u+1].w;
|
||||||
|
|
||||||
/* remove the col[u+1] */
|
/* remove the col[u+1] */
|
||||||
if (row->col[u+1].data)
|
if (row->col[u+1].data)
|
||||||
jfree (row->col[u+1].data);
|
jfree(row->col[u+1].data);
|
||||||
|
|
||||||
if (u+1 < row->cols-1)
|
if (u+1 < row->cols-1)
|
||||||
memmove (row->col+u+1, row->col+u+2,
|
memmove(row->col+u+1, row->col+u+2,
|
||||||
sizeof (struct DirtyCol) * (row->cols-2-u));
|
sizeof(struct DirtyCol) * (row->cols-2-u));
|
||||||
|
|
||||||
row->cols--;
|
row->cols--;
|
||||||
row->col = jrealloc (row->col, sizeof (struct DirtyCol) * row->cols);
|
row->col = jrealloc(row->col, sizeof(struct DirtyCol) * row->cols);
|
||||||
}
|
}
|
||||||
|
|
||||||
row->col[u].data = jrealloc (row->col[u].data,
|
row->col[u].data = jrealloc(row->col[u].data,
|
||||||
DIRTY_LINE_SIZE (row->col[u].w));
|
DIRTY_LINE_SIZE(row->col[u].w));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
/* the pixel is in the left of the column */
|
/* the pixel is in the left of the column */
|
||||||
@ -459,17 +458,17 @@ void dirty_hline (Dirty *dirty, int x1, int y, int x2)
|
|||||||
if (row->col[u].flags & DIRTY_VALID_COLUMN) {
|
if (row->col[u].flags & DIRTY_VALID_COLUMN) {
|
||||||
row->col[u].flags ^= DIRTY_VALID_COLUMN;
|
row->col[u].flags ^= DIRTY_VALID_COLUMN;
|
||||||
|
|
||||||
memcpy (row->col[u].ptr,
|
memcpy(row->col[u].ptr,
|
||||||
row->col[u].data,
|
row->col[u].data,
|
||||||
DIRTY_LINE_SIZE (row->col[u].w));
|
DIRTY_LINE_SIZE(row->col[u].w));
|
||||||
}
|
}
|
||||||
|
|
||||||
row->col[u].x--;
|
row->col[u].x--;
|
||||||
row->col[u].w++;
|
row->col[u].w++;
|
||||||
row->col[u].data = jrealloc (row->col[u].data,
|
row->col[u].data = jrealloc(row->col[u].data,
|
||||||
DIRTY_LINE_SIZE (row->col[u].w));
|
DIRTY_LINE_SIZE(row->col[u].w));
|
||||||
|
|
||||||
row->col[u].ptr = IMAGE_ADDRESS (dirty->image, x, y);
|
row->col[u].ptr = IMAGE_ADDRESS(dirty->image, x, y);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
else if (x < row->col[u].x)
|
else if (x < row->col[u].x)
|
||||||
@ -478,17 +477,17 @@ void dirty_hline (Dirty *dirty, int x1, int y, int x2)
|
|||||||
|
|
||||||
/* add a new column */
|
/* add a new column */
|
||||||
row->cols++;
|
row->cols++;
|
||||||
row->col = jrealloc (row->col, sizeof (struct DirtyCol) * row->cols);
|
row->col = jrealloc(row->col, sizeof(struct DirtyCol) * row->cols);
|
||||||
|
|
||||||
if (u < row->cols-1)
|
if (u < row->cols-1)
|
||||||
memmove (row->col+u+1, row->col+u,
|
memmove(row->col+u+1, row->col+u,
|
||||||
sizeof (struct DirtyCol) * (row->cols-1-u));
|
sizeof (struct DirtyCol) * (row->cols-1-u));
|
||||||
|
|
||||||
row->col[u].x = x;
|
row->col[u].x = x;
|
||||||
row->col[u].w = 1;
|
row->col[u].w = 1;
|
||||||
row->col[u].flags = 0;
|
row->col[u].flags = 0;
|
||||||
row->col[u].data = jmalloc (DIRTY_LINE_SIZE (1));
|
row->col[u].data = jmalloc(DIRTY_LINE_SIZE(1));
|
||||||
row->col[u].ptr = IMAGE_ADDRESS (dirty->image, x, y);
|
row->col[u].ptr = IMAGE_ADDRESS(dirty->image, x, y);
|
||||||
|
|
||||||
done:;
|
done:;
|
||||||
}
|
}
|
||||||
@ -507,14 +506,14 @@ void dirty_hline (Dirty *dirty, int x1, int y, int x2)
|
|||||||
return;
|
return;
|
||||||
/* extend this column to "x2" */
|
/* extend this column to "x2" */
|
||||||
else {
|
else {
|
||||||
RESTORE_IMAGE (u);
|
RESTORE_IMAGE(u);
|
||||||
EAT_COLUMNS ();
|
EAT_COLUMNS();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* the hline is to left of the column */
|
/* the hline is to left of the column */
|
||||||
else if ((x1 < row->col[u].x) && (x2 >= row->col[u].x-1)) {
|
else if ((x1 < row->col[u].x) && (x2 >= row->col[u].x-1)) {
|
||||||
RESTORE_IMAGE (u);
|
RESTORE_IMAGE(u);
|
||||||
|
|
||||||
/* extend to left */
|
/* extend to left */
|
||||||
row->col[u].w += row->col[u].x - x1;
|
row->col[u].w += row->col[u].x - x1;
|
||||||
@ -523,13 +522,13 @@ void dirty_hline (Dirty *dirty, int x1, int y, int x2)
|
|||||||
|
|
||||||
/* inside the column */
|
/* inside the column */
|
||||||
if (x2 <= row->col[u].x+row->col[u].w-1) {
|
if (x2 <= row->col[u].x+row->col[u].w-1) {
|
||||||
row->col[u].data = jrealloc (row->col[u].data,
|
row->col[u].data = jrealloc(row->col[u].data,
|
||||||
DIRTY_LINE_SIZE (row->col[u].w));
|
DIRTY_LINE_SIZE(row->col[u].w));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* extend this column to "x2" */
|
/* extend this column to "x2" */
|
||||||
else {
|
else {
|
||||||
EAT_COLUMNS ();
|
EAT_COLUMNS();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -539,41 +538,41 @@ void dirty_hline (Dirty *dirty, int x1, int y, int x2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* add a new column */
|
/* add a new column */
|
||||||
ADD_COLUMN ();
|
ADD_COLUMN();
|
||||||
|
|
||||||
row->col[u].x = x1;
|
row->col[u].x = x1;
|
||||||
row->col[u].w = x2-x1+1;
|
row->col[u].w = x2-x1+1;
|
||||||
row->col[u].flags = 0;
|
row->col[u].flags = 0;
|
||||||
row->col[u].data = jmalloc (DIRTY_LINE_SIZE (row->col[u].w));
|
row->col[u].data = jmalloc(DIRTY_LINE_SIZE(row->col[u].w));
|
||||||
row->col[u].ptr = IMAGE_ADDRESS (dirty->image, x1, y);
|
row->col[u].ptr = IMAGE_ADDRESS(dirty->image, x1, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dirty_vline (Dirty *dirty, int x, int y1, int y2)
|
void dirty_vline(Dirty *dirty, int x, int y1, int y2)
|
||||||
{
|
{
|
||||||
dirty_line (dirty, x, y1, x, y2);
|
dirty_line(dirty, x, y1, x, y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dirty_line (Dirty *dirty, int x1, int y1, int x2, int y2)
|
void dirty_line(Dirty *dirty, int x1, int y1, int x2, int y2)
|
||||||
{
|
{
|
||||||
AlgoData data = { dirty, NULL, 0 };
|
AlgoData data = { dirty, NULL, 0 };
|
||||||
algo_line (x1, y1, x2, y2, &data, (AlgoPixel)algo_putpixel);
|
algo_line(x1, y1, x2, y2, &data, (AlgoPixel)algo_putpixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dirty_rect (Dirty *dirty, int x1, int y1, int x2, int y2)
|
void dirty_rect(Dirty *dirty, int x1, int y1, int x2, int y2)
|
||||||
{
|
{
|
||||||
dirty_hline (dirty, x1, y1, x2);
|
dirty_hline(dirty, x1, y1, x2);
|
||||||
dirty_hline (dirty, x1, y2, x2);
|
dirty_hline(dirty, x1, y2, x2);
|
||||||
dirty_vline (dirty, x1, y1, y2);
|
dirty_vline(dirty, x1, y1, y2);
|
||||||
dirty_vline (dirty, x2, y1, y2);
|
dirty_vline(dirty, x2, y1, y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dirty_rectfill (Dirty *dirty, int x1, int y1, int x2, int y2)
|
void dirty_rectfill(Dirty *dirty, int x1, int y1, int x2, int y2)
|
||||||
{
|
{
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
for (y=y1; y<=y2; y++)
|
for (y=y1; y<=y2; y++)
|
||||||
dirty_hline (dirty, x1, y, x2);
|
dirty_hline(dirty, x1, y, x2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* void dirty_putpixel_thick (Dirty *dirty, int x, int y, int thickness) */
|
/* void dirty_putpixel_thick (Dirty *dirty, int x, int y, int thickness) */
|
||||||
@ -591,35 +590,35 @@ void dirty_rectfill (Dirty *dirty, int x1, int y1, int x2, int y2)
|
|||||||
/* (AlgoPixel)algo_putthick); */
|
/* (AlgoPixel)algo_putthick); */
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
void dirty_putpixel_brush (Dirty *dirty, Brush *brush, int x, int y)
|
void dirty_putpixel_brush(Dirty *dirty, Brush *brush, int x, int y)
|
||||||
{
|
{
|
||||||
AlgoData data = { dirty, brush, 0 };
|
AlgoData data = { dirty, brush, 0 };
|
||||||
if (brush->size == 1)
|
if (brush->size == 1)
|
||||||
algo_putpixel (x, y, &data);
|
algo_putpixel(x, y, &data);
|
||||||
else
|
else
|
||||||
algo_putbrush (x, y, &data);
|
algo_putbrush(x, y, &data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dirty_hline_brush (Dirty *dirty, struct Brush *brush, int x1, int y, int x2)
|
void dirty_hline_brush(Dirty *dirty, struct Brush *brush, int x1, int y, int x2)
|
||||||
{
|
{
|
||||||
AlgoData data = { dirty, brush, 0 };
|
AlgoData data = { dirty, brush, 0 };
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
if (brush->size == 1)
|
if (brush->size == 1)
|
||||||
for (x=x1; x<=x2; x++)
|
for (x=x1; x<=x2; x++)
|
||||||
algo_putpixel (x, y, &data);
|
algo_putpixel(x, y, &data);
|
||||||
else
|
else
|
||||||
for (x=x1; x<=x2; x++)
|
for (x=x1; x<=x2; x++)
|
||||||
algo_putbrush (x, y, &data);
|
algo_putbrush(x, y, &data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dirty_line_brush (Dirty *dirty, Brush *brush, int x1, int y1, int x2, int y2)
|
void dirty_line_brush(Dirty *dirty, Brush *brush, int x1, int y1, int x2, int y2)
|
||||||
{
|
{
|
||||||
AlgoData data = { dirty, brush, 0 };
|
AlgoData data = { dirty, brush, 0 };
|
||||||
algo_line (x1, y1, x2, y2, &data,
|
algo_line(x1, y1, x2, y2, &data,
|
||||||
(brush->size == 1)?
|
(brush->size == 1)?
|
||||||
(AlgoPixel)algo_putpixel:
|
(AlgoPixel)algo_putpixel:
|
||||||
(AlgoPixel)algo_putbrush);
|
(AlgoPixel)algo_putbrush);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static void remove_column (Dirty *dirty, int u, int v) */
|
/* static void remove_column (Dirty *dirty, int u, int v) */
|
||||||
@ -670,18 +669,18 @@ void dirty_line_brush (Dirty *dirty, Brush *brush, int x1, int y1, int x2, int y
|
|||||||
/* } */
|
/* } */
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
void dirty_get (Dirty *dirty)
|
void dirty_get(Dirty *dirty)
|
||||||
{
|
{
|
||||||
int u, v, shift;
|
int u, v, shift;
|
||||||
|
|
||||||
shift = IMAGE_SHIFT (dirty->image);
|
shift = IMAGE_SHIFT(dirty->image);
|
||||||
|
|
||||||
for (v=0; v<dirty->rows; v++)
|
for (v=0; v<dirty->rows; v++)
|
||||||
for (u=0; u<dirty->row[v].cols; u++) {
|
for (u=0; u<dirty->row[v].cols; u++) {
|
||||||
if (!(dirty->row[v].col[u].flags & DIRTY_VALID_COLUMN)) {
|
if (!(dirty->row[v].col[u].flags & DIRTY_VALID_COLUMN)) {
|
||||||
memcpy (dirty->row[v].col[u].data,
|
memcpy(dirty->row[v].col[u].data,
|
||||||
dirty->row[v].col[u].ptr,
|
dirty->row[v].col[u].ptr,
|
||||||
dirty->row[v].col[u].w<<shift);
|
dirty->row[v].col[u].w<<shift);
|
||||||
|
|
||||||
dirty->row[v].col[u].flags |= DIRTY_VALID_COLUMN;
|
dirty->row[v].col[u].flags |= DIRTY_VALID_COLUMN;
|
||||||
dirty->row[v].col[u].flags |= DIRTY_MUSTBE_UPDATED;
|
dirty->row[v].col[u].flags |= DIRTY_MUSTBE_UPDATED;
|
||||||
@ -689,43 +688,43 @@ void dirty_get (Dirty *dirty)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dirty_put (Dirty *dirty)
|
void dirty_put(Dirty *dirty)
|
||||||
{
|
{
|
||||||
int u, v, shift;
|
int u, v, shift;
|
||||||
|
|
||||||
shift = IMAGE_SHIFT (dirty->image);
|
shift = IMAGE_SHIFT(dirty->image);
|
||||||
|
|
||||||
for (v=0; v<dirty->rows; v++)
|
for (v=0; v<dirty->rows; v++)
|
||||||
for (u=0; u<dirty->row[v].cols; u++) {
|
for (u=0; u<dirty->row[v].cols; u++) {
|
||||||
if (dirty->row[v].col[u].flags & DIRTY_VALID_COLUMN) {
|
if (dirty->row[v].col[u].flags & DIRTY_VALID_COLUMN) {
|
||||||
memcpy (dirty->row[v].col[u].ptr,
|
memcpy(dirty->row[v].col[u].ptr,
|
||||||
dirty->row[v].col[u].data,
|
dirty->row[v].col[u].data,
|
||||||
dirty->row[v].col[u].w<<shift);
|
dirty->row[v].col[u].w<<shift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dirty_swap (Dirty *dirty)
|
void dirty_swap(Dirty *dirty)
|
||||||
{
|
{
|
||||||
void (*proc) (void *image, void *data, int x1, int x2);
|
void (*proc)(void *image, void *data, int x1, int x2);
|
||||||
int u, v;
|
int u, v;
|
||||||
|
|
||||||
proc = swap_hline (dirty->image);
|
proc = swap_hline(dirty->image);
|
||||||
|
|
||||||
for (v=0; v<dirty->rows; v++)
|
for (v=0; v<dirty->rows; v++)
|
||||||
for (u=0; u<dirty->row[v].cols; u++) {
|
for (u=0; u<dirty->row[v].cols; u++) {
|
||||||
if (dirty->row[v].col[u].flags & DIRTY_VALID_COLUMN) {
|
if (dirty->row[v].col[u].flags & DIRTY_VALID_COLUMN) {
|
||||||
(*proc) (dirty->row[v].col[u].ptr,
|
(*proc)(dirty->row[v].col[u].ptr,
|
||||||
dirty->row[v].col[u].data,
|
dirty->row[v].col[u].data,
|
||||||
dirty->row[v].col[u].x,
|
dirty->row[v].col[u].x,
|
||||||
dirty->row[v].col[u].x+dirty->row[v].col[u].w-1);
|
dirty->row[v].col[u].x+dirty->row[v].col[u].w-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void algo_putpixel (int x, int y, AlgoData *data)
|
static void algo_putpixel (int x, int y, AlgoData *data)
|
||||||
{
|
{
|
||||||
dirty_putpixel (data->dirty, x, y);
|
dirty_putpixel(data->dirty, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static void algo_putthick (int x, int y, AlgoData *data) */
|
/* static void algo_putthick (int x, int y, AlgoData *data) */
|
||||||
@ -746,7 +745,7 @@ static void algo_putbrush (int x, int y, AlgoData *data)
|
|||||||
|
|
||||||
for (c=0; c<data->brush->size; c++) {
|
for (c=0; c<data->brush->size; c++) {
|
||||||
if (scanline->state)
|
if (scanline->state)
|
||||||
dirty_hline (data->dirty, x+scanline->x1, y+c, x+scanline->x2);
|
dirty_hline(data->dirty, x+scanline->x1, y+c, x+scanline->x2);
|
||||||
scanline++;
|
scanline++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -764,10 +763,10 @@ static void *swap_hline (Image *image)
|
|||||||
return proc;
|
return proc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void swap_hline1 (void *image, void *data, int x1, int x2)
|
static void swap_hline1(void *image, void *data, int x1, int x2)
|
||||||
{
|
{
|
||||||
unsigned char *address1 = image;
|
ase_uint8 *address1 = image;
|
||||||
unsigned char *address2 = data;
|
ase_uint8 *address2 = data;
|
||||||
register int c;
|
register int c;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
@ -780,10 +779,10 @@ static void swap_hline1 (void *image, void *data, int x1, int x2)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void swap_hline2 (void *image, void *data, int x1, int x2)
|
static void swap_hline2(void *image, void *data, int x1, int x2)
|
||||||
{
|
{
|
||||||
unsigned short *address1 = image;
|
ase_uint16 *address1 = image;
|
||||||
unsigned short *address2 = data;
|
ase_uint16 *address2 = data;
|
||||||
register int c;
|
register int c;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
@ -796,10 +795,10 @@ static void swap_hline2 (void *image, void *data, int x1, int x2)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void swap_hline4 (void *image, void *data, int x1, int x2)
|
static void swap_hline4(void *image, void *data, int x1, int x2)
|
||||||
{
|
{
|
||||||
unsigned long *address1 = image;
|
ase_uint32 *address1 = image;
|
||||||
unsigned long *address2 = data;
|
ase_uint32 *address2 = data;
|
||||||
register int c;
|
register int c;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
|
@ -28,21 +28,21 @@ struct Mask;
|
|||||||
|
|
||||||
#define IMAGE_ADDRESS(d,x,y) \
|
#define IMAGE_ADDRESS(d,x,y) \
|
||||||
((void *)((d)->imgtype == IMAGE_RGB)? \
|
((void *)((d)->imgtype == IMAGE_RGB)? \
|
||||||
(void *)(((unsigned long **)(d)->line)[(y)]+(x)): \
|
(void *)(((ase_uint32 **)(d)->line)[(y)]+(x)): \
|
||||||
((d)->imgtype == IMAGE_GRAYSCALE)? \
|
((d)->imgtype == IMAGE_GRAYSCALE)? \
|
||||||
(void *)(((unsigned short **)(d)->line)[(y)]+(x)): \
|
(void *)(((ase_uint16 **)(d)->line)[(y)]+(x)): \
|
||||||
((d)->imgtype == IMAGE_INDEXED)? \
|
((d)->imgtype == IMAGE_INDEXED)? \
|
||||||
(void *)(((unsigned char **)(d)->line)[(y)]+(x)): 0)
|
(void *)(((ase_uint8 **)(d)->line)[(y)]+(x)): 0)
|
||||||
|
|
||||||
#define IMAGE_SHIFT(d) \
|
#define IMAGE_SHIFT(d) \
|
||||||
(((d)->imgtype == IMAGE_RGB)? 2: \
|
(((d)->imgtype == IMAGE_RGB)? 2: \
|
||||||
((d)->imgtype == IMAGE_GRAYSCALE)? 1: 0)
|
((d)->imgtype == IMAGE_GRAYSCALE)? 1: 0)
|
||||||
|
|
||||||
#define IMAGE_LINE_SIZE(image, width) \
|
#define IMAGE_LINE_SIZE(image, width) \
|
||||||
((width) << IMAGE_SHIFT (image))
|
((width) << IMAGE_SHIFT(image))
|
||||||
|
|
||||||
#define DIRTY_LINE_SIZE(width) \
|
#define DIRTY_LINE_SIZE(width) \
|
||||||
(IMAGE_LINE_SIZE (dirty->image, width))
|
(IMAGE_LINE_SIZE(dirty->image, width))
|
||||||
|
|
||||||
typedef struct Dirty Dirty;
|
typedef struct Dirty Dirty;
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ void dirty_putpixel_brush(Dirty *dirty, struct Brush *brush, int x, int y);
|
|||||||
void dirty_hline_brush(Dirty *dirty, struct Brush *brush, int x1, int y, int x2);
|
void dirty_hline_brush(Dirty *dirty, struct Brush *brush, int x1, int y, int x2);
|
||||||
void dirty_line_brush(Dirty *dirty, struct Brush *brush, int x1, int y1, int x2, int y2);
|
void dirty_line_brush(Dirty *dirty, struct Brush *brush, int x1, int y1, int x2, int y2);
|
||||||
|
|
||||||
/* void dirty_optimize (Dirty *dirty); */
|
/* void dirty_optimize(Dirty *dirty); */
|
||||||
|
|
||||||
void dirty_get(Dirty *dirty);
|
void dirty_get(Dirty *dirty);
|
||||||
void dirty_put(Dirty *dirty);
|
void dirty_put(Dirty *dirty);
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* #define USE_ALLEGRO_IMAGE */
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifndef USE_PRECOMPILED_HEADER
|
#ifndef USE_PRECOMPILED_HEADER
|
||||||
@ -47,205 +45,7 @@ static ImageMethods *image_methods[] =
|
|||||||
&bitmap_methods, /* IMAGE_BITMAP */
|
&bitmap_methods, /* IMAGE_BITMAP */
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
/**********************************************************************/
|
#include "imgalleg.c"
|
||||||
/**********************************************************************/
|
|
||||||
/**********************************************************************/
|
|
||||||
|
|
||||||
#undef BYTES
|
|
||||||
#undef LINES
|
|
||||||
|
|
||||||
#define BYTES(image) ((unsigned char *)image->dat)
|
|
||||||
#define LINES(image) ((unsigned char **)image->line)
|
|
||||||
|
|
||||||
static int alleg_init (Image *image)
|
|
||||||
{
|
|
||||||
static int _image_depth[] = { 32, 16, 8, 8 };
|
|
||||||
image->bmp = create_bitmap_ex (_image_depth[image->imgtype],
|
|
||||||
image->w, image->h);
|
|
||||||
image->dat = image->bmp->dat;
|
|
||||||
image->line = image->bmp->line;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int alleg_getpixel (const Image *image, int x, int y)
|
|
||||||
{
|
|
||||||
return getpixel (image->bmp, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void alleg_putpixel (Image *image, int x, int y, int color)
|
|
||||||
{
|
|
||||||
putpixel (image->bmp, x, y, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void alleg_clear (Image *image, int color)
|
|
||||||
{
|
|
||||||
clear_to_color (image->bmp, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void alleg_copy (Image *dst, const Image *src, int x, int y)
|
|
||||||
{
|
|
||||||
blit (src->bmp, dst->bmp, 0, 0, x, y, src->w, src->h);
|
|
||||||
#if 0
|
|
||||||
unsigned char *src_address;
|
|
||||||
unsigned char *dst_address;
|
|
||||||
int xbeg, xend, xsrc;
|
|
||||||
int ybeg, yend, ysrc, ydst;
|
|
||||||
int bytes;
|
|
||||||
|
|
||||||
/* clipping */
|
|
||||||
|
|
||||||
xsrc = 0;
|
|
||||||
ysrc = 0;
|
|
||||||
|
|
||||||
xbeg = x;
|
|
||||||
ybeg = y;
|
|
||||||
xend = x+src->w-1;
|
|
||||||
yend = y+src->h-1;
|
|
||||||
|
|
||||||
if ((xend < 0) || (xbeg >= dst->w) ||
|
|
||||||
(yend < 0) || (ybeg >= dst->h))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (xbeg < 0) {
|
|
||||||
xsrc -= xbeg;
|
|
||||||
xbeg = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ybeg < 0) {
|
|
||||||
ysrc -= ybeg;
|
|
||||||
ybeg = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xend >= dst->w)
|
|
||||||
xend = dst->w-1;
|
|
||||||
|
|
||||||
if (yend >= dst->h)
|
|
||||||
yend = dst->h-1;
|
|
||||||
|
|
||||||
/* copy process */
|
|
||||||
|
|
||||||
bytes = (xend - xbeg + 1);
|
|
||||||
|
|
||||||
for (ydst=ybeg; ydst<=yend; ydst++, ysrc++) {
|
|
||||||
src_address = LINES (src)[ysrc]+xsrc;
|
|
||||||
dst_address = LINES (dst)[ydst]+xbeg;
|
|
||||||
|
|
||||||
memcpy (dst_address, src_address, bytes);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if "color_map" is not NULL, it's used by the routine to merge the
|
|
||||||
source and the destionation pixels */
|
|
||||||
static void alleg_merge (Image *dst, const Image *src,
|
|
||||||
int x, int y, int opacity, int blend_mode)
|
|
||||||
{
|
|
||||||
masked_blit (src->bmp, dst->bmp, 0, 0, x, y, src->w, src->h);
|
|
||||||
#if 0
|
|
||||||
unsigned char *src_address;
|
|
||||||
unsigned char *dst_address;
|
|
||||||
int xbeg, xend, xsrc, xdst;
|
|
||||||
int ybeg, yend, ysrc, ydst;
|
|
||||||
|
|
||||||
/* clipping */
|
|
||||||
|
|
||||||
xsrc = 0;
|
|
||||||
ysrc = 0;
|
|
||||||
|
|
||||||
xbeg = x;
|
|
||||||
ybeg = y;
|
|
||||||
xend = x+src->w-1;
|
|
||||||
yend = y+src->h-1;
|
|
||||||
|
|
||||||
if ((xend < 0) || (xbeg >= dst->w) ||
|
|
||||||
(yend < 0) || (ybeg >= dst->h))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (xbeg < 0) {
|
|
||||||
xsrc -= xbeg;
|
|
||||||
xbeg = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ybeg < 0) {
|
|
||||||
ysrc -= ybeg;
|
|
||||||
ybeg = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xend >= dst->w)
|
|
||||||
xend = dst->w-1;
|
|
||||||
|
|
||||||
if (yend >= dst->h)
|
|
||||||
yend = dst->h-1;
|
|
||||||
|
|
||||||
/* merge process */
|
|
||||||
|
|
||||||
/* direct copy */
|
|
||||||
if (blend_mode == BLEND_MODE_COPY) {
|
|
||||||
for (ydst=ybeg; ydst<=yend; ydst++, ysrc++) {
|
|
||||||
src_address = LINES (src)[ysrc]+xsrc;
|
|
||||||
dst_address = LINES (dst)[ydst]+xbeg;
|
|
||||||
|
|
||||||
for (xdst=xbeg; xdst<=xend; xdst++) {
|
|
||||||
*dst_address = (*src_address);
|
|
||||||
|
|
||||||
dst_address++;
|
|
||||||
src_address++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* with mask */
|
|
||||||
else {
|
|
||||||
for (ydst=ybeg; ydst<=yend; ydst++, ysrc++) {
|
|
||||||
src_address = LINES (src)[ysrc]+xsrc;
|
|
||||||
dst_address = LINES (dst)[ydst]+xbeg;
|
|
||||||
|
|
||||||
for (xdst=xbeg; xdst<=xend; xdst++) {
|
|
||||||
if (*src_address) {
|
|
||||||
if (color_map)
|
|
||||||
*dst_address = color_map->data[*src_address][*dst_address];
|
|
||||||
else
|
|
||||||
*dst_address = (*src_address);
|
|
||||||
}
|
|
||||||
|
|
||||||
dst_address++;
|
|
||||||
src_address++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void alleg_hline (Image *image, int x1, int y, int x2, int color)
|
|
||||||
{
|
|
||||||
hline (image->bmp, x1, y, x2, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void alleg_rectfill (Image *image, int x1, int y1, int x2, int y2, int color)
|
|
||||||
{
|
|
||||||
rectfill (image->bmp, x1, y1, x2, y2, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void alleg_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
|
|
||||||
{
|
|
||||||
blit (image->bmp, bmp, 0, 0, _x, _y, image->w, image->h);
|
|
||||||
}
|
|
||||||
|
|
||||||
static ImageMethods alleg_methods =
|
|
||||||
{
|
|
||||||
alleg_init,
|
|
||||||
alleg_getpixel,
|
|
||||||
alleg_putpixel,
|
|
||||||
alleg_clear,
|
|
||||||
alleg_copy,
|
|
||||||
alleg_merge,
|
|
||||||
alleg_hline,
|
|
||||||
alleg_rectfill,
|
|
||||||
alleg_to_allegro,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**********************************************************************/
|
|
||||||
/**********************************************************************/
|
|
||||||
/**********************************************************************/
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Image *image_new(int imgtype, int w, int h)
|
Image *image_new(int imgtype, int w, int h)
|
||||||
@ -341,12 +141,12 @@ Image *image_crop(const Image *image, int x, int y, int w, int h)
|
|||||||
if ((w < 1) || (h < 1))
|
if ((w < 1) || (h < 1))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
trim = image_new (image->imgtype, w, h);
|
trim = image_new(image->imgtype, w, h);
|
||||||
if (!trim)
|
if (!trim)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
image_clear (trim, 0);
|
image_clear(trim, 0);
|
||||||
image_copy (trim, image, -x, -y);
|
image_copy(trim, image, -x, -y);
|
||||||
|
|
||||||
return trim;
|
return trim;
|
||||||
}
|
}
|
||||||
@ -367,7 +167,7 @@ void image_hline(Image *image, int x1, int y, int x2, int color)
|
|||||||
if (x1 < 0) x1 = 0;
|
if (x1 < 0) x1 = 0;
|
||||||
if (x2 >= image->w) x2 = image->w-1;
|
if (x2 >= image->w) x2 = image->w-1;
|
||||||
|
|
||||||
image->method->hline (image, x1, y, x2, color);
|
image->method->hline(image, x1, y, x2, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void image_vline(Image *image, int x, int y1, int y2, int color)
|
void image_vline(Image *image, int x, int y1, int y2, int color)
|
||||||
@ -387,7 +187,7 @@ void image_vline(Image *image, int x, int y1, int y2, int color)
|
|||||||
if (y2 >= image->h) y2 = image->h-1;
|
if (y2 >= image->h) y2 = image->h-1;
|
||||||
|
|
||||||
for (t=y1; t<=y2; t++)
|
for (t=y1; t<=y2; t++)
|
||||||
image->method->putpixel (image, x, t, color);
|
image->method->putpixel(image, x, t, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void image_rect(Image *image, int x1, int y1, int x2, int y2, int color)
|
void image_rect(Image *image, int x1, int y1, int x2, int y2, int color)
|
||||||
@ -463,24 +263,24 @@ static void hline_for_image(int x1, int y, int x2, Data *data)
|
|||||||
void image_line(Image *image, int x1, int y1, int x2, int y2, int color)
|
void image_line(Image *image, int x1, int y1, int x2, int y2, int color)
|
||||||
{
|
{
|
||||||
Data data = { image, color };
|
Data data = { image, color };
|
||||||
algo_line (x1, y1, x2, y2, &data, (AlgoPixel)pixel_for_image);
|
algo_line(x1, y1, x2, y2, &data, (AlgoPixel)pixel_for_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
void image_ellipse(Image *image, int x1, int y1, int x2, int y2, int color)
|
void image_ellipse(Image *image, int x1, int y1, int x2, int y2, int color)
|
||||||
{
|
{
|
||||||
Data data = { image, color };
|
Data data = { image, color };
|
||||||
algo_ellipse (x1, y1, x2, y2, &data, (AlgoPixel)pixel_for_image);
|
algo_ellipse(x1, y1, x2, y2, &data, (AlgoPixel)pixel_for_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
void image_ellipsefill(Image *image, int x1, int y1, int x2, int y2, int color)
|
void image_ellipsefill(Image *image, int x1, int y1, int x2, int y2, int color)
|
||||||
{
|
{
|
||||||
Data data = { image, color };
|
Data data = { image, color };
|
||||||
algo_ellipsefill (x1, y1, x2, y2, &data, (AlgoHLine)hline_for_image);
|
algo_ellipsefill(x1, y1, x2, y2, &data, (AlgoHLine)hline_for_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
void image_to_allegro(Image *image, struct BITMAP *bmp, int x, int y)
|
void image_to_allegro(Image *image, struct BITMAP *bmp, int x, int y)
|
||||||
{
|
{
|
||||||
image->method->to_allegro (image, bmp, x, y);
|
image->method->to_allegro(image, bmp, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void image_convert(Image *dst, const Image *src)
|
void image_convert(Image *dst, const Image *src)
|
||||||
@ -491,7 +291,7 @@ void image_convert(Image *dst, const Image *src)
|
|||||||
if ((src->w != dst->w) || (src->h != dst->h))
|
if ((src->w != dst->w) || (src->h != dst->h))
|
||||||
return;
|
return;
|
||||||
else if (src->imgtype == dst->imgtype) {
|
else if (src->imgtype == dst->imgtype) {
|
||||||
image_copy (dst, src, 0, 0);
|
image_copy(dst, src, 0, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -507,14 +307,14 @@ void image_convert(Image *dst, const Image *src)
|
|||||||
case IMAGE_GRAYSCALE:
|
case IMAGE_GRAYSCALE:
|
||||||
for (y=0; y<h; y++) {
|
for (y=0; y<h; y++) {
|
||||||
for (x=0; x<w; x++) {
|
for (x=0; x<w; x++) {
|
||||||
c = src->method->getpixel (src, x, y);
|
c = src->method->getpixel(src, x, y);
|
||||||
rgb_to_hsv (_rgba_getr (c),
|
rgb_to_hsv(_rgba_getr(c),
|
||||||
_rgba_getg (c),
|
_rgba_getg(c),
|
||||||
_rgba_getb (c), &hue, &s, &v);
|
_rgba_getb(c), &hue, &s, &v);
|
||||||
v = v * 255.0f;
|
v = v * 255.0f;
|
||||||
dst->method->putpixel (dst, x, y,
|
dst->method->putpixel(dst, x, y,
|
||||||
_graya((int)MID (0, v, 255),
|
_graya((int)MID(0, v, 255),
|
||||||
_rgba_geta (c)));
|
_rgba_geta(c)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -523,14 +323,14 @@ void image_convert(Image *dst, const Image *src)
|
|||||||
case IMAGE_INDEXED:
|
case IMAGE_INDEXED:
|
||||||
for (y=0; y<h; y++) {
|
for (y=0; y<h; y++) {
|
||||||
for (x=0; x<w; x++) {
|
for (x=0; x<w; x++) {
|
||||||
c = src->method->getpixel (src, x, y);
|
c = src->method->getpixel(src, x, y);
|
||||||
if (!_rgba_geta (c))
|
if (!_rgba_geta (c))
|
||||||
dst->method->putpixel (dst, x, y, 0);
|
dst->method->putpixel(dst, x, y, 0);
|
||||||
else
|
else
|
||||||
dst->method->putpixel (dst, x, y,
|
dst->method->putpixel(dst, x, y,
|
||||||
makecol8 (_rgba_getr (c),
|
makecol8(_rgba_getr(c),
|
||||||
_rgba_getg (c),
|
_rgba_getg(c),
|
||||||
_rgba_getb (c)));
|
_rgba_getb(c)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -544,12 +344,12 @@ void image_convert(Image *dst, const Image *src)
|
|||||||
case IMAGE_RGB:
|
case IMAGE_RGB:
|
||||||
for (y=0; y<h; y++) {
|
for (y=0; y<h; y++) {
|
||||||
for (x=0; x<w; x++) {
|
for (x=0; x<w; x++) {
|
||||||
c = src->method->getpixel (src, x, y);
|
c = src->method->getpixel(src, x, y);
|
||||||
dst->method->putpixel (dst, x, y,
|
dst->method->putpixel(dst, x, y,
|
||||||
_rgba (_graya_getk (c),
|
_rgba(_graya_getk(c),
|
||||||
_graya_getk (c),
|
_graya_getk(c),
|
||||||
_graya_getk (c),
|
_graya_getk(c),
|
||||||
_graya_geta (c)));
|
_graya_geta(c)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -558,14 +358,14 @@ void image_convert(Image *dst, const Image *src)
|
|||||||
case IMAGE_INDEXED:
|
case IMAGE_INDEXED:
|
||||||
for (y=0; y<h; y++) {
|
for (y=0; y<h; y++) {
|
||||||
for (x=0; x<w; x++) {
|
for (x=0; x<w; x++) {
|
||||||
c = src->method->getpixel (src, x, y);
|
c = src->method->getpixel(src, x, y);
|
||||||
if (!_graya_geta (c))
|
if (!_graya_geta (c))
|
||||||
dst->method->putpixel (dst, x, y, 0);
|
dst->method->putpixel(dst, x, y, 0);
|
||||||
else
|
else
|
||||||
dst->method->putpixel (dst, x, y,
|
dst->method->putpixel(dst, x, y,
|
||||||
makecol8 (_graya_getk (c),
|
makecol8(_graya_getk(c),
|
||||||
_graya_getk (c),
|
_graya_getk(c),
|
||||||
_graya_getk (c)));
|
_graya_getk(c)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -579,14 +379,14 @@ void image_convert(Image *dst, const Image *src)
|
|||||||
case IMAGE_RGB:
|
case IMAGE_RGB:
|
||||||
for (y=0; y<h; y++) {
|
for (y=0; y<h; y++) {
|
||||||
for (x=0; x<w; x++) {
|
for (x=0; x<w; x++) {
|
||||||
c = src->method->getpixel (src, x, y);
|
c = src->method->getpixel(src, x, y);
|
||||||
if (!c)
|
if (!c)
|
||||||
dst->method->putpixel (dst, x, y, 0);
|
dst->method->putpixel(dst, x, y, 0);
|
||||||
else
|
else
|
||||||
dst->method->putpixel (dst, x, y,
|
dst->method->putpixel(dst, x, y,
|
||||||
_rgba (getr8 (c),
|
_rgba(getr8(c),
|
||||||
getg8 (c),
|
getg8(c),
|
||||||
getb8 (c), 255));
|
getb8(c), 255));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -595,14 +395,14 @@ void image_convert(Image *dst, const Image *src)
|
|||||||
case IMAGE_GRAYSCALE:
|
case IMAGE_GRAYSCALE:
|
||||||
for (y=0; y<h; y++) {
|
for (y=0; y<h; y++) {
|
||||||
for (x=0; x<w; x++) {
|
for (x=0; x<w; x++) {
|
||||||
c = src->method->getpixel (src, x, y);
|
c = src->method->getpixel(src, x, y);
|
||||||
if (!c)
|
if (!c)
|
||||||
dst->method->putpixel (dst, x, y, 0);
|
dst->method->putpixel(dst, x, y, 0);
|
||||||
else {
|
else {
|
||||||
rgb_to_hsv (getr8 (c), getg8 (c), getb8 (c), &hue, &s, &v);
|
rgb_to_hsv(getr8(c), getg8(c), getb8(c), &hue, &s, &v);
|
||||||
v = v * 255.0f;
|
v = v * 255.0f;
|
||||||
dst->method->putpixel (dst, x, y,
|
dst->method->putpixel(dst, x, y,
|
||||||
_graya ((int)MID (0, v, 255), 255));
|
_graya((int)MID(0, v, 255), 255));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -625,8 +425,8 @@ int image_count_diff(const Image *i1, const Image *i2)
|
|||||||
|
|
||||||
case IMAGE_RGB:
|
case IMAGE_RGB:
|
||||||
{
|
{
|
||||||
unsigned long *address1 = (unsigned long *)i1->dat;
|
ase_uint32 *address1 = (ase_uint32 *)i1->dat;
|
||||||
unsigned long *address2 = (unsigned long *)i2->dat;
|
ase_uint32 *address2 = (ase_uint32 *)i2->dat;
|
||||||
for (c=0; c<size; c++)
|
for (c=0; c<size; c++)
|
||||||
if (*(address1++) != *(address2++))
|
if (*(address1++) != *(address2++))
|
||||||
diff++;
|
diff++;
|
||||||
@ -635,8 +435,8 @@ int image_count_diff(const Image *i1, const Image *i2)
|
|||||||
|
|
||||||
case IMAGE_GRAYSCALE:
|
case IMAGE_GRAYSCALE:
|
||||||
{
|
{
|
||||||
unsigned short *address1 = (unsigned short *)i1->dat;
|
ase_uint16 *address1 = (ase_uint16 *)i1->dat;
|
||||||
unsigned short *address2 = (unsigned short *)i2->dat;
|
ase_uint16 *address2 = (ase_uint16 *)i2->dat;
|
||||||
for (c=0; c<size; c++)
|
for (c=0; c<size; c++)
|
||||||
if (*(address1++) != *(address2++))
|
if (*(address1++) != *(address2++))
|
||||||
diff++;
|
diff++;
|
||||||
@ -645,8 +445,8 @@ int image_count_diff(const Image *i1, const Image *i2)
|
|||||||
|
|
||||||
case IMAGE_INDEXED:
|
case IMAGE_INDEXED:
|
||||||
{
|
{
|
||||||
unsigned char *address1 = (unsigned char *)i1->dat;
|
ase_uint8 *address1 = (ase_uint8 *)i1->dat;
|
||||||
unsigned char *address2 = (unsigned char *)i2->dat;
|
ase_uint8 *address2 = (ase_uint8 *)i2->dat;
|
||||||
for (c=0; c<size; c++)
|
for (c=0; c<size; c++)
|
||||||
if (*(address1++) != *(address2++))
|
if (*(address1++) != *(address2++))
|
||||||
diff++;
|
diff++;
|
||||||
@ -656,8 +456,8 @@ int image_count_diff(const Image *i1, const Image *i2)
|
|||||||
case IMAGE_BITMAP:
|
case IMAGE_BITMAP:
|
||||||
/* TODO test it */
|
/* TODO test it */
|
||||||
{
|
{
|
||||||
unsigned char *address1 = (unsigned char *)i1->dat;
|
ase_uint8 *address1 = (ase_uint8 *)i1->dat;
|
||||||
unsigned char *address2 = (unsigned char *)i2->dat;
|
ase_uint8 *address2 = (ase_uint8 *)i2->dat;
|
||||||
div_t d1 = div (0, 8);
|
div_t d1 = div (0, 8);
|
||||||
div_t d2 = div (0, 8);
|
div_t d2 = div (0, 8);
|
||||||
for (c=0; c<size; c++) {
|
for (c=0; c<size; c++) {
|
||||||
|
@ -19,26 +19,28 @@
|
|||||||
#ifndef RASTER_IMAGE_H
|
#ifndef RASTER_IMAGE_H
|
||||||
#define RASTER_IMAGE_H
|
#define RASTER_IMAGE_H
|
||||||
|
|
||||||
|
/* #define USE_ALLEGRO_IMAGE */
|
||||||
|
|
||||||
#include "raster/gfxobj.h"
|
#include "raster/gfxobj.h"
|
||||||
|
|
||||||
#define _rgba_r_shift 0
|
#define _rgba_r_shift 0
|
||||||
#define _rgba_g_shift 8
|
#define _rgba_g_shift 8
|
||||||
#define _rgba_b_shift 16
|
#define _rgba_b_shift 16
|
||||||
#define _rgba_a_shift 24
|
#define _rgba_a_shift 24
|
||||||
#define _rgba_getr(c) (((c) >> _rgba_r_shift) & 0xff)
|
#define _rgba_getr(c) (((c) >> _rgba_r_shift) & 0xff)
|
||||||
#define _rgba_getg(c) (((c) >> _rgba_g_shift) & 0xff)
|
#define _rgba_getg(c) (((c) >> _rgba_g_shift) & 0xff)
|
||||||
#define _rgba_getb(c) (((c) >> _rgba_b_shift) & 0xff)
|
#define _rgba_getb(c) (((c) >> _rgba_b_shift) & 0xff)
|
||||||
#define _rgba_geta(c) (((c) >> _rgba_a_shift) & 0xff)
|
#define _rgba_geta(c) (((c) >> _rgba_a_shift) & 0xff)
|
||||||
#define _rgba(r,g,b,a) \
|
#define _rgba(r,g,b,a) \
|
||||||
(((r) << _rgba_r_shift) | \
|
(((r) << _rgba_r_shift) | \
|
||||||
((g) << _rgba_g_shift) | \
|
((g) << _rgba_g_shift) | \
|
||||||
((b) << _rgba_b_shift) | \
|
((b) << _rgba_b_shift) | \
|
||||||
((a) << _rgba_a_shift))
|
((a) << _rgba_a_shift))
|
||||||
|
|
||||||
#define _graya_k_shift 0
|
#define _graya_k_shift 0
|
||||||
#define _graya_a_shift 8
|
#define _graya_a_shift 8
|
||||||
#define _graya_getk(c) (((c) >> _graya_k_shift) & 0xff)
|
#define _graya_getk(c) (((c) >> _graya_k_shift) & 0xff)
|
||||||
#define _graya_geta(c) (((c) >> _graya_a_shift) & 0xff)
|
#define _graya_geta(c) (((c) >> _graya_a_shift) & 0xff)
|
||||||
#define _graya(k,a) \
|
#define _graya(k,a) \
|
||||||
(((k) << _graya_k_shift) | \
|
(((k) << _graya_k_shift) | \
|
||||||
((a) << _graya_a_shift))
|
((a) << _graya_a_shift))
|
||||||
@ -69,10 +71,12 @@ struct Image
|
|||||||
GfxObj gfxobj;
|
GfxObj gfxobj;
|
||||||
int imgtype;
|
int imgtype;
|
||||||
int w, h;
|
int w, h;
|
||||||
unsigned char *dat; /* pixmap data */
|
ase_uint8 *dat; /* pixmap data */
|
||||||
unsigned char **line; /* start of each scanline */
|
ase_uint8 **line; /* start of each scanline */
|
||||||
struct ImageMethods *method;
|
struct ImageMethods *method;
|
||||||
// struct BITMAP *bmp;
|
#ifdef USE_ALLEGRO_IMAGE
|
||||||
|
struct BITMAP *bmp;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct ImageMethods
|
typedef struct ImageMethods
|
||||||
@ -112,8 +116,7 @@ void image_rect(Image *image, int x1, int y1, int x2, int y2, int color);
|
|||||||
void image_rectfill(Image *image, int x1, int y1, int x2, int y2, int color);
|
void image_rectfill(Image *image, int x1, int y1, int x2, int y2, int color);
|
||||||
void image_line(Image *image, int x1, int y1, int x2, int y2, int color);
|
void image_line(Image *image, int x1, int y1, int x2, int y2, int color);
|
||||||
void image_ellipse(Image *image, int x1, int y1, int x2, int y2, int color);
|
void image_ellipse(Image *image, int x1, int y1, int x2, int y2, int color);
|
||||||
void image_ellipsefill(Image *image, int x1, int y1, int x2, int y2,
|
void image_ellipsefill(Image *image, int x1, int y1, int x2, int y2, int color);
|
||||||
int color);
|
|
||||||
|
|
||||||
void image_to_allegro(Image *image, struct BITMAP *bmp, int x, int y);
|
void image_to_allegro(Image *image, struct BITMAP *bmp, int x, int y);
|
||||||
|
|
||||||
|
209
src/raster/imgalleg.c
Normal file
209
src/raster/imgalleg.c
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
/* ASE - Allegro Sprite Editor
|
||||||
|
* Copyright (C) 2001-2005, 2007 David A. Capello
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#undef BYTES
|
||||||
|
#undef LINES
|
||||||
|
|
||||||
|
#define BYTES(image) ((ase_uint8 *)image->dat)
|
||||||
|
#define LINES(image) ((ase_uint8 **)image->line)
|
||||||
|
|
||||||
|
static int alleg_init(Image *image)
|
||||||
|
{
|
||||||
|
static int _image_depth[] = { 32, 16, 8, 8 };
|
||||||
|
image->bmp = create_bitmap_ex(_image_depth[image->imgtype],
|
||||||
|
image->w, image->h);
|
||||||
|
image->dat = image->bmp->dat;
|
||||||
|
image->line = image->bmp->line;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int alleg_getpixel(const Image *image, int x, int y)
|
||||||
|
{
|
||||||
|
return getpixel(image->bmp, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void alleg_putpixel(Image *image, int x, int y, int color)
|
||||||
|
{
|
||||||
|
putpixel(image->bmp, x, y, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void alleg_clear(Image *image, int color)
|
||||||
|
{
|
||||||
|
clear_to_color(image->bmp, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void alleg_copy(Image *dst, const Image *src, int x, int y)
|
||||||
|
{
|
||||||
|
blit(src->bmp, dst->bmp, 0, 0, x, y, src->w, src->h);
|
||||||
|
#if 0
|
||||||
|
ase_uint8 *src_address;
|
||||||
|
ase_uint8 *dst_address;
|
||||||
|
int xbeg, xend, xsrc;
|
||||||
|
int ybeg, yend, ysrc, ydst;
|
||||||
|
int bytes;
|
||||||
|
|
||||||
|
/* clipping */
|
||||||
|
|
||||||
|
xsrc = 0;
|
||||||
|
ysrc = 0;
|
||||||
|
|
||||||
|
xbeg = x;
|
||||||
|
ybeg = y;
|
||||||
|
xend = x+src->w-1;
|
||||||
|
yend = y+src->h-1;
|
||||||
|
|
||||||
|
if ((xend < 0) || (xbeg >= dst->w) ||
|
||||||
|
(yend < 0) || (ybeg >= dst->h))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (xbeg < 0) {
|
||||||
|
xsrc -= xbeg;
|
||||||
|
xbeg = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ybeg < 0) {
|
||||||
|
ysrc -= ybeg;
|
||||||
|
ybeg = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xend >= dst->w)
|
||||||
|
xend = dst->w-1;
|
||||||
|
|
||||||
|
if (yend >= dst->h)
|
||||||
|
yend = dst->h-1;
|
||||||
|
|
||||||
|
/* copy process */
|
||||||
|
|
||||||
|
bytes = (xend - xbeg + 1);
|
||||||
|
|
||||||
|
for (ydst=ybeg; ydst<=yend; ydst++, ysrc++) {
|
||||||
|
src_address = LINES (src)[ysrc]+xsrc;
|
||||||
|
dst_address = LINES (dst)[ydst]+xbeg;
|
||||||
|
|
||||||
|
memcpy (dst_address, src_address, bytes);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if "color_map" is not NULL, it's used by the routine to merge the
|
||||||
|
source and the destionation pixels */
|
||||||
|
static void alleg_merge(Image *dst, const Image *src,
|
||||||
|
int x, int y, int opacity, int blend_mode)
|
||||||
|
{
|
||||||
|
masked_blit(src->bmp, dst->bmp, 0, 0, x, y, src->w, src->h);
|
||||||
|
#if 0
|
||||||
|
ase_uint8 *src_address;
|
||||||
|
ase_uint8 *dst_address;
|
||||||
|
int xbeg, xend, xsrc, xdst;
|
||||||
|
int ybeg, yend, ysrc, ydst;
|
||||||
|
|
||||||
|
/* clipping */
|
||||||
|
|
||||||
|
xsrc = 0;
|
||||||
|
ysrc = 0;
|
||||||
|
|
||||||
|
xbeg = x;
|
||||||
|
ybeg = y;
|
||||||
|
xend = x+src->w-1;
|
||||||
|
yend = y+src->h-1;
|
||||||
|
|
||||||
|
if ((xend < 0) || (xbeg >= dst->w) ||
|
||||||
|
(yend < 0) || (ybeg >= dst->h))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (xbeg < 0) {
|
||||||
|
xsrc -= xbeg;
|
||||||
|
xbeg = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ybeg < 0) {
|
||||||
|
ysrc -= ybeg;
|
||||||
|
ybeg = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xend >= dst->w)
|
||||||
|
xend = dst->w-1;
|
||||||
|
|
||||||
|
if (yend >= dst->h)
|
||||||
|
yend = dst->h-1;
|
||||||
|
|
||||||
|
/* merge process */
|
||||||
|
|
||||||
|
/* direct copy */
|
||||||
|
if (blend_mode == BLEND_MODE_COPY) {
|
||||||
|
for (ydst=ybeg; ydst<=yend; ydst++, ysrc++) {
|
||||||
|
src_address = LINES (src)[ysrc]+xsrc;
|
||||||
|
dst_address = LINES (dst)[ydst]+xbeg;
|
||||||
|
|
||||||
|
for (xdst=xbeg; xdst<=xend; xdst++) {
|
||||||
|
*dst_address = (*src_address);
|
||||||
|
|
||||||
|
dst_address++;
|
||||||
|
src_address++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* with mask */
|
||||||
|
else {
|
||||||
|
for (ydst=ybeg; ydst<=yend; ydst++, ysrc++) {
|
||||||
|
src_address = LINES (src)[ysrc]+xsrc;
|
||||||
|
dst_address = LINES (dst)[ydst]+xbeg;
|
||||||
|
|
||||||
|
for (xdst=xbeg; xdst<=xend; xdst++) {
|
||||||
|
if (*src_address) {
|
||||||
|
if (color_map)
|
||||||
|
*dst_address = color_map->data[*src_address][*dst_address];
|
||||||
|
else
|
||||||
|
*dst_address = (*src_address);
|
||||||
|
}
|
||||||
|
|
||||||
|
dst_address++;
|
||||||
|
src_address++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void alleg_hline(Image *image, int x1, int y, int x2, int color)
|
||||||
|
{
|
||||||
|
hline(image->bmp, x1, y, x2, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void alleg_rectfill(Image *image, int x1, int y1, int x2, int y2, int color)
|
||||||
|
{
|
||||||
|
rectfill(image->bmp, x1, y1, x2, y2, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void alleg_to_allegro(const Image *image, BITMAP *bmp, int _x, int _y)
|
||||||
|
{
|
||||||
|
blit(image->bmp, bmp, 0, 0, _x, _y, image->w, image->h);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImageMethods alleg_methods =
|
||||||
|
{
|
||||||
|
alleg_init,
|
||||||
|
alleg_getpixel,
|
||||||
|
alleg_putpixel,
|
||||||
|
alleg_clear,
|
||||||
|
alleg_copy,
|
||||||
|
alleg_merge,
|
||||||
|
alleg_hline,
|
||||||
|
alleg_rectfill,
|
||||||
|
alleg_to_allegro,
|
||||||
|
};
|
@ -19,8 +19,8 @@
|
|||||||
#undef BYTES
|
#undef BYTES
|
||||||
#undef LINES
|
#undef LINES
|
||||||
|
|
||||||
#define BYTES(image) ((unsigned char *)image->dat)
|
#define BYTES(image) ((ase_uint8 *)image->dat)
|
||||||
#define LINES(image) ((unsigned char **)image->line)
|
#define LINES(image) ((ase_uint8 **)image->line)
|
||||||
|
|
||||||
#define BITMAP_HLINE(op) \
|
#define BITMAP_HLINE(op) \
|
||||||
for (x=x1; x<=x2; x++) { \
|
for (x=x1; x<=x2; x++) { \
|
||||||
@ -28,48 +28,47 @@
|
|||||||
_image_bitmap_next_bit(d, address); \
|
_image_bitmap_next_bit(d, address); \
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bitmap_regenerate_lines (Image *image)
|
static int bitmap_regenerate_lines(Image *image)
|
||||||
{
|
{
|
||||||
unsigned char *address = BYTES (image);
|
ase_uint8 *address = BYTES(image);
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
if (LINES (image))
|
if (LINES(image))
|
||||||
jfree (LINES (image));
|
jfree(LINES(image));
|
||||||
|
|
||||||
image->line = jmalloc (sizeof (unsigned char *) * image->h);
|
image->line = jmalloc(sizeof(ase_uint8 *) * image->h);
|
||||||
if (!LINES (image))
|
if (!LINES(image))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (y=0; y<image->h; y++) {
|
for (y=0; y<image->h; y++) {
|
||||||
LINES (image)[y] = address;
|
LINES(image)[y] = address;
|
||||||
address += (image->w+7)/8;
|
address += (image->w+7)/8;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bitmap_init (Image *image)
|
static int bitmap_init(Image *image)
|
||||||
{
|
{
|
||||||
image->dat = jmalloc (sizeof (unsigned char) *
|
image->dat = jmalloc(sizeof(ase_uint8) * ((image->w+7)/8) * image->h);
|
||||||
((image->w+7)/8) * image->h);
|
if (!BYTES(image))
|
||||||
if (!BYTES (image))
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (bitmap_regenerate_lines (image) < 0) {
|
if (bitmap_regenerate_lines(image) < 0) {
|
||||||
jfree (BYTES (image));
|
jfree(BYTES(image));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bitmap_getpixel (const Image *image, int x, int y)
|
static int bitmap_getpixel(const Image *image, int x, int y)
|
||||||
{
|
{
|
||||||
div_t d = div (x, 8);
|
div_t d = div (x, 8);
|
||||||
return ((*(LINES (image)[y]+d.quot)) & (1<<d.rem)) ? 1: 0;
|
return ((*(LINES (image)[y]+d.quot)) & (1<<d.rem)) ? 1: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bitmap_putpixel (Image *image, int x, int y, int color)
|
static void bitmap_putpixel(Image *image, int x, int y, int color)
|
||||||
{
|
{
|
||||||
div_t d = div (x, 8);
|
div_t d = div (x, 8);
|
||||||
|
|
||||||
@ -79,15 +78,15 @@ static void bitmap_putpixel (Image *image, int x, int y, int color)
|
|||||||
*(LINES (image)[y]+d.quot) &= ~(1<<d.rem);
|
*(LINES (image)[y]+d.quot) &= ~(1<<d.rem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bitmap_clear (Image *image, int color)
|
static void bitmap_clear(Image *image, int color)
|
||||||
{
|
{
|
||||||
memset (BYTES (image), color ? 0xff: 0x00, ((image->w+7)/8) * image->h);
|
memset(BYTES(image), color ? 0xff: 0x00, ((image->w+7)/8) * image->h);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bitmap_copy (Image *dst, const Image *src, int x, int y)
|
static void bitmap_copy(Image *dst, const Image *src, int x, int y)
|
||||||
{
|
{
|
||||||
unsigned char *src_address;
|
ase_uint8 *src_address;
|
||||||
unsigned char *dst_address;
|
ase_uint8 *dst_address;
|
||||||
int xbeg, xend, xsrc, xdst;
|
int xbeg, xend, xsrc, xdst;
|
||||||
int ybeg, yend, ysrc, ydst;
|
int ybeg, yend, ysrc, ydst;
|
||||||
div_t src_d, src_beg_d;
|
div_t src_d, src_beg_d;
|
||||||
@ -147,11 +146,11 @@ static void bitmap_copy (Image *dst, const Image *src, int x, int y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bitmap_merge (Image *dst, const Image *src,
|
static void bitmap_merge(Image *dst, const Image *src,
|
||||||
int x, int y, int opacity, int blend_mode)
|
int x, int y, int opacity, int blend_mode)
|
||||||
{
|
{
|
||||||
unsigned char *src_address;
|
ase_uint8 *src_address;
|
||||||
unsigned char *dst_address;
|
ase_uint8 *dst_address;
|
||||||
int xbeg, xend, xsrc, xdst;
|
int xbeg, xend, xsrc, xdst;
|
||||||
int ybeg, yend, ysrc, ydst;
|
int ybeg, yend, ysrc, ydst;
|
||||||
div_t src_d, src_beg_d;
|
div_t src_d, src_beg_d;
|
||||||
@ -209,9 +208,9 @@ static void bitmap_merge (Image *dst, const Image *src,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bitmap_hline (Image *image, int x1, int y, int x2, int color)
|
static void bitmap_hline(Image *image, int x1, int y, int x2, int color)
|
||||||
{
|
{
|
||||||
unsigned char *address;
|
ase_uint8 *address;
|
||||||
div_t d = div (x1, 8);
|
div_t d = div (x1, 8);
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
@ -225,9 +224,9 @@ static void bitmap_hline (Image *image, int x1, int y, int x2, int color)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bitmap_rectfill (Image *image, int x1, int y1, int x2, int y2, int color)
|
static void bitmap_rectfill(Image *image, int x1, int y1, int x2, int y2, int color)
|
||||||
{
|
{
|
||||||
unsigned char *address;
|
ase_uint8 *address;
|
||||||
div_t d, beg_d = div (x1, 8);
|
div_t d, beg_d = div (x1, 8);
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
@ -247,9 +246,9 @@ static void bitmap_rectfill (Image *image, int x1, int y1, int x2, int y2, int c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bitmap_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
|
static void bitmap_to_allegro(const Image *image, BITMAP *bmp, int _x, int _y)
|
||||||
{
|
{
|
||||||
unsigned char *address;
|
ase_uint8 *address;
|
||||||
unsigned long bmp_address;
|
unsigned long bmp_address;
|
||||||
int depth = bitmap_color_depth (bmp);
|
int depth = bitmap_color_depth (bmp);
|
||||||
div_t d, beg_d = div (0, 8);
|
div_t d, beg_d = div (0, 8);
|
||||||
@ -267,15 +266,15 @@ static void bitmap_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
|
|||||||
#ifdef GFX_MODEX
|
#ifdef GFX_MODEX
|
||||||
if (is_planar_bitmap (bmp)) {
|
if (is_planar_bitmap (bmp)) {
|
||||||
for (y=0; y<image->h; y++) {
|
for (y=0; y<image->h; y++) {
|
||||||
address = LINES (image)[y];
|
address = LINES(image)[y];
|
||||||
bmp_address = (unsigned long)bmp->line[_y];
|
bmp_address = (unsigned long)bmp->line[_y];
|
||||||
|
|
||||||
d = beg_d;
|
d = beg_d;
|
||||||
for (x=0; x<image->w; x++) {
|
for (x=0; x<image->w; x++) {
|
||||||
outportw (0x3C4, (0x100<<((_x+x)&3))|2);
|
outportw (0x3C4, (0x100<<((_x+x)&3))|2);
|
||||||
bmp_write8 (bmp_address+((_x+x)>>2),
|
bmp_write8(bmp_address+((_x+x)>>2),
|
||||||
color[((*address) & (1<<d.rem))? 1: 0]);
|
color[((*address) & (1<<d.rem))? 1: 0]);
|
||||||
_image_bitmap_next_bit (d, address);
|
_image_bitmap_next_bit(d, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
_y++;
|
_y++;
|
||||||
@ -285,12 +284,12 @@ static void bitmap_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
|
|||||||
#endif
|
#endif
|
||||||
for (y=0; y<image->h; y++) {
|
for (y=0; y<image->h; y++) {
|
||||||
address = LINES (image)[y];
|
address = LINES (image)[y];
|
||||||
bmp_address = bmp_write_line (bmp, _y)+_x;
|
bmp_address = bmp_write_line(bmp, _y)+_x;
|
||||||
|
|
||||||
d = beg_d;
|
d = beg_d;
|
||||||
for (x=0; x<image->w; x++) {
|
for (x=0; x<image->w; x++) {
|
||||||
bmp_write8 (bmp_address++, color[((*address) & (1<<d.rem))? 1: 0]);
|
bmp_write8 (bmp_address++, color[((*address) & (1<<d.rem))? 1: 0]);
|
||||||
_image_bitmap_next_bit (d, address);
|
_image_bitmap_next_bit(d, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
_y++;
|
_y++;
|
||||||
@ -301,20 +300,20 @@ static void bitmap_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 15:
|
case 15:
|
||||||
color[0] = makecol15 (0, 0, 0);
|
color[0] = makecol15(0, 0, 0);
|
||||||
color[1] = makecol15 (255, 255, 255);
|
color[1] = makecol15(255, 255, 255);
|
||||||
|
|
||||||
_x <<= 1;
|
_x <<= 1;
|
||||||
|
|
||||||
for (y=0; y<image->h; y++) {
|
for (y=0; y<image->h; y++) {
|
||||||
address = LINES (image)[y];
|
address = LINES (image)[y];
|
||||||
bmp_address = bmp_write_line (bmp, _y)+_x;
|
bmp_address = bmp_write_line(bmp, _y)+_x;
|
||||||
|
|
||||||
d = beg_d;
|
d = beg_d;
|
||||||
for (x=0; x<image->w; x++) {
|
for (x=0; x<image->w; x++) {
|
||||||
bmp_write15 (bmp_address, color[((*address) & (1<<d.rem))? 1: 0]);
|
bmp_write15(bmp_address, color[((*address) & (1<<d.rem))? 1: 0]);
|
||||||
bmp_address += 2;
|
bmp_address += 2;
|
||||||
_image_bitmap_next_bit (d, address);
|
_image_bitmap_next_bit(d, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
_y++;
|
_y++;
|
||||||
@ -322,20 +321,20 @@ static void bitmap_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 16:
|
case 16:
|
||||||
color[0] = makecol16 (0, 0, 0);
|
color[0] = makecol16(0, 0, 0);
|
||||||
color[1] = makecol16 (255, 255, 255);
|
color[1] = makecol16(255, 255, 255);
|
||||||
|
|
||||||
_x <<= 1;
|
_x <<= 1;
|
||||||
|
|
||||||
for (y=0; y<image->h; y++) {
|
for (y=0; y<image->h; y++) {
|
||||||
address = LINES (image)[y];
|
address = LINES (image)[y];
|
||||||
bmp_address = bmp_write_line (bmp, _y)+_x;
|
bmp_address = bmp_write_line(bmp, _y)+_x;
|
||||||
|
|
||||||
d = beg_d;
|
d = beg_d;
|
||||||
for (x=0; x<image->w; x++) {
|
for (x=0; x<image->w; x++) {
|
||||||
bmp_write16(bmp_address, color[((*address) & (1<<d.rem))? 1: 0]);
|
bmp_write16(bmp_address, color[((*address) & (1<<d.rem))? 1: 0]);
|
||||||
bmp_address += 2;
|
bmp_address += 2;
|
||||||
_image_bitmap_next_bit (d, address);
|
_image_bitmap_next_bit(d, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
_y++;
|
_y++;
|
||||||
|
@ -19,18 +19,18 @@
|
|||||||
#undef BYTES
|
#undef BYTES
|
||||||
#undef LINES
|
#undef LINES
|
||||||
|
|
||||||
#define BYTES(image) ((unsigned short *)image->dat)
|
#define BYTES(image) ((ase_uint16 *)image->dat)
|
||||||
#define LINES(image) ((unsigned short **)image->line)
|
#define LINES(image) ((ase_uint16 **)image->line)
|
||||||
|
|
||||||
static int grayscale_regenerate_lines (Image *image)
|
static int grayscale_regenerate_lines (Image *image)
|
||||||
{
|
{
|
||||||
unsigned short *address = BYTES (image);
|
ase_uint16 *address = BYTES (image);
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
if (LINES (image))
|
if (LINES (image))
|
||||||
jfree (LINES (image));
|
jfree (LINES (image));
|
||||||
|
|
||||||
image->line = jmalloc (sizeof (unsigned short *) * image->h);
|
image->line = jmalloc (sizeof (ase_uint16 *) * image->h);
|
||||||
if (!LINES (image))
|
if (!LINES (image))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ static int grayscale_regenerate_lines (Image *image)
|
|||||||
|
|
||||||
static int grayscale_init (Image *image)
|
static int grayscale_init (Image *image)
|
||||||
{
|
{
|
||||||
image->dat = jmalloc (sizeof (unsigned short) * image->w * image->h);
|
image->dat = jmalloc (sizeof (ase_uint16) * image->w * image->h);
|
||||||
if (!BYTES (image))
|
if (!BYTES (image))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ static void grayscale_putpixel (Image *image, int x, int y, int color)
|
|||||||
|
|
||||||
static void grayscale_clear (Image *image, int color)
|
static void grayscale_clear (Image *image, int color)
|
||||||
{
|
{
|
||||||
unsigned short *address = BYTES (image);
|
ase_uint16 *address = BYTES (image);
|
||||||
int c, size = image->w * image->h;
|
int c, size = image->w * image->h;
|
||||||
|
|
||||||
for (c=0; c<size; c++)
|
for (c=0; c<size; c++)
|
||||||
@ -77,8 +77,8 @@ static void grayscale_clear (Image *image, int color)
|
|||||||
|
|
||||||
static void grayscale_copy (Image *dst, const Image *src, int x, int y)
|
static void grayscale_copy (Image *dst, const Image *src, int x, int y)
|
||||||
{
|
{
|
||||||
unsigned short *src_address;
|
ase_uint16 *src_address;
|
||||||
unsigned short *dst_address;
|
ase_uint16 *dst_address;
|
||||||
int xbeg, xend, xsrc;
|
int xbeg, xend, xsrc;
|
||||||
int ybeg, yend, ysrc, ydst;
|
int ybeg, yend, ysrc, ydst;
|
||||||
int bytes;
|
int bytes;
|
||||||
@ -129,8 +129,8 @@ static void grayscale_merge (Image *dst, const Image *src,
|
|||||||
int x, int y, int opacity, int blend_mode)
|
int x, int y, int opacity, int blend_mode)
|
||||||
{
|
{
|
||||||
BLEND_COLOR blender = _graya_blenders[blend_mode];
|
BLEND_COLOR blender = _graya_blenders[blend_mode];
|
||||||
unsigned short *src_address;
|
ase_uint16 *src_address;
|
||||||
unsigned short *dst_address;
|
ase_uint16 *dst_address;
|
||||||
int xbeg, xend, xsrc, xdst;
|
int xbeg, xend, xsrc, xdst;
|
||||||
int ybeg, yend, ysrc, ydst;
|
int ybeg, yend, ysrc, ydst;
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ static void grayscale_merge (Image *dst, const Image *src,
|
|||||||
|
|
||||||
static void grayscale_hline (Image *image, int x1, int y, int x2, int color)
|
static void grayscale_hline (Image *image, int x1, int y, int x2, int color)
|
||||||
{
|
{
|
||||||
unsigned short *address = LINES (image)[y]+x1;
|
ase_uint16 *address = LINES (image)[y]+x1;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
for (x=x1; x<=x2; x++)
|
for (x=x1; x<=x2; x++)
|
||||||
@ -194,7 +194,7 @@ static void grayscale_hline (Image *image, int x1, int y, int x2, int color)
|
|||||||
|
|
||||||
static void grayscale_rectfill (Image *image, int x1, int y1, int x2, int y2, int color)
|
static void grayscale_rectfill (Image *image, int x1, int y1, int x2, int y2, int color)
|
||||||
{
|
{
|
||||||
unsigned short *address;
|
ase_uint16 *address;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
for (y=y1; y<=y2; y++) {
|
for (y=y1; y<=y2; y++) {
|
||||||
@ -204,11 +204,11 @@ static void grayscale_rectfill (Image *image, int x1, int y1, int x2, int y2, in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void grayscale_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
|
static void grayscale_to_allegro(const Image *image, BITMAP *bmp, int _x, int _y)
|
||||||
{
|
{
|
||||||
unsigned short *address = BYTES (image);
|
ase_uint16 *address = BYTES(image);
|
||||||
unsigned long bmp_address;
|
unsigned long bmp_address;
|
||||||
int depth = bitmap_color_depth (bmp);
|
int depth = bitmap_color_depth(bmp);
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
bmp_select (bmp);
|
bmp_select (bmp);
|
||||||
@ -217,14 +217,14 @@ static void grayscale_to_allegro (const Image *image, BITMAP *bmp, int _x, int _
|
|||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
#ifdef GFX_MODEX
|
#ifdef GFX_MODEX
|
||||||
if (is_planar_bitmap (bmp)) {
|
if (is_planar_bitmap(bmp)) {
|
||||||
for (y=0; y<image->h; y++) {
|
for (y=0; y<image->h; y++) {
|
||||||
bmp_address = (unsigned long)bmp->line[_y];
|
bmp_address = (unsigned long)bmp->line[_y];
|
||||||
|
|
||||||
for (x=0; x<image->w; x++) {
|
for (x=0; x<image->w; x++) {
|
||||||
outportw (0x3C4, (0x100<<((_x+x)&3))|2);
|
outportw(0x3C4, (0x100<<((_x+x)&3))|2);
|
||||||
bmp_write8 (bmp_address+((_x+x)>>2),
|
bmp_write8(bmp_address+((_x+x)>>2),
|
||||||
_index_cmap[(*address) & 0xff]);
|
_index_cmap[(*address) & 0xff]);
|
||||||
address++;
|
address++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,18 +19,18 @@
|
|||||||
#undef BYTES
|
#undef BYTES
|
||||||
#undef LINES
|
#undef LINES
|
||||||
|
|
||||||
#define BYTES(image) ((unsigned char *)image->dat)
|
#define BYTES(image) ((ase_uint8 *)image->dat)
|
||||||
#define LINES(image) ((unsigned char **)image->line)
|
#define LINES(image) ((ase_uint8 **)image->line)
|
||||||
|
|
||||||
static int indexed_regenerate_lines(Image *image)
|
static int indexed_regenerate_lines(Image *image)
|
||||||
{
|
{
|
||||||
unsigned char *address = BYTES(image);
|
ase_uint8 *address = BYTES(image);
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
if (LINES(image))
|
if (LINES(image))
|
||||||
jfree(LINES(image));
|
jfree(LINES(image));
|
||||||
|
|
||||||
image->line = jmalloc(sizeof(unsigned char *) * image->h);
|
image->line = jmalloc(sizeof(ase_uint8 *) * image->h);
|
||||||
if (!LINES(image))
|
if (!LINES(image))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ static int indexed_regenerate_lines(Image *image)
|
|||||||
|
|
||||||
static int indexed_init(Image *image)
|
static int indexed_init(Image *image)
|
||||||
{
|
{
|
||||||
image->dat = jmalloc(sizeof(unsigned char) * image->w * image->h);
|
image->dat = jmalloc(sizeof(ase_uint8) * image->w * image->h);
|
||||||
if (!BYTES(image))
|
if (!BYTES(image))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -73,8 +73,8 @@ static void indexed_clear(Image *image, int color)
|
|||||||
|
|
||||||
static void indexed_copy(Image *dst, const Image *src, int x, int y)
|
static void indexed_copy(Image *dst, const Image *src, int x, int y)
|
||||||
{
|
{
|
||||||
unsigned char *src_address;
|
ase_uint8 *src_address;
|
||||||
unsigned char *dst_address;
|
ase_uint8 *dst_address;
|
||||||
int xbeg, xend, xsrc;
|
int xbeg, xend, xsrc;
|
||||||
int ybeg, yend, ysrc, ydst;
|
int ybeg, yend, ysrc, ydst;
|
||||||
int bytes;
|
int bytes;
|
||||||
@ -117,7 +117,7 @@ static void indexed_copy(Image *dst, const Image *src, int x, int y)
|
|||||||
src_address = LINES (src)[ysrc]+xsrc;
|
src_address = LINES (src)[ysrc]+xsrc;
|
||||||
dst_address = LINES (dst)[ydst]+xbeg;
|
dst_address = LINES (dst)[ydst]+xbeg;
|
||||||
|
|
||||||
memcpy (dst_address, src_address, bytes);
|
memcpy(dst_address, src_address, bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,8 +126,8 @@ static void indexed_copy(Image *dst, const Image *src, int x, int y)
|
|||||||
static void indexed_merge(Image *dst, const Image *src,
|
static void indexed_merge(Image *dst, const Image *src,
|
||||||
int x, int y, int opacity, int blend_mode)
|
int x, int y, int opacity, int blend_mode)
|
||||||
{
|
{
|
||||||
unsigned char *src_address;
|
ase_uint8 *src_address;
|
||||||
unsigned char *dst_address;
|
ase_uint8 *dst_address;
|
||||||
int xbeg, xend, xsrc, xdst;
|
int xbeg, xend, xsrc, xdst;
|
||||||
int ybeg, yend, ysrc, ydst;
|
int ybeg, yend, ysrc, ydst;
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ static void indexed_merge(Image *dst, const Image *src,
|
|||||||
|
|
||||||
static void indexed_hline(Image *image, int x1, int y, int x2, int color)
|
static void indexed_hline(Image *image, int x1, int y, int x2, int color)
|
||||||
{
|
{
|
||||||
memset (LINES (image)[y]+x1, color, x2-x1+1);
|
memset(LINES(image)[y]+x1, color, x2-x1+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void indexed_rectfill(Image *image, int x1, int y1, int x2, int y2, int color)
|
static void indexed_rectfill(Image *image, int x1, int y1, int x2, int y2, int color)
|
||||||
@ -208,7 +208,7 @@ static void indexed_rectfill(Image *image, int x1, int y1, int x2, int y2, int c
|
|||||||
int y, bytes = x2-x1+1;
|
int y, bytes = x2-x1+1;
|
||||||
|
|
||||||
for (y=y1; y<=y2; y++)
|
for (y=y1; y<=y2; y++)
|
||||||
memset (LINES (image)[y]+x1, color, bytes);
|
memset(LINES(image)[y]+x1, color, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void indexed_to_allegro(const Image *image, BITMAP *bmp, int _x, int _y)
|
static void indexed_to_allegro(const Image *image, BITMAP *bmp, int _x, int _y)
|
||||||
@ -218,12 +218,12 @@ static void indexed_to_allegro(const Image *image, BITMAP *bmp, int _x, int _y)
|
|||||||
_rgb_scale_6[_current_palette[_index_cmap[(*address)]].g], \
|
_rgb_scale_6[_current_palette[_index_cmap[(*address)]].g], \
|
||||||
_rgb_scale_6[_current_palette[_index_cmap[(*address)]].b]
|
_rgb_scale_6[_current_palette[_index_cmap[(*address)]].b]
|
||||||
|
|
||||||
unsigned char *address = BYTES (image);
|
ase_uint8 *address = BYTES(image);
|
||||||
unsigned long bmp_address;
|
unsigned long bmp_address;
|
||||||
int depth = bitmap_color_depth (bmp);
|
int depth = bitmap_color_depth(bmp);
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
bmp_select (bmp);
|
bmp_select(bmp);
|
||||||
|
|
||||||
switch (depth) {
|
switch (depth) {
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ static void indexed_to_allegro(const Image *image, BITMAP *bmp, int _x, int _y)
|
|||||||
bmp_address = bmp_write_line(bmp, _y)+_x;
|
bmp_address = bmp_write_line(bmp, _y)+_x;
|
||||||
|
|
||||||
for (x=0; x<image->w; x++) {
|
for (x=0; x<image->w; x++) {
|
||||||
bmp_write15(bmp_address, makecol15 (RGB_TRIPLET));
|
bmp_write15(bmp_address, makecol15(RGB_TRIPLET));
|
||||||
address++;
|
address++;
|
||||||
bmp_address += 2;
|
bmp_address += 2;
|
||||||
}
|
}
|
||||||
@ -283,7 +283,7 @@ static void indexed_to_allegro(const Image *image, BITMAP *bmp, int _x, int _y)
|
|||||||
bmp_address = bmp_write_line(bmp, _y)+_x;
|
bmp_address = bmp_write_line(bmp, _y)+_x;
|
||||||
|
|
||||||
for (x=0; x<image->w; x++) {
|
for (x=0; x<image->w; x++) {
|
||||||
bmp_write16(bmp_address, makecol16 (RGB_TRIPLET));
|
bmp_write16(bmp_address, makecol16(RGB_TRIPLET));
|
||||||
address++;
|
address++;
|
||||||
bmp_address += 2;
|
bmp_address += 2;
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ static void indexed_to_allegro(const Image *image, BITMAP *bmp, int _x, int _y)
|
|||||||
bmp_address = bmp_write_line(bmp, _y)+_x;
|
bmp_address = bmp_write_line(bmp, _y)+_x;
|
||||||
|
|
||||||
for (x=0; x<image->w; x++) {
|
for (x=0; x<image->w; x++) {
|
||||||
bmp_write24(bmp_address, makecol24 (RGB_TRIPLET));
|
bmp_write24(bmp_address, makecol24(RGB_TRIPLET));
|
||||||
address++;
|
address++;
|
||||||
bmp_address += 3;
|
bmp_address += 3;
|
||||||
}
|
}
|
||||||
@ -312,10 +312,10 @@ static void indexed_to_allegro(const Image *image, BITMAP *bmp, int _x, int _y)
|
|||||||
_x <<= 2;
|
_x <<= 2;
|
||||||
|
|
||||||
for (y=0; y<image->h; y++) {
|
for (y=0; y<image->h; y++) {
|
||||||
bmp_address = bmp_write_line (bmp, _y)+_x;
|
bmp_address = bmp_write_line(bmp, _y)+_x;
|
||||||
|
|
||||||
for (x=0; x<image->w; x++) {
|
for (x=0; x<image->w; x++) {
|
||||||
bmp_write32(bmp_address, makeacol32 (RGB_TRIPLET, 255));
|
bmp_write32(bmp_address, makeacol32(RGB_TRIPLET, 255));
|
||||||
address++;
|
address++;
|
||||||
bmp_address += 4;
|
bmp_address += 4;
|
||||||
}
|
}
|
||||||
|
@ -19,18 +19,18 @@
|
|||||||
#undef BYTES
|
#undef BYTES
|
||||||
#undef LINES
|
#undef LINES
|
||||||
|
|
||||||
#define BYTES(image) ((unsigned long *)image->dat)
|
#define BYTES(image) ((ase_uint32 *)image->dat)
|
||||||
#define LINES(image) ((unsigned long **)image->line)
|
#define LINES(image) ((ase_uint32 **)image->line)
|
||||||
|
|
||||||
static int rgb_regenerate_lines (Image *image)
|
static int rgb_regenerate_lines (Image *image)
|
||||||
{
|
{
|
||||||
unsigned long *address = BYTES (image);
|
ase_uint32 *address = BYTES (image);
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
if (LINES (image))
|
if (LINES (image))
|
||||||
jfree (LINES (image));
|
jfree (LINES (image));
|
||||||
|
|
||||||
image->line = jmalloc (sizeof (unsigned long *) * image->h);
|
image->line = jmalloc(sizeof(ase_uint32 *) * image->h);
|
||||||
if (!LINES (image))
|
if (!LINES (image))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ static int rgb_regenerate_lines (Image *image)
|
|||||||
|
|
||||||
static int rgb_init (Image *image)
|
static int rgb_init (Image *image)
|
||||||
{
|
{
|
||||||
image->dat = jmalloc (sizeof (unsigned long) * image->w * image->h);
|
image->dat = jmalloc(sizeof(ase_uint32) * image->w * image->h);
|
||||||
if (!BYTES (image))
|
if (!BYTES (image))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -68,17 +68,17 @@ static void rgb_putpixel (Image *image, int x, int y, int color)
|
|||||||
|
|
||||||
static void rgb_clear (Image *image, int color)
|
static void rgb_clear (Image *image, int color)
|
||||||
{
|
{
|
||||||
unsigned long *address = BYTES (image);
|
ase_uint32 *address = BYTES (image);
|
||||||
unsigned int c, size = image->w * image->h;
|
unsigned int c, size = image->w * image->h;
|
||||||
|
|
||||||
for (c=0; c<size; c++)
|
for (c=0; c<size; c++)
|
||||||
*(address++) = color;
|
*(address++) = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rgb_copy (Image *dst, const Image *src, int x, int y)
|
static void rgb_copy(Image *dst, const Image *src, int x, int y)
|
||||||
{
|
{
|
||||||
unsigned long *src_address;
|
ase_uint32 *src_address;
|
||||||
unsigned long *dst_address;
|
ase_uint32 *dst_address;
|
||||||
int xbeg, xend, xsrc;
|
int xbeg, xend, xsrc;
|
||||||
int ybeg, yend, ysrc, ydst;
|
int ybeg, yend, ysrc, ydst;
|
||||||
int bytes;
|
int bytes;
|
||||||
@ -129,8 +129,8 @@ static void rgb_merge (Image *dst, const Image *src,
|
|||||||
int x, int y, int opacity, int blend_mode)
|
int x, int y, int opacity, int blend_mode)
|
||||||
{
|
{
|
||||||
BLEND_COLOR blender = _rgba_blenders[blend_mode];
|
BLEND_COLOR blender = _rgba_blenders[blend_mode];
|
||||||
unsigned long *src_address;
|
ase_uint32 *src_address;
|
||||||
unsigned long *dst_address;
|
ase_uint32 *dst_address;
|
||||||
int xbeg, xend, xsrc, xdst;
|
int xbeg, xend, xsrc, xdst;
|
||||||
int ybeg, yend, ysrc, ydst;
|
int ybeg, yend, ysrc, ydst;
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ static void rgb_merge (Image *dst, const Image *src,
|
|||||||
|
|
||||||
static void rgb_hline (Image *image, int x1, int y, int x2, int color)
|
static void rgb_hline (Image *image, int x1, int y, int x2, int color)
|
||||||
{
|
{
|
||||||
unsigned long *address = LINES (image)[y]+x1;
|
ase_uint32 *address = LINES (image)[y]+x1;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
for (x=x1; x<=x2; x++)
|
for (x=x1; x<=x2; x++)
|
||||||
@ -194,7 +194,7 @@ static void rgb_hline (Image *image, int x1, int y, int x2, int color)
|
|||||||
|
|
||||||
static void rgb_rectfill (Image *image, int x1, int y1, int x2, int y2, int color)
|
static void rgb_rectfill (Image *image, int x1, int y1, int x2, int y2, int color)
|
||||||
{
|
{
|
||||||
unsigned long *address;
|
ase_uint32 *address;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
for (y=y1; y<=y2; y++) {
|
for (y=y1; y<=y2; y++) {
|
||||||
@ -206,9 +206,9 @@ static void rgb_rectfill (Image *image, int x1, int y1, int x2, int y2, int colo
|
|||||||
|
|
||||||
static void rgb_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
|
static void rgb_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
|
||||||
{
|
{
|
||||||
unsigned long *address = BYTES (image);
|
ase_uint32 *address = BYTES(image);
|
||||||
unsigned long bmp_address;
|
unsigned long bmp_address;
|
||||||
int depth = bitmap_color_depth (bmp);
|
int depth = bitmap_color_depth(bmp);
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
bmp_select (bmp);
|
bmp_select (bmp);
|
||||||
@ -222,11 +222,11 @@ static void rgb_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
|
|||||||
bmp_address = (unsigned long)bmp->line[_y];
|
bmp_address = (unsigned long)bmp->line[_y];
|
||||||
|
|
||||||
for (x=0; x<image->w; x++) {
|
for (x=0; x<image->w; x++) {
|
||||||
outportw (0x3C4, (0x100<<((_x+x)&3))|2);
|
outportw(0x3C4, (0x100<<((_x+x)&3))|2);
|
||||||
bmp_write8 (bmp_address+((_x+x)>>2),
|
bmp_write8(bmp_address+((_x+x)>>2),
|
||||||
makecol8 ((*address) & 0xff,
|
makecol8((*address) & 0xff,
|
||||||
((*address)>>8) & 0xff,
|
((*address)>>8) & 0xff,
|
||||||
((*address)>>16) & 0xff));
|
((*address)>>16) & 0xff));
|
||||||
address++;
|
address++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,13 +236,13 @@ static void rgb_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
|
|||||||
else {
|
else {
|
||||||
#endif
|
#endif
|
||||||
for (y=0; y<image->h; y++) {
|
for (y=0; y<image->h; y++) {
|
||||||
bmp_address = bmp_write_line (bmp, _y)+_x;
|
bmp_address = bmp_write_line(bmp, _y)+_x;
|
||||||
|
|
||||||
for (x=0; x<image->w; x++) {
|
for (x=0; x<image->w; x++) {
|
||||||
bmp_write8 (bmp_address,
|
bmp_write8(bmp_address,
|
||||||
makecol8 ((*address) & 0xff,
|
makecol8((*address) & 0xff,
|
||||||
((*address)>>8) & 0xff,
|
((*address)>>8) & 0xff,
|
||||||
((*address)>>16) & 0xff));
|
((*address)>>16) & 0xff));
|
||||||
address++;
|
address++;
|
||||||
bmp_address++;
|
bmp_address++;
|
||||||
}
|
}
|
||||||
@ -258,13 +258,13 @@ static void rgb_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
|
|||||||
_x <<= 1;
|
_x <<= 1;
|
||||||
|
|
||||||
for (y=0; y<image->h; y++) {
|
for (y=0; y<image->h; y++) {
|
||||||
bmp_address = bmp_write_line (bmp, _y)+_x;
|
bmp_address = bmp_write_line(bmp, _y)+_x;
|
||||||
|
|
||||||
for (x=0; x<image->w; x++) {
|
for (x=0; x<image->w; x++) {
|
||||||
bmp_write15 (bmp_address,
|
bmp_write15(bmp_address,
|
||||||
makecol15 ((*address) & 0xff,
|
makecol15((*address) & 0xff,
|
||||||
((*address)>>8) & 0xff,
|
((*address)>>8) & 0xff,
|
||||||
((*address)>>16) & 0xff));
|
((*address)>>16) & 0xff));
|
||||||
address++;
|
address++;
|
||||||
bmp_address += 2;
|
bmp_address += 2;
|
||||||
}
|
}
|
||||||
@ -280,10 +280,10 @@ static void rgb_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
|
|||||||
bmp_address = bmp_write_line (bmp, _y)+_x;
|
bmp_address = bmp_write_line (bmp, _y)+_x;
|
||||||
|
|
||||||
for (x=0; x<image->w; x++) {
|
for (x=0; x<image->w; x++) {
|
||||||
bmp_write16 (bmp_address,
|
bmp_write16(bmp_address,
|
||||||
makecol16 ((*address) & 0xff,
|
makecol16((*address) & 0xff,
|
||||||
((*address)>>8) & 0xff,
|
((*address)>>8) & 0xff,
|
||||||
((*address)>>16) & 0xff));
|
((*address)>>16) & 0xff));
|
||||||
address++;
|
address++;
|
||||||
bmp_address += 2;
|
bmp_address += 2;
|
||||||
}
|
}
|
||||||
@ -299,10 +299,10 @@ static void rgb_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
|
|||||||
bmp_address = bmp_write_line (bmp, _y)+_x;
|
bmp_address = bmp_write_line (bmp, _y)+_x;
|
||||||
|
|
||||||
for (x=0; x<image->w; x++) {
|
for (x=0; x<image->w; x++) {
|
||||||
bmp_write24 (bmp_address,
|
bmp_write24(bmp_address,
|
||||||
makecol24 ((*address) & 0xff,
|
makecol24((*address) & 0xff,
|
||||||
((*address)>>8) & 0xff,
|
((*address)>>8) & 0xff,
|
||||||
((*address)>>16) & 0xff));
|
((*address)>>16) & 0xff));
|
||||||
address++;
|
address++;
|
||||||
bmp_address += 3;
|
bmp_address += 3;
|
||||||
}
|
}
|
||||||
@ -318,11 +318,11 @@ static void rgb_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
|
|||||||
bmp_address = bmp_write_line (bmp, _y)+_x;
|
bmp_address = bmp_write_line (bmp, _y)+_x;
|
||||||
|
|
||||||
for (x=0; x<image->w; x++) {
|
for (x=0; x<image->w; x++) {
|
||||||
bmp_write32 (bmp_address,
|
bmp_write32(bmp_address,
|
||||||
makeacol32 ((*address) & 0xff,
|
makeacol32((*address) & 0xff,
|
||||||
((*address)>>8) & 0xff,
|
((*address)>>8) & 0xff,
|
||||||
((*address)>>16) & 0xff,
|
((*address)>>16) & 0xff,
|
||||||
((*address)>>24) & 0xff));
|
((*address)>>24) & 0xff));
|
||||||
address++;
|
address++;
|
||||||
bmp_address += 4;
|
bmp_address += 4;
|
||||||
}
|
}
|
||||||
|
@ -117,16 +117,16 @@ void mask_none (Mask *mask)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mask_invert (Mask *mask)
|
void mask_invert(Mask *mask)
|
||||||
{
|
{
|
||||||
if (mask->bitmap) {
|
if (mask->bitmap) {
|
||||||
unsigned char *address;
|
ase_uint8 *address;
|
||||||
int u, v;
|
int u, v;
|
||||||
div_t d;
|
div_t d;
|
||||||
|
|
||||||
for (v=0; v<mask->h; v++) {
|
for (v=0; v<mask->h; v++) {
|
||||||
d.quot = d.rem = 0;
|
d.quot = d.rem = 0;
|
||||||
address = ((unsigned char **)mask->bitmap->line)[v];
|
address = ((ase_uint8 **)mask->bitmap->line)[v];
|
||||||
for (u=0; u<mask->w; u++) {
|
for (u=0; u<mask->w; u++) {
|
||||||
*address ^= (1<<d.rem);
|
*address ^= (1<<d.rem);
|
||||||
_image_bitmap_next_bit (d, address);
|
_image_bitmap_next_bit (d, address);
|
||||||
@ -219,42 +219,42 @@ void mask_merge (Mask *mask, const Mask *src)
|
|||||||
/* TODO!!! */
|
/* TODO!!! */
|
||||||
}
|
}
|
||||||
|
|
||||||
void mask_by_color (Mask *mask, const Image *src, int color, int fuzziness)
|
void mask_by_color(Mask *mask, const Image *src, int color, int fuzziness)
|
||||||
{
|
{
|
||||||
Image *dst;
|
Image *dst;
|
||||||
|
|
||||||
mask_replace (mask, 0, 0, src->w, src->h);
|
mask_replace(mask, 0, 0, src->w, src->h);
|
||||||
|
|
||||||
dst = mask->bitmap;
|
dst = mask->bitmap;
|
||||||
|
|
||||||
switch (src->imgtype) {
|
switch (src->imgtype) {
|
||||||
|
|
||||||
case IMAGE_RGB: {
|
case IMAGE_RGB: {
|
||||||
unsigned long *src_address;
|
ase_uint32 *src_address;
|
||||||
unsigned char *dst_address;
|
ase_uint8 *dst_address;
|
||||||
int src_r, src_g, src_b, src_a;
|
int src_r, src_g, src_b, src_a;
|
||||||
int dst_r, dst_g, dst_b, dst_a;
|
int dst_r, dst_g, dst_b, dst_a;
|
||||||
int u, v, c;
|
int u, v, c;
|
||||||
div_t d;
|
div_t d;
|
||||||
|
|
||||||
dst_r = _rgba_getr (color);
|
dst_r = _rgba_getr(color);
|
||||||
dst_g = _rgba_getg (color);
|
dst_g = _rgba_getg(color);
|
||||||
dst_b = _rgba_getb (color);
|
dst_b = _rgba_getb(color);
|
||||||
dst_a = _rgba_geta (color);
|
dst_a = _rgba_geta(color);
|
||||||
|
|
||||||
for (v=0; v<src->h; v++) {
|
for (v=0; v<src->h; v++) {
|
||||||
src_address = ((unsigned long **)src->line)[v];
|
src_address = ((ase_uint32 **)src->line)[v];
|
||||||
dst_address = ((unsigned char **)dst->line)[v];
|
dst_address = ((ase_uint8 **)dst->line)[v];
|
||||||
|
|
||||||
d = div (0, 8);
|
d = div (0, 8);
|
||||||
|
|
||||||
for (u=0; u<src->w; u++) {
|
for (u=0; u<src->w; u++) {
|
||||||
c = *(src_address++);
|
c = *(src_address++);
|
||||||
|
|
||||||
src_r = _rgba_getr (c);
|
src_r = _rgba_getr(c);
|
||||||
src_g = _rgba_getg (c);
|
src_g = _rgba_getg(c);
|
||||||
src_b = _rgba_getb (c);
|
src_b = _rgba_getb(c);
|
||||||
src_a = _rgba_geta (c);
|
src_a = _rgba_geta(c);
|
||||||
|
|
||||||
if (!((src_r >= dst_r-fuzziness) && (src_r <= dst_r+fuzziness) &&
|
if (!((src_r >= dst_r-fuzziness) && (src_r <= dst_r+fuzziness) &&
|
||||||
(src_g >= dst_g-fuzziness) && (src_g <= dst_g+fuzziness) &&
|
(src_g >= dst_g-fuzziness) && (src_g <= dst_g+fuzziness) &&
|
||||||
@ -262,25 +262,25 @@ void mask_by_color (Mask *mask, const Image *src, int color, int fuzziness)
|
|||||||
(src_a >= dst_a-fuzziness) && (src_a <= dst_a+fuzziness)))
|
(src_a >= dst_a-fuzziness) && (src_a <= dst_a+fuzziness)))
|
||||||
(*dst_address) ^= (1 << d.rem);
|
(*dst_address) ^= (1 << d.rem);
|
||||||
|
|
||||||
_image_bitmap_next_bit (d, dst_address);
|
_image_bitmap_next_bit(d, dst_address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case IMAGE_GRAYSCALE: {
|
case IMAGE_GRAYSCALE: {
|
||||||
unsigned short *src_address;
|
ase_uint16 *src_address;
|
||||||
unsigned char *dst_address;
|
ase_uint8 *dst_address;
|
||||||
int src_k, src_a;
|
int src_k, src_a;
|
||||||
int dst_k, dst_a;
|
int dst_k, dst_a;
|
||||||
int u, v, c;
|
int u, v, c;
|
||||||
div_t d;
|
div_t d;
|
||||||
|
|
||||||
dst_k = _graya_getk (color);
|
dst_k = _graya_getk(color);
|
||||||
dst_a = _graya_geta (color);
|
dst_a = _graya_geta(color);
|
||||||
|
|
||||||
for (v=0; v<src->h; v++) {
|
for (v=0; v<src->h; v++) {
|
||||||
src_address = ((unsigned short **)src->line)[v];
|
src_address = ((ase_uint16 **)src->line)[v];
|
||||||
dst_address = ((unsigned char **)dst->line)[v];
|
dst_address = ((ase_uint8 **)dst->line)[v];
|
||||||
|
|
||||||
d = div (0, 8);
|
d = div (0, 8);
|
||||||
|
|
||||||
@ -294,20 +294,20 @@ void mask_by_color (Mask *mask, const Image *src, int color, int fuzziness)
|
|||||||
(src_a >= dst_a-fuzziness) && (src_a <= dst_a+fuzziness)))
|
(src_a >= dst_a-fuzziness) && (src_a <= dst_a+fuzziness)))
|
||||||
(*dst_address) ^= (1 << d.rem);
|
(*dst_address) ^= (1 << d.rem);
|
||||||
|
|
||||||
_image_bitmap_next_bit (d, dst_address);
|
_image_bitmap_next_bit(d, dst_address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case IMAGE_INDEXED: {
|
case IMAGE_INDEXED: {
|
||||||
unsigned char *src_address;
|
ase_uint8 *src_address;
|
||||||
unsigned char *dst_address;
|
ase_uint8 *dst_address;
|
||||||
int u, v, c;
|
int u, v, c;
|
||||||
div_t d;
|
div_t d;
|
||||||
|
|
||||||
for (v=0; v<src->h; v++) {
|
for (v=0; v<src->h; v++) {
|
||||||
src_address = ((unsigned char **)src->line)[v];
|
src_address = ((ase_uint8 **)src->line)[v];
|
||||||
dst_address = ((unsigned char **)dst->line)[v];
|
dst_address = ((ase_uint8 **)dst->line)[v];
|
||||||
|
|
||||||
d = div (0, 8);
|
d = div (0, 8);
|
||||||
|
|
||||||
@ -317,25 +317,25 @@ void mask_by_color (Mask *mask, const Image *src, int color, int fuzziness)
|
|||||||
if (!((c >= color-fuzziness) && (c <= color+fuzziness)))
|
if (!((c >= color-fuzziness) && (c <= color+fuzziness)))
|
||||||
(*dst_address) ^= (1 << d.rem);
|
(*dst_address) ^= (1 << d.rem);
|
||||||
|
|
||||||
_image_bitmap_next_bit (d, dst_address);
|
_image_bitmap_next_bit(d, dst_address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
shrink_mask (mask);
|
shrink_mask(mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* void mask_fill (Mask *mask, Image *image, int color) */
|
/* void mask_fill (Mask *mask, Image *image, int color) */
|
||||||
/* { */
|
/* { */
|
||||||
/* if (mask) { */
|
/* if (mask) { */
|
||||||
/* unsigned char *address; */
|
/* ase_uint8 *address; */
|
||||||
/* int u, v; */
|
/* int u, v; */
|
||||||
/* div_t d; */
|
/* div_t d; */
|
||||||
|
|
||||||
/* for (v=0; v<h; v++) { */
|
/* for (v=0; v<h; v++) { */
|
||||||
/* d = div (0, 8); */
|
/* d = div (0, 8); */
|
||||||
/* address = ((unsigned char **)drawable->lines)[v]+d.quot; */
|
/* address = ((ase_uint8 **)drawable->lines)[v]+d.quot; */
|
||||||
|
|
||||||
/* for (u=0; u<w; u++) { */
|
/* for (u=0; u<w; u++) { */
|
||||||
/* if ((*address) & (1<<d.rem)) */
|
/* if ((*address) & (1<<d.rem)) */
|
||||||
|
@ -232,16 +232,16 @@ typedef struct _ArtBitmapSVPData ArtBitmapSVPData;
|
|||||||
struct _ArtBitmapSVPData
|
struct _ArtBitmapSVPData
|
||||||
{
|
{
|
||||||
Image *image;
|
Image *image;
|
||||||
unsigned char *address;
|
ase_uint8 *address;
|
||||||
int shift;
|
int shift;
|
||||||
int x0, x1;
|
int x0, x1;
|
||||||
int color;
|
int color;
|
||||||
void (*hline) (Image *image, int x1, int y, int x2, int c1, int c2);
|
void (*hline) (Image *image, int x1, int y, int x2, int c1, int c2);
|
||||||
};
|
};
|
||||||
|
|
||||||
static void blend_rgb_hline (Image *image, int x1, int y, int x2, int rgb, int a)
|
static void blend_rgb_hline(Image *image, int x1, int y, int x2, int rgb, int a)
|
||||||
{
|
{
|
||||||
unsigned long *address = ((unsigned long **)image->line)[y]+x1;
|
ase_uint32 *address = ((ase_uint32 **)image->line)[y]+x1;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
for (x=x1; x<=x2; x++) {
|
for (x=x1; x<=x2; x++) {
|
||||||
@ -250,9 +250,9 @@ static void blend_rgb_hline (Image *image, int x1, int y, int x2, int rgb, int a
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void blend_grayscale_hline (Image *image, int x1, int y, int x2, int k, int a)
|
static void blend_grayscale_hline(Image *image, int x1, int y, int x2, int k, int a)
|
||||||
{
|
{
|
||||||
unsigned short *address = ((unsigned short **)image->line)[y]+x1;
|
ase_uint16 *address = ((ase_uint16 **)image->line)[y]+x1;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
for (x=x1; x<=x2; x++) {
|
for (x=x1; x<=x2; x++) {
|
||||||
@ -261,9 +261,9 @@ static void blend_grayscale_hline (Image *image, int x1, int y, int x2, int k, i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void blend_indexed_hline (Image *image, int x1, int y, int x2, int i, int a)
|
static void blend_indexed_hline(Image *image, int x1, int y, int x2, int i, int a)
|
||||||
{
|
{
|
||||||
unsigned char *address = ((unsigned char **)image->line)[y]+x1;
|
ase_uint8 *address = ((ase_uint8 **)image->line)[y]+x1;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
if (a > 128)
|
if (a > 128)
|
||||||
@ -367,7 +367,7 @@ static void art_image_svp_aa (const ArtSVP *svp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
data.image = image;
|
data.image = image;
|
||||||
data.address = ((unsigned char *)image->line[y0]) + (x0<<data.shift);
|
data.address = ((ase_uint8 *)image->line[y0]) + (x0<<data.shift);
|
||||||
data.x0 = x0;
|
data.x0 = x0;
|
||||||
data.x1 = x1+1;
|
data.x1 = x1+1;
|
||||||
data.color = color;
|
data.color = color;
|
||||||
|
@ -26,14 +26,14 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Image *image_set_imgtype (Image *image, int imgtype,
|
Image *image_set_imgtype(Image *image, int imgtype,
|
||||||
int dithering_method,
|
int dithering_method,
|
||||||
RGB_MAP *rgb_map,
|
RGB_MAP *rgb_map,
|
||||||
RGB *palette)
|
RGB *palette)
|
||||||
{
|
{
|
||||||
unsigned long *rgb_address;
|
ase_uint32 *rgb_address;
|
||||||
unsigned short *gray_address;
|
ase_uint16 *gray_address;
|
||||||
unsigned char *idx_address;
|
ase_uint8 *idx_address;
|
||||||
int i, c, r, g, b, size;
|
int i, c, r, g, b, size;
|
||||||
Image *new_image;
|
Image *new_image;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ Image *image_set_imgtype (Image *image, int imgtype,
|
|||||||
dithering_method == DITHERING_ORDERED)
|
dithering_method == DITHERING_ORDERED)
|
||||||
return image_rgb_to_indexed (image, 0, 0, rgb_map, palette);
|
return image_rgb_to_indexed (image, 0, 0, rgb_map, palette);
|
||||||
|
|
||||||
new_image = image_new (imgtype, image->w, image->h);
|
new_image = image_new(imgtype, image->w, image->h);
|
||||||
if (!new_image)
|
if (!new_image)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -55,12 +55,12 @@ Image *image_set_imgtype (Image *image, int imgtype,
|
|||||||
switch (image->imgtype) {
|
switch (image->imgtype) {
|
||||||
|
|
||||||
case IMAGE_RGB:
|
case IMAGE_RGB:
|
||||||
rgb_address = image->dat;
|
rgb_address = (ase_uint32 *)image->dat;
|
||||||
|
|
||||||
switch (new_image->imgtype) {
|
switch (new_image->imgtype) {
|
||||||
/* RGB -> Grayscale */
|
/* RGB -> Grayscale */
|
||||||
case IMAGE_GRAYSCALE:
|
case IMAGE_GRAYSCALE:
|
||||||
gray_address = new_image->dat;
|
gray_address = (ase_uint16 *)new_image->dat;
|
||||||
for (i=0; i<size; i++) {
|
for (i=0; i<size; i++) {
|
||||||
c = *rgb_address;
|
c = *rgb_address;
|
||||||
r = _rgba_getr (c);
|
r = _rgba_getr (c);
|
||||||
@ -77,10 +77,10 @@ Image *image_set_imgtype (Image *image, int imgtype,
|
|||||||
idx_address = new_image->dat;
|
idx_address = new_image->dat;
|
||||||
for (i=0; i<size; i++) {
|
for (i=0; i<size; i++) {
|
||||||
c = *rgb_address;
|
c = *rgb_address;
|
||||||
r = _rgba_getr (c);
|
r = _rgba_getr(c);
|
||||||
g = _rgba_getg (c);
|
g = _rgba_getg(c);
|
||||||
b = _rgba_getb (c);
|
b = _rgba_getb(c);
|
||||||
if (_rgba_geta (c) == 0)
|
if (_rgba_geta(c) == 0)
|
||||||
*idx_address = 0;
|
*idx_address = 0;
|
||||||
else
|
else
|
||||||
*idx_address = rgb_map->data[r>>3][g>>3][b>>3];
|
*idx_address = rgb_map->data[r>>3][g>>3][b>>3];
|
||||||
@ -92,12 +92,12 @@ Image *image_set_imgtype (Image *image, int imgtype,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case IMAGE_GRAYSCALE:
|
case IMAGE_GRAYSCALE:
|
||||||
gray_address = image->dat;
|
gray_address = (ase_uint16 *)image->dat;
|
||||||
|
|
||||||
switch (new_image->imgtype) {
|
switch (new_image->imgtype) {
|
||||||
/* Grayscale -> RGB */
|
/* Grayscale -> RGB */
|
||||||
case IMAGE_RGB:
|
case IMAGE_RGB:
|
||||||
rgb_address = new_image->dat;
|
rgb_address = (ase_uint32 *)new_image->dat;
|
||||||
for (i=0; i<size; i++) {
|
for (i=0; i<size; i++) {
|
||||||
c = *gray_address;
|
c = *gray_address;
|
||||||
g = _graya_getk (c);
|
g = _graya_getk (c);
|
||||||
@ -128,7 +128,7 @@ Image *image_set_imgtype (Image *image, int imgtype,
|
|||||||
switch (new_image->imgtype) {
|
switch (new_image->imgtype) {
|
||||||
/* Indexed -> RGB */
|
/* Indexed -> RGB */
|
||||||
case IMAGE_RGB:
|
case IMAGE_RGB:
|
||||||
rgb_address = new_image->dat;
|
rgb_address = (ase_uint32 *)new_image->dat;
|
||||||
for (i=0; i<size; i++) {
|
for (i=0; i<size; i++) {
|
||||||
c = *idx_address;
|
c = *idx_address;
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
@ -143,7 +143,7 @@ Image *image_set_imgtype (Image *image, int imgtype,
|
|||||||
break;
|
break;
|
||||||
/* Indexed -> Grayscale */
|
/* Indexed -> Grayscale */
|
||||||
case IMAGE_GRAYSCALE:
|
case IMAGE_GRAYSCALE:
|
||||||
gray_address = new_image->dat;
|
gray_address = (ase_uint16 *)new_image->dat;
|
||||||
for (i=0; i<size; i++) {
|
for (i=0; i<size; i++) {
|
||||||
c = *idx_address;
|
c = *idx_address;
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
@ -197,10 +197,10 @@ static int pattern[8][8] = {
|
|||||||
4 * ((g1)-(g2)) * ((g1)-(g2)) + \
|
4 * ((g1)-(g2)) * ((g1)-(g2)) + \
|
||||||
2 * ((b1)-(b2)) * ((b1)-(b2)))
|
2 * ((b1)-(b2)) * ((b1)-(b2)))
|
||||||
|
|
||||||
Image *image_rgb_to_indexed (Image *src_image,
|
Image *image_rgb_to_indexed(Image *src_image,
|
||||||
int offsetx, int offsety,
|
int offsetx, int offsety,
|
||||||
RGB_MAP *rgb_map,
|
RGB_MAP *rgb_map,
|
||||||
RGB *palette)
|
RGB *palette)
|
||||||
{
|
{
|
||||||
int oppr, oppg, oppb, oppnrcm;
|
int oppr, oppg, oppb, oppnrcm;
|
||||||
Image *dst_image;
|
Image *dst_image;
|
||||||
|
@ -450,9 +450,10 @@ void sprite_set_frame(Sprite *sprite, int frame)
|
|||||||
*/
|
*/
|
||||||
void sprite_set_imgtype(Sprite *sprite, int imgtype, int dithering_method)
|
void sprite_set_imgtype(Sprite *sprite, int imgtype, int dithering_method)
|
||||||
{
|
{
|
||||||
|
RGB *palette = sprite_get_palette(sprite, 0);
|
||||||
Image *old_image;
|
Image *old_image;
|
||||||
Image *new_image;
|
Image *new_image;
|
||||||
int c;
|
int c, r, g, b;
|
||||||
|
|
||||||
/* nothing to do */
|
/* nothing to do */
|
||||||
if (sprite->imgtype == imgtype)
|
if (sprite->imgtype == imgtype)
|
||||||
@ -462,6 +463,83 @@ void sprite_set_imgtype(Sprite *sprite, int imgtype, int dithering_method)
|
|||||||
if (undo_is_enabled(sprite->undo))
|
if (undo_is_enabled(sprite->undo))
|
||||||
undo_open(sprite->undo);
|
undo_open(sprite->undo);
|
||||||
|
|
||||||
|
/* change the background color */
|
||||||
|
if (undo_is_enabled(sprite->undo))
|
||||||
|
undo_int(sprite->undo, (GfxObj *)sprite, &sprite->bgcolor);
|
||||||
|
|
||||||
|
c = sprite->bgcolor;
|
||||||
|
|
||||||
|
switch (sprite->imgtype) {
|
||||||
|
|
||||||
|
case IMAGE_RGB:
|
||||||
|
switch (imgtype) {
|
||||||
|
/* RGB -> Grayscale */
|
||||||
|
case IMAGE_GRAYSCALE:
|
||||||
|
r = _rgba_getr(c);
|
||||||
|
g = _rgba_getg(c);
|
||||||
|
b = _rgba_getb(c);
|
||||||
|
rgb_to_hsv_int(&r, &g, &b);
|
||||||
|
c = _graya(b, _rgba_geta(c));
|
||||||
|
break;
|
||||||
|
/* RGB -> Indexed */
|
||||||
|
case IMAGE_INDEXED:
|
||||||
|
r = _rgba_getr(c);
|
||||||
|
g = _rgba_getg(c);
|
||||||
|
b = _rgba_getb(c);
|
||||||
|
if (_rgba_geta(c) == 0)
|
||||||
|
c = 0;
|
||||||
|
else
|
||||||
|
c = rgb_map->data[r>>3][g>>3][b>>3];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IMAGE_GRAYSCALE:
|
||||||
|
switch (imgtype) {
|
||||||
|
/* Grayscale -> RGB */
|
||||||
|
case IMAGE_RGB:
|
||||||
|
g = _graya_getk(c);
|
||||||
|
c = _rgba(g, g, g, _graya_geta(c));
|
||||||
|
break;
|
||||||
|
/* Grayscale -> Indexed */
|
||||||
|
case IMAGE_INDEXED:
|
||||||
|
if (_graya_geta(c) == 0)
|
||||||
|
c = 0;
|
||||||
|
else
|
||||||
|
c = _graya_getk(c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IMAGE_INDEXED:
|
||||||
|
switch (imgtype) {
|
||||||
|
/* Indexed -> RGB */
|
||||||
|
case IMAGE_RGB:
|
||||||
|
if (c == 0)
|
||||||
|
c = 0;
|
||||||
|
else
|
||||||
|
c = _rgba(_rgb_scale_6[palette[c].r],
|
||||||
|
_rgb_scale_6[palette[c].g],
|
||||||
|
_rgb_scale_6[palette[c].b], 255);
|
||||||
|
break;
|
||||||
|
/* Indexed -> Grayscale */
|
||||||
|
case IMAGE_GRAYSCALE:
|
||||||
|
if (c == 0)
|
||||||
|
c = 0;
|
||||||
|
else {
|
||||||
|
r = _rgb_scale_6[palette[c].r];
|
||||||
|
g = _rgb_scale_6[palette[c].g];
|
||||||
|
b = _rgb_scale_6[palette[c].b];
|
||||||
|
rgb_to_hsv_int(&r, &g, &b);
|
||||||
|
c = _graya(b, 255);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprite_set_bgcolor(sprite, c);
|
||||||
|
|
||||||
/* change imgtype of the stock of images */
|
/* change imgtype of the stock of images */
|
||||||
if (undo_is_enabled(sprite->undo)) {
|
if (undo_is_enabled(sprite->undo)) {
|
||||||
undo_int(sprite->undo, (GfxObj *)sprite, &imgtype);
|
undo_int(sprite->undo, (GfxObj *)sprite, &imgtype);
|
||||||
@ -489,10 +567,10 @@ void sprite_set_imgtype(Sprite *sprite, int imgtype, int dithering_method)
|
|||||||
image_free(old_image);
|
image_free(old_image);
|
||||||
stock_replace_image(sprite->stock, c, new_image);
|
stock_replace_image(sprite->stock, c, new_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* change "sprite.imgtype" field */
|
/* change "sprite.imgtype" field */
|
||||||
if (undo_is_enabled(sprite->undo))
|
if (undo_is_enabled(sprite->undo))
|
||||||
undo_int (sprite->undo, (GfxObj *)sprite, &sprite->imgtype);
|
undo_int(sprite->undo, (GfxObj *)sprite, &sprite->imgtype);
|
||||||
|
|
||||||
sprite->imgtype = imgtype;
|
sprite->imgtype = imgtype;
|
||||||
|
|
||||||
@ -509,6 +587,7 @@ void sprite_set_imgtype(Sprite *sprite, int imgtype, int dithering_method)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (undo_is_enabled(sprite->undo))
|
if (undo_is_enabled(sprite->undo))
|
||||||
undo_close(sprite->undo);
|
undo_close(sprite->undo);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ typedef struct UndoChunk
|
|||||||
int max_size;
|
int max_size;
|
||||||
int size;
|
int size;
|
||||||
int pos;
|
int pos;
|
||||||
unsigned char *data;
|
ase_uint8 *data;
|
||||||
} UndoChunk;
|
} UndoChunk;
|
||||||
|
|
||||||
typedef struct UndoStream
|
typedef struct UndoStream
|
||||||
@ -192,8 +192,8 @@ static void undo_chunk_put32(UndoChunk *chunk, long c);
|
|||||||
/* static double undo_chunk_get64(UndoChunk *chunk); */
|
/* static double undo_chunk_get64(UndoChunk *chunk); */
|
||||||
/* static void undo_chunk_put64(UndoChunk *chunk, double c); */
|
/* static void undo_chunk_put64(UndoChunk *chunk, double c); */
|
||||||
|
|
||||||
static int undo_chunk_read(UndoChunk *chunk, unsigned char *buf, int size);
|
static int undo_chunk_read(UndoChunk *chunk, ase_uint8 *buf, int size);
|
||||||
static void undo_chunk_write(UndoChunk *chunk, const unsigned char *buf, int size);
|
static void undo_chunk_write(UndoChunk *chunk, const ase_uint8 *buf, int size);
|
||||||
|
|
||||||
static char *undo_chunk_read_string(UndoChunk *chunk);
|
static char *undo_chunk_read_string(UndoChunk *chunk);
|
||||||
static void undo_chunk_write_string(UndoChunk *chunk, const char *string);
|
static void undo_chunk_write_string(UndoChunk *chunk, const char *string);
|
||||||
@ -221,8 +221,8 @@ static void undo_stream_push_chunk(UndoStream *stream, UndoChunk *chunk);
|
|||||||
/* static long undo_stream_raw_read_dword(UndoStream *stream); */
|
/* static long undo_stream_raw_read_dword(UndoStream *stream); */
|
||||||
/* static void undo_stream_raw_write_dword(UndoStream *stream, long dword); */
|
/* static void undo_stream_raw_write_dword(UndoStream *stream, long dword); */
|
||||||
|
|
||||||
/* static int undo_stream_raw_read(UndoStream *stream, unsigned char *buf, int size); */
|
/* static int undo_stream_raw_read(UndoStream *stream, ase_uint8 *buf, int size); */
|
||||||
/* static void undo_stream_raw_write(UndoStream *stream, unsigned char *buf, int size); */
|
/* static void undo_stream_raw_write(UndoStream *stream, ase_uint8 *buf, int size); */
|
||||||
|
|
||||||
/* General undo routines */
|
/* General undo routines */
|
||||||
|
|
||||||
@ -466,15 +466,15 @@ void undo_data(Undo *undo, GfxObj *gfxobj, void *data, int size)
|
|||||||
static void chunk_data(UndoStream *stream, GfxObj *gfxobj, void *data, int size)
|
static void chunk_data(UndoStream *stream, GfxObj *gfxobj, void *data, int size)
|
||||||
{
|
{
|
||||||
UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_DATA);
|
UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_DATA);
|
||||||
unsigned int offset = (unsigned int)(((unsigned char *)data) -
|
unsigned int offset = (unsigned int)(((ase_uint8 *)data) -
|
||||||
((unsigned char *)gfxobj));
|
((ase_uint8 *)gfxobj));
|
||||||
unsigned int c;
|
unsigned int c;
|
||||||
|
|
||||||
undo_chunk_put32(chunk, gfxobj->id);
|
undo_chunk_put32(chunk, gfxobj->id);
|
||||||
undo_chunk_put32(chunk, offset);
|
undo_chunk_put32(chunk, offset);
|
||||||
undo_chunk_put32(chunk, size);
|
undo_chunk_put32(chunk, size);
|
||||||
for (c=0; c<size; c++)
|
for (c=0; c<size; c++)
|
||||||
undo_chunk_put8(chunk, ((unsigned char *)data)[c]);
|
undo_chunk_put8(chunk, ((ase_uint8 *)data)[c]);
|
||||||
|
|
||||||
undo_stream_push_chunk(stream, chunk);
|
undo_stream_push_chunk(stream, chunk);
|
||||||
}
|
}
|
||||||
@ -487,13 +487,13 @@ static void chunk_data_invert(UndoStream *stream, UndoChunk *chunk, int state)
|
|||||||
GfxObj *gfxobj = gfxobj_find(id);
|
GfxObj *gfxobj = gfxobj_find(id);
|
||||||
|
|
||||||
if (gfxobj) {
|
if (gfxobj) {
|
||||||
void *data = (void *)(((unsigned char *)gfxobj) + offset);
|
void *data = (void *)(((ase_uint8 *)gfxobj) + offset);
|
||||||
|
|
||||||
chunk_data(stream, gfxobj, data, size);
|
chunk_data(stream, gfxobj, data, size);
|
||||||
|
|
||||||
/* get the string from the chunk */
|
/* get the string from the chunk */
|
||||||
for (c=0; c<size; c++)
|
for (c=0; c<size; c++)
|
||||||
((unsigned char *)data)[c] = undo_chunk_get8(chunk);
|
((ase_uint8 *)data)[c] = undo_chunk_get8(chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,9 +697,9 @@ static void chunk_dirty(UndoStream *stream, Dirty *dirty)
|
|||||||
|
|
||||||
static void chunk_dirty_invert(UndoStream *stream, UndoChunk *chunk, int state)
|
static void chunk_dirty_invert(UndoStream *stream, UndoChunk *chunk, int state)
|
||||||
{
|
{
|
||||||
unsigned long id = undo_chunk_get32 (chunk);
|
unsigned long id = undo_chunk_get32(chunk);
|
||||||
int imgtype = undo_chunk_get8 (chunk);
|
int imgtype = undo_chunk_get8 (chunk);
|
||||||
Image *image = (Image *)gfxobj_find (id);
|
Image *image = (Image *)gfxobj_find(id);
|
||||||
|
|
||||||
if ((image) && (image->gfxobj.type == GFXOBJ_IMAGE) &&
|
if ((image) && (image->gfxobj.type == GFXOBJ_IMAGE) &&
|
||||||
(image->imgtype == imgtype)) {
|
(image->imgtype == imgtype)) {
|
||||||
@ -1334,7 +1334,7 @@ static void undo_chunk_put32(UndoChunk *chunk, long c)
|
|||||||
/* undo_chunk_put32(chunk, longs[1]); */
|
/* undo_chunk_put32(chunk, longs[1]); */
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
static int undo_chunk_read(UndoChunk *chunk, unsigned char *buf, int size)
|
static int undo_chunk_read(UndoChunk *chunk, ase_uint8 *buf, int size)
|
||||||
{
|
{
|
||||||
if (chunk->pos+size > chunk->size)
|
if (chunk->pos+size > chunk->size)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1345,7 +1345,7 @@ static int undo_chunk_read(UndoChunk *chunk, unsigned char *buf, int size)
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void undo_chunk_write(UndoChunk *chunk, const unsigned char *buf, int size)
|
static void undo_chunk_write(UndoChunk *chunk, const ase_uint8 *buf, int size)
|
||||||
{
|
{
|
||||||
if (chunk->size+size > chunk->max_size) {
|
if (chunk->size+size > chunk->max_size) {
|
||||||
chunk->max_size = chunk->size+size;
|
chunk->max_size = chunk->size+size;
|
||||||
|
@ -20,9 +20,8 @@
|
|||||||
.align 4
|
.align 4
|
||||||
|
|
||||||
/* Function: int _int_mult (int a, int b) */
|
/* Function: int _int_mult (int a, int b) */
|
||||||
.globl _int_mult
|
.globl __int_mult
|
||||||
/* .type _int_mult,@function */
|
__int_mult:
|
||||||
_int_mult:
|
|
||||||
pushl %ebp
|
pushl %ebp
|
||||||
movl %esp,%ebp
|
movl %esp,%ebp
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ find_empty_segs (PixelRegion *maskPR,
|
|||||||
gint x2,
|
gint x2,
|
||||||
gint y2)
|
gint y2)
|
||||||
{
|
{
|
||||||
unsigned char *data;
|
ase_uint8 *data;
|
||||||
int x;
|
int x;
|
||||||
int start, end;
|
int start, end;
|
||||||
int val, last;
|
int val, last;
|
||||||
@ -171,7 +171,7 @@ find_empty_segs (PixelRegion *maskPR,
|
|||||||
l_num_empty = *num_empty;
|
l_num_empty = *num_empty;
|
||||||
|
|
||||||
d = div (start, 8);
|
d = div (start, 8);
|
||||||
data = ((unsigned char *)maskPR->line[scanline])+d.quot;
|
data = ((ase_uint8 *)maskPR->line[scanline])+d.quot;
|
||||||
|
|
||||||
for (x = start; x < end;)
|
for (x = start; x < end;)
|
||||||
{
|
{
|
||||||
|
@ -49,13 +49,13 @@
|
|||||||
static void (*function)(void *) = NULL;
|
static void (*function)(void *) = NULL;
|
||||||
static HashTable *the_table = NULL;
|
static HashTable *the_table = NULL;
|
||||||
|
|
||||||
static unsigned long hash (const unsigned char *str);
|
static unsigned long hash(const unsigned char *str);
|
||||||
static void free_node (const char *key, void *data);
|
static void free_node(const char *key, void *data);
|
||||||
|
|
||||||
/* hash_new:
|
/* hash_new:
|
||||||
* Creates a new hash table to the size asked for.
|
* Creates a new hash table to the size asked for.
|
||||||
*/
|
*/
|
||||||
HashTable *hash_new (int size)
|
HashTable *hash_new(int size)
|
||||||
{
|
{
|
||||||
HashTable *table;
|
HashTable *table;
|
||||||
int i;
|
int i;
|
||||||
@ -84,20 +84,20 @@ HashTable *hash_new (int size)
|
|||||||
* responsible for freeing the data, or doing whatever is needed with
|
* responsible for freeing the data, or doing whatever is needed with
|
||||||
* it.
|
* it.
|
||||||
*/
|
*/
|
||||||
void hash_free (HashTable *table, void (*func) (void *))
|
void hash_free(HashTable *table, void (*func)(void *))
|
||||||
{
|
{
|
||||||
function = func;
|
function = func;
|
||||||
the_table = table;
|
the_table = table;
|
||||||
|
|
||||||
hash_enumerate (table, free_node);
|
hash_enumerate(table, free_node);
|
||||||
jfree (table->table);
|
jfree(table->table);
|
||||||
table->table = NULL;
|
table->table = NULL;
|
||||||
table->size = 0;
|
table->size = 0;
|
||||||
|
|
||||||
the_table = NULL;
|
the_table = NULL;
|
||||||
function = NULL;
|
function = NULL;
|
||||||
|
|
||||||
jfree (table);
|
jfree(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* hash_insert:
|
/* hash_insert:
|
||||||
@ -105,9 +105,9 @@ void hash_free (HashTable *table, void (*func) (void *))
|
|||||||
* Returns pointer to old data associated with the key, if any, or
|
* Returns pointer to old data associated with the key, if any, or
|
||||||
* NULL if the key wasn't in the table previously.
|
* NULL if the key wasn't in the table previously.
|
||||||
*/
|
*/
|
||||||
void *hash_insert (HashTable *table, const char *key, void *data)
|
void *hash_insert(HashTable *table, const char *key, void *data)
|
||||||
{
|
{
|
||||||
unsigned int val = hash (key) % table->size;
|
unsigned int val = hash(key) % table->size;
|
||||||
HashBucket *ptr;
|
HashBucket *ptr;
|
||||||
|
|
||||||
/* See if the current string has already been inserted, and if so,
|
/* See if the current string has already been inserted, and if so,
|
||||||
@ -141,9 +141,9 @@ void *hash_insert (HashTable *table, const char *key, void *data)
|
|||||||
* Look up a key and return the associated data.
|
* Look up a key and return the associated data.
|
||||||
* Returns NULL if the key is not in the table.
|
* Returns NULL if the key is not in the table.
|
||||||
*/
|
*/
|
||||||
void *hash_lookup (HashTable *table, const char *key)
|
void *hash_lookup(HashTable *table, const char *key)
|
||||||
{
|
{
|
||||||
unsigned int val = hash (key) % table->size;
|
unsigned int val = hash(key) % table->size;
|
||||||
HashBucket *ptr;
|
HashBucket *ptr;
|
||||||
|
|
||||||
for (ptr = table->table[val]; NULL != ptr; ptr = ptr->next)
|
for (ptr = table->table[val]; NULL != ptr; ptr = ptr->next)
|
||||||
@ -157,9 +157,9 @@ void *hash_lookup (HashTable *table, const char *key)
|
|||||||
* Delete a key from the hash table and return associated
|
* Delete a key from the hash table and return associated
|
||||||
* data, or NULL if not present.
|
* data, or NULL if not present.
|
||||||
*/
|
*/
|
||||||
void *hash_remove (HashTable *table, const char *key)
|
void *hash_remove(HashTable *table, const char *key)
|
||||||
{
|
{
|
||||||
unsigned int val = hash (key) % table->size;
|
unsigned int val = hash(key) % table->size;
|
||||||
void *data;
|
void *data;
|
||||||
HashBucket *ptr, *last = NULL;
|
HashBucket *ptr, *last = NULL;
|
||||||
|
|
||||||
@ -170,8 +170,8 @@ void *hash_remove (HashTable *table, const char *key)
|
|||||||
else
|
else
|
||||||
table->table[val] = ptr->next;
|
table->table[val] = ptr->next;
|
||||||
data = ptr->data;
|
data = ptr->data;
|
||||||
jfree (ptr->key);
|
jfree(ptr->key);
|
||||||
jfree (ptr);
|
jfree(ptr);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
last = ptr;
|
last = ptr;
|
||||||
@ -184,7 +184,7 @@ void *hash_remove (HashTable *table, const char *key)
|
|||||||
* Simply invokes the callback given as the second parameter for each
|
* Simply invokes the callback given as the second parameter for each
|
||||||
* node in the table, passing it the key and the associated data.
|
* node in the table, passing it the key and the associated data.
|
||||||
*/
|
*/
|
||||||
void hash_enumerate (HashTable *table, void (*callback) (const char *, void *))
|
void hash_enumerate(HashTable *table, void (*callback)(const char *, void *))
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
HashBucket *bucket, *next;
|
HashBucket *bucket, *next;
|
||||||
@ -199,7 +199,7 @@ void hash_enumerate (HashTable *table, void (*callback) (const char *, void *))
|
|||||||
/* hash:
|
/* hash:
|
||||||
* Hashes a string.
|
* Hashes a string.
|
||||||
*/
|
*/
|
||||||
static unsigned long hash (const unsigned char *str)
|
static unsigned long hash(const unsigned char *str)
|
||||||
{
|
{
|
||||||
unsigned long hash = 0, c;
|
unsigned long hash = 0, c;
|
||||||
while ((c = *str++))
|
while ((c = *str++))
|
||||||
@ -213,10 +213,10 @@ static unsigned long hash (const unsigned char *str)
|
|||||||
* passes a pointer to the data back to a function defined by the user,
|
* passes a pointer to the data back to a function defined by the user,
|
||||||
* process the data as needed.
|
* process the data as needed.
|
||||||
*/
|
*/
|
||||||
static void free_node (const char *key, void *data)
|
static void free_node(const char *key, void *data)
|
||||||
{
|
{
|
||||||
if (function)
|
if (function)
|
||||||
function (hash_remove (the_table, key));
|
function(hash_remove(the_table, key));
|
||||||
else
|
else
|
||||||
hash_remove (the_table, key);
|
hash_remove(the_table, key);
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ void ClearMask(void)
|
|||||||
{
|
{
|
||||||
Sprite *sprite = current_sprite;
|
Sprite *sprite = current_sprite;
|
||||||
int x, y, u, v, putx, puty;
|
int x, y, u, v, putx, puty;
|
||||||
unsigned char *address;
|
ase_uint8 *address;
|
||||||
Image *image;
|
Image *image;
|
||||||
div_t d;
|
div_t d;
|
||||||
int color;
|
int color;
|
||||||
@ -165,7 +165,7 @@ void ClearMask(void)
|
|||||||
/* clear the masked zones */
|
/* clear the masked zones */
|
||||||
for (v=0; v<sprite->mask->h; v++) {
|
for (v=0; v<sprite->mask->h; v++) {
|
||||||
d = div (0, 8);
|
d = div (0, 8);
|
||||||
address = ((unsigned char **)sprite->mask->bitmap->line)[v]+d.quot;
|
address = ((ase_uint8 **)sprite->mask->bitmap->line)[v]+d.quot;
|
||||||
|
|
||||||
for (u=0; u<sprite->mask->w; u++) {
|
for (u=0; u<sprite->mask->w; u++) {
|
||||||
if ((*address & (1<<d.rem))) {
|
if ((*address & (1<<d.rem))) {
|
||||||
@ -186,7 +186,7 @@ void ClearMask(void)
|
|||||||
sprite, the layer isn't added to the sprite */
|
sprite, the layer isn't added to the sprite */
|
||||||
Layer *NewLayerFromMask(Sprite *src_sprite, Sprite *dst_sprite)
|
Layer *NewLayerFromMask(Sprite *src_sprite, Sprite *dst_sprite)
|
||||||
{
|
{
|
||||||
unsigned char *address;
|
ase_uint8 *address;
|
||||||
int x, y, u, v, getx, gety;
|
int x, y, u, v, getx, gety;
|
||||||
Image *dst, *src = GetImage2(src_sprite, &x, &y, NULL);
|
Image *dst, *src = GetImage2(src_sprite, &x, &y, NULL);
|
||||||
Layer *layer;
|
Layer *layer;
|
||||||
@ -208,7 +208,7 @@ Layer *NewLayerFromMask(Sprite *src_sprite, Sprite *dst_sprite)
|
|||||||
/* copy the masked zones */
|
/* copy the masked zones */
|
||||||
for (v=0; v<src_sprite->mask->h; v++) {
|
for (v=0; v<src_sprite->mask->h; v++) {
|
||||||
d = div(0, 8);
|
d = div(0, 8);
|
||||||
address = ((unsigned char **)src_sprite->mask->bitmap->line)[v]+d.quot;
|
address = ((ase_uint8 **)src_sprite->mask->bitmap->line)[v]+d.quot;
|
||||||
|
|
||||||
for (u=0; u<src_sprite->mask->w; u++) {
|
for (u=0; u<src_sprite->mask->w; u++) {
|
||||||
if ((*address & (1<<d.rem))) {
|
if ((*address & (1<<d.rem))) {
|
||||||
|
@ -51,10 +51,10 @@ void sprite_quantize_ex(Sprite *sprite, RGB *palette)
|
|||||||
stock = sprite_get_images(sprite, TARGET_ALL, FALSE, NULL, NULL);
|
stock = sprite_get_images(sprite, TARGET_ALL, FALSE, NULL, NULL);
|
||||||
if (stock) {
|
if (stock) {
|
||||||
/* add a flat image with the current sprite's frame rendered */
|
/* add a flat image with the current sprite's frame rendered */
|
||||||
flat_image = image_new (sprite->imgtype, sprite->w, sprite->h);
|
flat_image = image_new(sprite->imgtype, sprite->w, sprite->h);
|
||||||
image_clear (flat_image, 0);
|
image_clear(flat_image, 0);
|
||||||
sprite_render (sprite, flat_image, 0, 0);
|
sprite_render(sprite, flat_image, 0, 0);
|
||||||
stock_add_image (stock, flat_image);
|
stock_add_image(stock, flat_image);
|
||||||
|
|
||||||
/* generate the optimized palette */
|
/* generate the optimized palette */
|
||||||
{
|
{
|
||||||
|
@ -256,9 +256,9 @@ static void merge_zoomed_image1(Image *dst, Image *src,
|
|||||||
int x, int y, int opacity,
|
int x, int y, int opacity,
|
||||||
int blend_mode, int zoom)
|
int blend_mode, int zoom)
|
||||||
{
|
{
|
||||||
unsigned char *src_address;
|
ase_uint8 *src_address;
|
||||||
unsigned char *dst_address;
|
ase_uint8 *dst_address;
|
||||||
unsigned char *scanline, *scanline_address;
|
ase_uint8 *scanline, *scanline_address;
|
||||||
int src_x, src_y, src_w, src_h;
|
int src_x, src_y, src_w, src_h;
|
||||||
int dst_x, dst_y, dst_w, dst_h;
|
int dst_x, dst_y, dst_w, dst_h;
|
||||||
int box_x, box_y, box_w, box_h;
|
int box_x, box_y, box_w, box_h;
|
||||||
@ -311,18 +311,18 @@ static void merge_zoomed_image1(Image *dst, Image *src,
|
|||||||
if ((src_w <= 0) || (src_h <= 0) || (dst_w <= 0) || (dst_h <= 0))
|
if ((src_w <= 0) || (src_h <= 0) || (dst_w <= 0) || (dst_h <= 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sizeof_box = sizeof(unsigned char) * box_w;
|
sizeof_box = sizeof(ase_uint8) * box_w;
|
||||||
right = dst_x+dst_w-1;
|
right = dst_x+dst_w-1;
|
||||||
bottom = dst_y+dst_h-1;
|
bottom = dst_y+dst_h-1;
|
||||||
|
|
||||||
scanline = jmalloc (sizeof(unsigned char) * src_w);
|
scanline = jmalloc(sizeof(ase_uint8) * src_w);
|
||||||
|
|
||||||
/* merge process */
|
/* merge process */
|
||||||
|
|
||||||
for (y=0; y<src_h; y++) {
|
for (y=0; y<src_h; y++) {
|
||||||
/* process a new line */
|
/* process a new line */
|
||||||
src_address = ((unsigned char **)src->line)[src_y] + src_x;
|
src_address = ((ase_uint8 **)src->line)[src_y] + src_x;
|
||||||
dst_address = ((unsigned char **)dst->line)[dst_y] + dst_x;
|
dst_address = ((ase_uint8 **)dst->line)[dst_y] + dst_x;
|
||||||
scanline_address = scanline;
|
scanline_address = scanline;
|
||||||
|
|
||||||
/* read `src' and `dst' and blend them, put the result in `scanline' */
|
/* read `src' and `dst' and blend them, put the result in `scanline' */
|
||||||
@ -354,7 +354,7 @@ static void merge_zoomed_image1(Image *dst, Image *src,
|
|||||||
|
|
||||||
/* put the line in `dst' */
|
/* put the line in `dst' */
|
||||||
for (box_y=0; box_y<line_h; box_y++) {
|
for (box_y=0; box_y<line_h; box_y++) {
|
||||||
dst_address = ((unsigned char **)dst->line)[dst_y] + dst_x;
|
dst_address = ((ase_uint8 **)dst->line)[dst_y] + dst_x;
|
||||||
scanline_address = scanline;
|
scanline_address = scanline;
|
||||||
|
|
||||||
line_x = dst_x;
|
line_x = dst_x;
|
||||||
@ -399,7 +399,7 @@ done_with_line:;
|
|||||||
}
|
}
|
||||||
|
|
||||||
done_with_blit:;
|
done_with_blit:;
|
||||||
jfree (scanline);
|
jfree(scanline);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void merge_zoomed_image2(Image *dst, Image *src,
|
static void merge_zoomed_image2(Image *dst, Image *src,
|
||||||
@ -407,9 +407,9 @@ static void merge_zoomed_image2(Image *dst, Image *src,
|
|||||||
int blend_mode, int zoom)
|
int blend_mode, int zoom)
|
||||||
{
|
{
|
||||||
BLEND_COLOR blender = _graya_blenders[blend_mode];
|
BLEND_COLOR blender = _graya_blenders[blend_mode];
|
||||||
unsigned short *src_address;
|
ase_uint16 *src_address;
|
||||||
unsigned short *dst_address;
|
ase_uint16 *dst_address;
|
||||||
unsigned short *scanline, *scanline_address;
|
ase_uint16 *scanline, *scanline_address;
|
||||||
int src_x, src_y, src_w, src_h;
|
int src_x, src_y, src_w, src_h;
|
||||||
int dst_x, dst_y, dst_w, dst_h;
|
int dst_x, dst_y, dst_w, dst_h;
|
||||||
int box_x, box_y, box_w, box_h;
|
int box_x, box_y, box_w, box_h;
|
||||||
@ -462,25 +462,25 @@ static void merge_zoomed_image2(Image *dst, Image *src,
|
|||||||
if ((src_w <= 0) || (src_h <= 0) || (dst_w <= 0) || (dst_h <= 0))
|
if ((src_w <= 0) || (src_h <= 0) || (dst_w <= 0) || (dst_h <= 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sizeof_box = sizeof(unsigned short) * box_w;
|
sizeof_box = sizeof(ase_uint16) * box_w;
|
||||||
right = dst_x+dst_w-1;
|
right = dst_x+dst_w-1;
|
||||||
bottom = dst_y+dst_h-1;
|
bottom = dst_y+dst_h-1;
|
||||||
|
|
||||||
scanline = jmalloc(sizeof(unsigned short) * src_w);
|
scanline = jmalloc(sizeof(ase_uint16) * src_w);
|
||||||
|
|
||||||
/* merge process */
|
/* merge process */
|
||||||
|
|
||||||
// opacity = (opacity)? opacity+1: 0;
|
/* opacity = (opacity)? opacity+1: 0; */
|
||||||
|
|
||||||
for (y=0; y<src_h; y++) {
|
for (y=0; y<src_h; y++) {
|
||||||
/* process a new line */
|
/* process a new line */
|
||||||
src_address = ((unsigned short **)src->line)[src_y] + src_x;
|
src_address = ((ase_uint16 **)src->line)[src_y] + src_x;
|
||||||
dst_address = ((unsigned short **)dst->line)[dst_y] + dst_x;
|
dst_address = ((ase_uint16 **)dst->line)[dst_y] + dst_x;
|
||||||
scanline_address = scanline;
|
scanline_address = scanline;
|
||||||
|
|
||||||
/* read `src' and `dst' and blend them, put the result in `scanline' */
|
/* read `src' and `dst' and blend them, put the result in `scanline' */
|
||||||
for (x=0; x<src_w; x++) {
|
for (x=0; x<src_w; x++) {
|
||||||
*scanline_address = (*blender) (*dst_address, *src_address, opacity);
|
*scanline_address = (*blender)(*dst_address, *src_address, opacity);
|
||||||
|
|
||||||
src_address++;
|
src_address++;
|
||||||
dst_address += box_w;
|
dst_address += box_w;
|
||||||
@ -495,7 +495,7 @@ static void merge_zoomed_image2(Image *dst, Image *src,
|
|||||||
|
|
||||||
/* put the line in `dst' */
|
/* put the line in `dst' */
|
||||||
for (box_y=0; box_y<line_h; box_y++) {
|
for (box_y=0; box_y<line_h; box_y++) {
|
||||||
dst_address = ((unsigned short **)dst->line)[dst_y] + dst_x;
|
dst_address = ((ase_uint16 **)dst->line)[dst_y] + dst_x;
|
||||||
scanline_address = scanline;
|
scanline_address = scanline;
|
||||||
|
|
||||||
line_x = dst_x;
|
line_x = dst_x;
|
||||||
@ -540,7 +540,7 @@ done_with_line:;
|
|||||||
}
|
}
|
||||||
|
|
||||||
done_with_blit:;
|
done_with_blit:;
|
||||||
jfree (scanline);
|
jfree(scanline);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void merge_zoomed_image4(Image *dst, Image *src,
|
static void merge_zoomed_image4(Image *dst, Image *src,
|
||||||
@ -548,9 +548,9 @@ static void merge_zoomed_image4(Image *dst, Image *src,
|
|||||||
int blend_mode, int zoom)
|
int blend_mode, int zoom)
|
||||||
{
|
{
|
||||||
BLEND_COLOR blender = _rgba_blenders[blend_mode];
|
BLEND_COLOR blender = _rgba_blenders[blend_mode];
|
||||||
unsigned long *src_address;
|
ase_uint32 *src_address;
|
||||||
unsigned long *dst_address;
|
ase_uint32 *dst_address;
|
||||||
unsigned long *scanline, *scanline_address;
|
ase_uint32 *scanline, *scanline_address;
|
||||||
int src_x, src_y, src_w, src_h;
|
int src_x, src_y, src_w, src_h;
|
||||||
int dst_x, dst_y, dst_w, dst_h;
|
int dst_x, dst_y, dst_w, dst_h;
|
||||||
int box_x, box_y, box_w, box_h;
|
int box_x, box_y, box_w, box_h;
|
||||||
@ -603,25 +603,25 @@ static void merge_zoomed_image4(Image *dst, Image *src,
|
|||||||
if ((src_w <= 0) || (src_h <= 0) || (dst_w <= 0) || (dst_h <= 0))
|
if ((src_w <= 0) || (src_h <= 0) || (dst_w <= 0) || (dst_h <= 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sizeof_box = sizeof(unsigned long) * box_w;
|
sizeof_box = sizeof(ase_uint32) * box_w;
|
||||||
right = dst_x+dst_w-1;
|
right = dst_x+dst_w-1;
|
||||||
bottom = dst_y+dst_h-1;
|
bottom = dst_y+dst_h-1;
|
||||||
|
|
||||||
scanline = jmalloc(sizeof(unsigned long) * src_w);
|
scanline = jmalloc(sizeof(ase_uint32) * src_w);
|
||||||
|
|
||||||
/* merge process */
|
/* merge process */
|
||||||
|
|
||||||
// opacity = (opacity)? opacity+1: 0;
|
/* opacity = (opacity)? opacity+1: 0; */
|
||||||
|
|
||||||
for (y=0; y<src_h; y++) {
|
for (y=0; y<src_h; y++) {
|
||||||
/* process a new line */
|
/* process a new line */
|
||||||
src_address = ((unsigned long **)src->line)[src_y] + src_x;
|
src_address = ((ase_uint32 **)src->line)[src_y] + src_x;
|
||||||
dst_address = ((unsigned long **)dst->line)[dst_y] + dst_x;
|
dst_address = ((ase_uint32 **)dst->line)[dst_y] + dst_x;
|
||||||
scanline_address = scanline;
|
scanline_address = scanline;
|
||||||
|
|
||||||
/* read `src' and `dst' and blend them, put the result in `scanline' */
|
/* read `src' and `dst' and blend them, put the result in `scanline' */
|
||||||
for (x=0; x<src_w; x++) {
|
for (x=0; x<src_w; x++) {
|
||||||
*scanline_address = (*blender) (*dst_address, *src_address, opacity);
|
*scanline_address = (*blender)(*dst_address, *src_address, opacity);
|
||||||
|
|
||||||
src_address++;
|
src_address++;
|
||||||
dst_address += box_w;
|
dst_address += box_w;
|
||||||
@ -636,7 +636,7 @@ static void merge_zoomed_image4(Image *dst, Image *src,
|
|||||||
|
|
||||||
/* put the line in `dst' */
|
/* put the line in `dst' */
|
||||||
for (box_y=0; box_y<line_h; box_y++) {
|
for (box_y=0; box_y<line_h; box_y++) {
|
||||||
dst_address = ((unsigned long **)dst->line)[dst_y] + dst_x;
|
dst_address = ((ase_uint32 **)dst->line)[dst_y] + dst_x;
|
||||||
scanline_address = scanline;
|
scanline_address = scanline;
|
||||||
|
|
||||||
line_x = dst_x;
|
line_x = dst_x;
|
||||||
@ -681,5 +681,5 @@ done_with_line:;
|
|||||||
}
|
}
|
||||||
|
|
||||||
done_with_blit:;
|
done_with_blit:;
|
||||||
jfree (scanline);
|
jfree(scanline);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user