Added ase_uint8, ase_uint16, ase_uint32

This commit is contained in:
David Capello 2007-12-11 20:05:18 +00:00
parent 1851db4ac7
commit ece7c72b0f
50 changed files with 1217 additions and 1091 deletions

View File

@ -134,6 +134,7 @@ THANKFULNESS
Elio Cuevas Gómez
Emmanuel Rousseau (God_Cells)
Hernán Echegoyemberry
Jon Rafkind (kazzmir)
Jonathan Taylor
Jorge Ramírez Flores
Juraj Michalek
@ -144,3 +145,4 @@ THANKFULNESS
Nora Amendez
Peter Wang (tjaden)
Robert J Ohannessian (Bob)
Trent Gamblin (trentg)

View File

@ -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>
* src/file/png_format.c (save_PNG): Fixed a problem when saving

View File

@ -2,6 +2,10 @@ High priority work
------------------
- 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.
- ver por el nuevo load_font de Allegro.
- complete palette operations, and palette editor (it needs a slider

View File

@ -47,3 +47,9 @@ const char *msgids_get(const char *id); /* src/intl/msgids.[ch] */
#include <math.h>
#undef PI
#define PI 3.14159265358979323846
#include <allegro/base.h>
typedef uint8_t ase_uint8;
typedef uint16_t ase_uint16;
typedef uint32_t ase_uint32;

View File

@ -51,10 +51,17 @@
</box>
</box>
</box>
<slider min="0" max="1" name="frame" />
<box horizontal homogeneous>
<button text="&OK" name="button_ok" magnetic />
<button text="&Cancel" />
<box horizontal >
<label text="Frame:" />
<slider min="0" max="1" name="frame" expansive />
</box>
<box horizontal>
<box horizontal expansive />
<box horizontal homogeneous>
<button text="&OK" name="button_ok" magnetic width="60" />
<button text="&Cancel" />
</box>
</box>
</box>
</window>

1
fix.sh
View File

@ -120,4 +120,3 @@ gen_makefile()
}
gen_makefile makefile conf
gen_makefile jinete/makefile

View File

@ -25,8 +25,8 @@ ifdef PROFILE
LFLAGS += -pg
else
ifdef DEBUGMODE
CFLAGS += -g
LFLAGS += -g
CFLAGS += -g3
LFLAGS += -g3
else
CFLAGS += -s -O3
LFLAGS += -s -O3
@ -41,6 +41,10 @@ ifdef USE_PRECOMPILED_HEADER
CFLAGS += -DUSE_PRECOMPILED_HEADER
endif
ifdef USE_X86_INT_MULT
CFLAGS += -DUSE_X86_INT_MULT
endif
######################################################################
# Rules to make third party libraries
@ -93,6 +97,7 @@ VPATH = src \
src/jinete/themes \
src/modules \
src/raster \
src/raster/x86 \
src/script \
src/util \
src/widgets \
@ -139,6 +144,9 @@ endif
$(OBJ_DIR)/%$(OBJ): %.c
$(CC) $(CFLAGS) -o $@ -c $<
$(OBJ_DIR)/%$(OBJ): %.s
$(CC) $(CFLAGS) -x assembler-with-cpp -o $@ -c $<
$(OBJ_DIR)/art.%$(OBJ): %.c
$(CC) $(CFLAGS) -o $@ -c $<

View File

@ -213,6 +213,10 @@ COMMON_SOURCES = \
src/widgets/target.c \
src/widgets/toolbar.c
ifdef USE_X86_INT_MULT
COMMON_SOURCES += src/raster/x86/int_mult.s
endif
COMMON_OBJS = $(addprefix $(OBJ_DIR)/, \
$(addsuffix $(OBJ), \
$(notdir $(basename $(COMMON_SOURCES)))))

View File

@ -56,7 +56,7 @@ static void cmd_about_execute(const char *argument)
jfree(authors_txt);
}
else {
view = textbox = NULL;
view = textbox = separator2 = NULL;
}
label3 = jlabel_new(COPYRIGHT);

View File

@ -86,12 +86,12 @@ static void cmd_change_image_type_execute(const char *argument)
destimgtype = IMAGE_RGB;
else if (jwidget_is_selected(radio2))
destimgtype = IMAGE_GRAYSCALE;
else if (jwidget_is_selected(radio3))
else
destimgtype = IMAGE_INDEXED;
if (jwidget_is_selected(dither1))
dithermethod = DITHERING_NONE;
else if (jwidget_is_selected(dither2))
else
dithermethod = DITHERING_ORDERED;
use_current_sprite_rgb_map();

View File

@ -20,27 +20,22 @@
#ifndef USE_PRECOMPILED_HEADER
#include "jinete/jinete.h"
#include "jinete/jbase.h"
#include "commands/commands.h"
#include "core/app.h"
#include "dialogs/dpaledit.h"
#include "modules/sprites.h"
#include "raster/sprite.h"
#endif
static bool cmd_palette_editor_enabled(const char *argument)
{
return FALSE;
}
static void cmd_palette_editor_execute(const char *argument)
{
dialogs_palette_editor();
}
Command cmd_palette_editor = {
CMD_PALETTE_EDITOR,
cmd_palette_editor_enabled,
NULL,
NULL,
cmd_palette_editor_execute,
NULL

View File

@ -178,7 +178,7 @@ static Image *render_text (FONT *f, const char *text, int color)
#define DO(type, colfunc) \
{ \
register int c; \
unsigned long *src = (unsigned long *)bmp->dat; \
ase_uint32 *src = (ase_uint32 *)bmp->dat; \
type *dst = (type *)image->dat; \
for (i=0; i<pixels; i++) { \
c = *src; \
@ -192,13 +192,13 @@ static Image *render_text (FONT *f, const char *text, int color)
Image *image;
BITMAP *bmp;
w = text_length (f, text);
h = text_height (f);
w = text_length(f, text);
h = text_height(f);
pixels = w*h;
if (!pixels)
return NULL;
bmp = create_bitmap_ex (32, w, h);
bmp = create_bitmap_ex(32, w, h);
if (!bmp)
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));
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) {
destroy_bitmap (bmp);
destroy_bitmap(bmp);
return NULL;
}
image_clear (image, 0);
acquire_bitmap (bmp);
image_clear(image, 0);
acquire_bitmap(bmp);
switch (image->imgtype) {
case IMAGE_RGB:
DO(unsigned long, _rgba(_rgba_getr(color),
_rgba_getg(color),
_rgba_getb(color), getg32(c)));
DO(ase_uint32, _rgba(_rgba_getr(color),
_rgba_getg(color),
_rgba_getb(color), getg32(c)));
break;
case IMAGE_GRAYSCALE:
DO(unsigned short, _graya(_graya_getk(color), getg32(c)));
DO(ase_uint16, _graya(_graya_getk(color), getg32(c)));
break;
case IMAGE_INDEXED:
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();
break;
}
release_bitmap (bmp);
destroy_bitmap (bmp);
release_bitmap(bmp);
destroy_bitmap(bmp);
return image;
}
@ -248,38 +248,38 @@ static FONT *my_load_font (const char *filename)
char buf[256];
/* directories to search */
dirs = dirs_new ();
dirs = dirs_new();
dirs_add_path (dirs, filename);
dirs_add_path(dirs, filename);
usprintf (buf, "fonts/%s", filename);
dirs_cat_dirs (dirs, filename_in_datadir (buf));
usprintf(buf, "fonts/%s", filename);
dirs_cat_dirs(dirs, filename_in_datadir(buf));
usprintf (buf, "fonts/%s", get_filename (filename));
dirs_cat_dirs (dirs, filename_in_datadir (buf));
usprintf(buf, "fonts/%s", get_filename (filename));
dirs_cat_dirs(dirs, filename_in_datadir(buf));
/* search the font */
for (dir=dirs; dir; dir=dir->next) {
/* load the font */
f = ji_font_load (dir->path);
f = ji_font_load(dir->path);
if (f)
break;
else {
if (exists (dir->path))
PRINTF ("Unknown font format \"%s\"\n", dir->path);
if (exists(dir->path))
PRINTF("Unknown font format \"%s\"\n", dir->path);
}
}
dirs_free (dirs);
dirs_free(dirs);
/* error loading font */
if (!f)
console_printf (_("Error loading font.\n"));
console_printf(_("Error loading font.\n"));
return f;
}
static void button_font_command (JWidget widget)
static void button_font_command(JWidget widget)
{
char *filename;
@ -287,15 +287,15 @@ static void button_font_command (JWidget widget)
get_config_string ("DrawText", "Font", ""),
"pcx,bmp,tga,lbm,ttf");
if (filename) {
set_config_string ("DrawText", "Font", filename);
update_button_text ();
jfree (filename);
set_config_string("DrawText", "Font", filename);
update_button_text();
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));
}

View File

@ -100,10 +100,10 @@ static void speed_timer_callback (void)
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,
bool (*callback) ())
static void my_play_fli(const char *filename, bool loop, bool fullscreen,
bool (*callback)())
{
unsigned char cmap[768];
unsigned char omap[768];
@ -117,16 +117,16 @@ static void my_play_fli (const char *filename, bool loop, bool fullscreen,
FILE *f;
/* open the file to read in binary mode */
f = fopen (filename, "rb");
f = fopen(filename, "rb");
if (!f)
return;
/* read the header */
fli_read_header (f, &fli_header);
fseek (f, 128, SEEK_SET);
fli_read_header(f, &fli_header);
fseek(f, 128, SEEK_SET);
bmp = create_bitmap_ex (8, fli_header.width, fli_header.height);
old = 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);
/* stretch routine doesn't support bitmaps of different color depths */
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) {
/* read the frame */
fli_read_frame (f, &fli_header,
(unsigned char *)old->dat, omap,
(unsigned char *)bmp->dat, cmap);
fli_read_frame(f, &fli_header,
(unsigned char *)old->dat, omap,
(unsigned char *)bmp->dat, cmap);
if ((!frpos) || (memcmp (omap, cmap, 768) != 0)) {
for (c=i=0; c<256; c++) {

View File

@ -261,84 +261,84 @@ void set_color_curve(Curve *curve)
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;
unsigned long *dst_address;
ase_uint32 *src_address;
ase_uint32 *dst_address;
int x, c, r, g, b, a;
src_address = ((unsigned long **)effect->src->line)[effect->row+effect->y]+effect->x;
dst_address = ((unsigned long **)effect->dst->line)[effect->row+effect->y]+effect->x;
src_address = ((ase_uint32 **)effect->src->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++) {
if (effect->mask_address) {
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
src_address++;
dst_address++;
_image_bitmap_next_bit (effect->d, effect->mask_address);
_image_bitmap_next_bit(effect->d, effect->mask_address);
continue;
}
else
_image_bitmap_next_bit (effect->d, effect->mask_address);
_image_bitmap_next_bit(effect->d, effect->mask_address);
}
c = *(src_address++);
r = _rgba_getr (c);
g = _rgba_getg (c);
b = _rgba_getb (c);
a = _rgba_geta (c);
r = _rgba_getr(c);
g = _rgba_getg(c);
b = _rgba_getb(c);
a = _rgba_geta(c);
if (effect->target.r) r = data.cmap[r];
if (effect->target.g) g = data.cmap[g];
if (effect->target.b) b = data.cmap[b];
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)
{
unsigned short *src_address;
unsigned short *dst_address;
ase_uint16 *src_address;
ase_uint16 *dst_address;
int x, c, k, a;
src_address = ((unsigned short **)effect->src->line)[effect->row+effect->y]+effect->x;
dst_address = ((unsigned short **)effect->dst->line)[effect->row+effect->y]+effect->x;
src_address = ((ase_uint16 **)effect->src->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++) {
if (effect->mask_address) {
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
src_address++;
dst_address++;
_image_bitmap_next_bit (effect->d, effect->mask_address);
_image_bitmap_next_bit(effect->d, effect->mask_address);
continue;
}
else
_image_bitmap_next_bit (effect->d, effect->mask_address);
_image_bitmap_next_bit(effect->d, effect->mask_address);
}
c = *(src_address++);
k = _graya_getk (c);
a = _graya_geta (c);
k = _graya_getk(c);
a = _graya_geta(c);
if (effect->target.k) k = data.cmap[k];
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;
unsigned char *dst_address;
ase_uint8 *src_address;
ase_uint8 *dst_address;
int x, c, r, g, b;
src_address = ((unsigned char **)effect->src->line)[effect->row+effect->y]+effect->x;
dst_address = ((unsigned char **)effect->dst->line)[effect->row+effect->y]+effect->x;
src_address = ((ase_uint8 **)effect->src->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++) {
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];
}
*(dst_address++) = MID (0, c, 255);
*(dst_address++) = MID(0, c, 255);
}
}

View File

@ -68,7 +68,7 @@ ConvMatr *convmatr_new(int w, int h)
ConvMatr *convmatr;
int c, size;
convmatr = (ConvMatr *)jnew (ConvMatr, 1);
convmatr = (ConvMatr *)jnew(ConvMatr, 1);
if (!convmatr)
return NULL;
@ -318,13 +318,13 @@ JList get_convmatr_stock(void)
continue; \
}
void apply_convolution_matrix4 (Effect *effect)
void apply_convolution_matrix4(Effect *effect)
{
ConvMatr *matrix = data.convmatr;
Image *src = effect->src;
Image *dst = effect->dst;
unsigned long *src_address;
unsigned long *dst_address;
ase_uint32 *src_address;
ase_uint32 *dst_address;
int x, y, dx, dy, color;
int getx, gety, addx, addy;
int r, g, b, a;
@ -334,7 +334,7 @@ void apply_convolution_matrix4 (Effect *effect)
if (matrix) {
w = effect->x+effect->w;
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++) {
/* avoid the unmask region */
@ -350,16 +350,17 @@ void apply_convolution_matrix4 (Effect *effect)
r = g = b = a = 0;
GET_CONVMATR_DATA (unsigned long,
if (_rgba_geta (color) == 0)
div -= *mdata;
else {
r += _rgba_getr (color) * (*mdata);
g += _rgba_getg (color) * (*mdata);
b += _rgba_getb (color) * (*mdata);
a += _rgba_geta (color) * (*mdata);
}
);
GET_CONVMATR_DATA
(ase_uint32,
if (_rgba_geta(color) == 0)
div -= *mdata;
else {
r += _rgba_getr(color) * (*mdata);
g += _rgba_getg(color) * (*mdata);
b += _rgba_getb(color) * (*mdata);
a += _rgba_geta(color) * (*mdata);
}
);
if (effect->target.r) {
r = r / div + matrix->bias;
@ -399,8 +400,8 @@ void apply_convolution_matrix2 (Effect *effect)
ConvMatr *matrix = data.convmatr;
Image *src = effect->src;
Image *dst = effect->dst;
unsigned short *src_address;
unsigned short *dst_address;
ase_uint16 *src_address;
ase_uint16 *dst_address;
int x, y, dx, dy, color;
int getx, gety, addx, addy;
int k, a;
@ -410,7 +411,7 @@ void apply_convolution_matrix2 (Effect *effect)
if (matrix) {
w = effect->x+effect->w;
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++) {
/* avoid the unmask region */
@ -426,14 +427,15 @@ void apply_convolution_matrix2 (Effect *effect)
k = a = 0;
GET_CONVMATR_DATA (unsigned short,
if (_graya_geta (color) == 0)
div -= *mdata;
else {
k += _graya_getk (color) * (*mdata);
a += _graya_geta (color) * (*mdata);
}
);
GET_CONVMATR_DATA
(ase_uint16,
if (_graya_geta(color) == 0)
div -= *mdata;
else {
k += _graya_getk(color) * (*mdata);
a += _graya_geta(color) * (*mdata);
}
);
if (effect->target.k) {
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;
Image *src = effect->src;
Image *dst = effect->dst;
unsigned char *src_address;
unsigned char *dst_address;
ase_uint8 *src_address;
ase_uint8 *dst_address;
int x, y, dx, dy, color;
int getx, gety, addx, addy;
int r, g, b, index;
@ -470,7 +472,7 @@ void apply_convolution_matrix1 (Effect *effect)
if (matrix) {
w = effect->x+effect->w;
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++) {
/* avoid the unmask region */
@ -487,7 +489,7 @@ void apply_convolution_matrix1 (Effect *effect)
r = g = b = index = 0;
GET_CONVMATR_DATA
(unsigned char,
(ase_uint8,
r += _rgb_scale_6[current_palette[color].r] * (*mdata);
g += _rgb_scale_6[current_palette[color].g] * (*mdata);
b += _rgb_scale_6[current_palette[color].b] * (*mdata);
@ -496,7 +498,7 @@ void apply_convolution_matrix1 (Effect *effect)
if (effect->target.index) {
index = index / matrix->div + matrix->bias;
index = MID (0, index, 255);
index = MID(0, index, 255);
*(dst_address++) = index;
}
@ -510,14 +512,14 @@ void apply_convolution_matrix1 (Effect *effect)
if (effect->target.g) {
g = g / div + matrix->bias;
g = MID (0, g, 255);
g = MID(0, g, 255);
}
else
g = _rgb_scale_6[current_palette[color].g];
if (effect->target.b) {
b = b / div + matrix->bias;
b = MID (0, b, 255);
b = MID(0, b, 255);
}
else
b = _rgb_scale_6[current_palette[color].b];

View File

@ -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->mask) && (effect->mask->bitmap)) {
effect->d = div (effect->x-effect->mask->x+effect->offset_x, 8);
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;
}
else

View File

@ -26,14 +26,14 @@
#endif
void apply_invert_color4 (Effect *effect)
void apply_invert_color4(Effect *effect)
{
unsigned long *src_address;
unsigned long *dst_address;
ase_uint32 *src_address;
ase_uint32 *dst_address;
int x, c, r, g, b, a;
src_address = ((unsigned long **)effect->src->line)[effect->row+effect->y]+effect->x;
dst_address = ((unsigned long **)effect->dst->line)[effect->row+effect->y]+effect->x;
src_address = ((ase_uint32 **)effect->src->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++) {
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;
unsigned short *dst_address;
ase_uint16 *src_address;
ase_uint16 *dst_address;
int x, c, k, a;
src_address = ((unsigned short **)effect->src->line)[effect->row+effect->y]+effect->x;
dst_address = ((unsigned short **)effect->dst->line)[effect->row+effect->y]+effect->x;
src_address = ((ase_uint16 **)effect->src->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++) {
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;
unsigned char *dst_address;
ase_uint8 *src_address;
ase_uint8 *dst_address;
int x, c, r, g, b;
src_address = ((unsigned char **)effect->src->line)[effect->row+effect->y]+effect->x;
dst_address = ((unsigned char **)effect->dst->line)[effect->row+effect->y]+effect->x;
src_address = ((ase_uint8 **)effect->src->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++) {
if (effect->mask_address) {
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
src_address++;
dst_address++;
_image_bitmap_next_bit (effect->d, effect->mask_address);
_image_bitmap_next_bit(effect->d, effect->mask_address);
continue;
}
else
_image_bitmap_next_bit (effect->d, effect->mask_address);
_image_bitmap_next_bit(effect->d, effect->mask_address);
}
c = *(src_address++);

View File

@ -36,7 +36,7 @@ static struct {
unsigned char *channel[4];
} 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;
@ -49,7 +49,7 @@ void set_median_size (int w, int h)
if (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);
}
void apply_median4 (Effect *effect)
void apply_median4(Effect *effect)
{
Image *src = effect->src;
Image *dst = effect->dst;
unsigned long *src_address;
unsigned long *dst_address;
ase_uint32 *src_address;
ase_uint32 *dst_address;
int x, y, dx, dy, color;
int c, w, r, g, b, a;
int getx, gety, addx, addy;
w = effect->x+effect->w;
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++) {
/* avoid the unmask region */
@ -86,14 +86,15 @@ void apply_median4 (Effect *effect)
c = 0;
GET_MATRIX_DATA (unsigned long, data.w, data.h, data.w/2, data.h/2,
color = *src_address;
data.channel[0][c] = _rgba_getr (color);
data.channel[1][c] = _rgba_getg (color);
data.channel[2][c] = _rgba_getb (color);
data.channel[3][c] = _rgba_geta (color);
c++;
);
GET_MATRIX_DATA
(ase_uint32, data.w, data.h, data.w/2, data.h/2,
color = *src_address;
data.channel[0][c] = _rgba_getr (color);
data.channel[1][c] = _rgba_getg (color);
data.channel[2][c] = _rgba_getb (color);
data.channel[3][c] = _rgba_geta (color);
c++;
);
for (c=0; c<4; c++)
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 *dst = effect->dst;
unsigned short *src_address;
unsigned short *dst_address;
ase_uint16 *src_address;
ase_uint16 *dst_address;
int x, y, dx, dy, color;
int c, w, k, a;
int getx, gety, addx, addy;
w = effect->x+effect->w;
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++) {
/* avoid the unmask region */
@ -152,12 +153,13 @@ void apply_median2 (Effect *effect)
c = 0;
GET_MATRIX_DATA (unsigned short, data.w, data.h, data.w/2, data.h/2,
color = *src_address;
data.channel[0][c] = _graya_getk (color);
data.channel[1][c] = _graya_geta (color);
c++;
);
GET_MATRIX_DATA
(ase_uint16, data.w, data.h, data.w/2, data.h/2,
color = *src_address;
data.channel[0][c] = _graya_getk(color);
data.channel[1][c] = _graya_geta(color);
c++;
);
for (c=0; c<2; c++)
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 *dst = effect->dst;
unsigned char *src_address;
unsigned char *dst_address;
ase_uint8 *src_address;
ase_uint8 *dst_address;
int x, y, dx, dy, color;
int c, w, r, g, b;
int getx, gety, addx, addy;
w = effect->x+effect->w;
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++) {
/* avoid the unmask region */
@ -206,24 +208,25 @@ void apply_median1 (Effect *effect)
c = 0;
GET_MATRIX_DATA (unsigned char, data.w, data.h, data.w/2, data.h/2,
color = *src_address;
if (effect->target.index) {
data.channel[0][c] = color;
}
else {
data.channel[0][c] = _rgb_scale_6[current_palette[color].r];
data.channel[1][c] = _rgb_scale_6[current_palette[color].g];
data.channel[2][c] = _rgb_scale_6[current_palette[color].b];
}
c++;
);
GET_MATRIX_DATA
(ase_uint8, data.w, data.h, data.w/2, data.h/2,
color = *src_address;
if (effect->target.index) {
data.channel[0][c] = color;
}
else {
data.channel[0][c] = _rgb_scale_6[current_palette[color].r];
data.channel[1][c] = _rgb_scale_6[current_palette[color].g];
data.channel[2][c] = _rgb_scale_6[current_palette[color].b];
}
c++;
);
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 {
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) {

View File

@ -38,40 +38,40 @@ void set_replace_colors (int from, int to, int fuzziness)
data.fuzziness = MID (0, fuzziness, 255);
}
void apply_replace_color4 (Effect *effect)
void apply_replace_color4(Effect *effect)
{
unsigned long *src_address;
unsigned long *dst_address;
ase_uint32 *src_address;
ase_uint32 *dst_address;
int src_r, src_g, src_b, src_a;
int dst_r, dst_g, dst_b, dst_a;
int x, c;
src_address = ((unsigned long **)effect->src->line)[effect->row+effect->y]+effect->x;
dst_address = ((unsigned long **)effect->dst->line)[effect->row+effect->y]+effect->x;
src_address = ((ase_uint32 **)effect->src->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_g = _rgba_getg (data.from);
dst_b = _rgba_getb (data.from);
dst_a = _rgba_geta (data.from);
dst_r = _rgba_getr(data.from);
dst_g = _rgba_getg(data.from);
dst_b = _rgba_getb(data.from);
dst_a = _rgba_geta(data.from);
for (x=0; x<effect->w; x++) {
if (effect->mask_address) {
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
src_address++;
dst_address++;
_image_bitmap_next_bit (effect->d, effect->mask_address);
_image_bitmap_next_bit(effect->d, effect->mask_address);
continue;
}
else
_image_bitmap_next_bit (effect->d, effect->mask_address);
_image_bitmap_next_bit(effect->d, effect->mask_address);
}
c = *(src_address++);
src_r = _rgba_getr (c);
src_g = _rgba_getg (c);
src_b = _rgba_getb (c);
src_a = _rgba_geta (c);
src_r = _rgba_getr(c);
src_g = _rgba_getg(c);
src_b = _rgba_getb(c);
src_a = _rgba_geta(c);
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) &&
@ -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;
unsigned short *dst_address;
ase_uint16 *src_address;
ase_uint16 *dst_address;
int src_k, src_a;
int dst_k, dst_a;
int x, c;
src_address = ((unsigned short **)effect->src->line)[effect->row+effect->y]+effect->x;
dst_address = ((unsigned short **)effect->dst->line)[effect->row+effect->y]+effect->x;
src_address = ((ase_uint16 **)effect->src->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_a = _graya_geta (data.from);
dst_k = _graya_getk(data.from);
dst_a = _graya_geta(data.from);
for (x=0; x<effect->w; x++) {
if (effect->mask_address) {
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
src_address++;
dst_address++;
_image_bitmap_next_bit (effect->d, effect->mask_address);
_image_bitmap_next_bit(effect->d, effect->mask_address);
continue;
}
else
_image_bitmap_next_bit (effect->d, effect->mask_address);
_image_bitmap_next_bit(effect->d, effect->mask_address);
}
c = *(src_address++);
src_k = _graya_getk (c);
src_a = _graya_geta (c);
src_k = _graya_getk(c);
src_a = _graya_geta(c);
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))
@ -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;
unsigned char *dst_address;
ase_uint8 *src_address;
ase_uint8 *dst_address;
int x, c;
src_address = ((unsigned char **)effect->src->line)[effect->row+effect->y]+effect->x;
dst_address = ((unsigned char **)effect->dst->line)[effect->row+effect->y]+effect->x;
src_address = ((ase_uint8 **)effect->src->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++) {
if (effect->mask_address) {
if (!((*effect->mask_address) & (1<<effect->d.rem))) {
src_address++;
dst_address++;
_image_bitmap_next_bit (effect->d, effect->mask_address);
_image_bitmap_next_bit(effect->d, effect->mask_address);
continue;
}
else
_image_bitmap_next_bit (effect->d, effect->mask_address);
_image_bitmap_next_bit(effect->d, effect->mask_address);
}
c = *(src_address++);

View File

@ -48,25 +48,25 @@ typedef struct ASE_Header
{
long pos;
unsigned long size;
unsigned short magic;
unsigned short frames;
unsigned short width;
unsigned short height;
unsigned short depth;
unsigned long flags;
unsigned short speed; /* deprecated, use "duration" of FrameHeader */
unsigned long next;
unsigned long frit;
unsigned char bgcolor[4];
ase_uint32 size;
ase_uint16 magic;
ase_uint16 frames;
ase_uint16 width;
ase_uint16 height;
ase_uint16 depth;
ase_uint32 flags;
ase_uint16 speed; /* deprecated, use "duration" of FrameHeader */
ase_uint32 next;
ase_uint32 frit;
ase_uint8 bgcolor[4];
} ASE_Header;
typedef struct ASE_FrameHeader
{
unsigned long size;
unsigned short magic;
unsigned short chunks;
unsigned short duration;
ase_uint32 size;
ase_uint16 magic;
ase_uint16 chunks;
ase_uint16 duration;
} ASE_FrameHeader;
static Sprite *load_ASE(const char *filename);

View File

@ -56,11 +56,11 @@ FileFormat format_bmp =
typedef struct BITMAPFILEHEADER
{
unsigned long bfType;
unsigned long bfSize;
unsigned short bfReserved1;
unsigned short bfReserved2;
unsigned long bfOffBits;
ase_uint32 bfType;
ase_uint32 bfSize;
ase_uint16 bfReserved1;
ase_uint16 bfReserved2;
ase_uint32 bfOffBits;
} BITMAPFILEHEADER;
/* Used for both OS/2 and Windows BMP.
@ -68,38 +68,38 @@ typedef struct BITMAPFILEHEADER
*/
typedef struct BITMAPINFOHEADER
{
unsigned long biWidth;
unsigned long biHeight;
unsigned short biBitCount;
unsigned long biCompression;
ase_uint32 biWidth;
ase_uint32 biHeight;
ase_uint16 biBitCount;
ase_uint32 biCompression;
} BITMAPINFOHEADER;
typedef struct WINBMPINFOHEADER /* size: 40 */
{
unsigned long biWidth;
unsigned long biHeight;
unsigned short biPlanes;
unsigned short biBitCount;
unsigned long biCompression;
unsigned long biSizeImage;
unsigned long biXPelsPerMeter;
unsigned long biYPelsPerMeter;
unsigned long biClrUsed;
unsigned long biClrImportant;
ase_uint32 biWidth;
ase_uint32 biHeight;
ase_uint16 biPlanes;
ase_uint16 biBitCount;
ase_uint32 biCompression;
ase_uint32 biSizeImage;
ase_uint32 biXPelsPerMeter;
ase_uint32 biYPelsPerMeter;
ase_uint32 biClrUsed;
ase_uint32 biClrImportant;
} WINBMPINFOHEADER;
typedef struct OS2BMPINFOHEADER /* size: 12 */
{
unsigned short biWidth;
unsigned short biHeight;
unsigned short biPlanes;
unsigned short biBitCount;
ase_uint16 biWidth;
ase_uint16 biHeight;
ase_uint16 biPlanes;
ase_uint16 biBitCount;
} OS2BMPINFOHEADER;
/* read_bmfileheader:
* 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->bfSize= pack_igetl(f);
@ -116,7 +116,7 @@ static int read_bmfileheader (PACKFILE *f, BITMAPFILEHEADER *fileheader)
/* read_win_bminfoheader:
* 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;
@ -142,7 +142,7 @@ static int read_win_bminfoheader (PACKFILE *f, BITMAPINFOHEADER *infoheader)
/* read_os2_bminfoheader:
* 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;
@ -162,7 +162,7 @@ static int read_os2_bminfoheader (PACKFILE *f, BITMAPINFOHEADER *infoheader)
/* read_bmicolors:
* 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;
@ -179,7 +179,7 @@ static void read_bmicolors (int ncols, PACKFILE *f,int win_flag)
/* read_1bit_line:
* 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 long n;
@ -203,7 +203,7 @@ static void read_1bit_line (int length, PACKFILE *f, Image *image, int line)
/* read_4bit_line:
* 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 long n;
@ -231,7 +231,7 @@ static void read_4bit_line (int length, PACKFILE *f, Image *image, int line)
/* read_8bit_line:
* 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 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
* 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;
RGB c;
@ -280,7 +280,7 @@ static void read_24bit_line (int length, PACKFILE *f, Image *image, int line)
/* read_image:
* 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;
@ -314,7 +314,7 @@ static void read_image (PACKFILE *f, Image *image, AL_CONST BITMAPINFOHEADER *in
/* read_RLE8_compressed_image:
* 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;
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:
* 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 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 bytesPerPixel;
@ -694,15 +694,15 @@ static int save_BMP(Sprite *sprite)
for (j=0; j<image->w; j++) {
if (bpp == 8) {
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)
pack_putc (_graya_getk (image->method->getpixel (image, j, i)), f);
pack_putc(_graya_getk(image->method->getpixel(image, j, i)), f);
}
else {
c = image->method->getpixel (image, j, i);
pack_putc (_rgba_getb (c), f);
pack_putc (_rgba_getg (c), f);
pack_putc (_rgba_getr (c), f);
c = image->method->getpixel(image, j, i);
pack_putc(_rgba_getb(c), f);
pack_putc(_rgba_getg(c), f);
pack_putc(_rgba_getr(c), f);
}
}

View File

@ -101,7 +101,7 @@ static int save_ICO(Sprite *sprite)
image_clear(bmp, 0);
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;
bw = (((bmp->w * bpp / 8) + 3) / 4) * 4;
bitsw = ((((bmp->w + 7) / 8) + 3) / 4) * 4;

View File

@ -189,13 +189,13 @@ static Sprite *load_JPEG(const char *filename)
/* RGB */
if (image->imgtype == IMAGE_RGB) {
unsigned char *src_address;
unsigned long *dst_address;
ase_uint8 *src_address;
ase_uint32 *dst_address;
int x, y, r, g, b;
for (y=0; y<(int)num_scanlines; y++) {
src_address = ((unsigned char **)buffer)[y];
dst_address = ((unsigned long **)image->line)[cinfo.output_scanline-1+y];
src_address = ((ase_uint8 **)buffer)[y];
dst_address = ((ase_uint32 **)image->line)[cinfo.output_scanline-1+y];
for (x=0; x<image->w; x++) {
r = *(src_address++);
@ -207,13 +207,13 @@ static Sprite *load_JPEG(const char *filename)
}
/* Grayscale */
else {
unsigned char *src_address;
unsigned short *dst_address;
ase_uint8 *src_address;
ase_uint16 *dst_address;
int x, y;
for (y=0; y<(int)num_scanlines; y++) {
src_address = ((unsigned char **)buffer)[y];
dst_address = ((unsigned short **)image->line)[cinfo.output_scanline-1+y];
src_address = ((ase_uint8 **)buffer)[y];
dst_address = ((ase_uint16 **)image->line)[cinfo.output_scanline-1+y];
for (x=0; x<image->w; x++)
*(dst_address++) = _graya(*(src_address++), 255);
@ -325,12 +325,12 @@ static int save_JPEG(Sprite *sprite)
while (cinfo.next_scanline < cinfo.image_height) {
/* RGB */
if (image->imgtype == IMAGE_RGB) {
unsigned long *src_address;
unsigned char *dst_address;
ase_uint32 *src_address;
ase_uint8 *dst_address;
int x, y;
for (y=0; y<(int)buffer_height; y++) {
src_address = ((unsigned long **)image->line)[cinfo.next_scanline+y];
dst_address = ((unsigned char **)buffer)[y];
src_address = ((ase_uint32 **)image->line)[cinfo.next_scanline+y];
dst_address = ((ase_uint8 **)buffer)[y];
for (x=0; x<image->w; x++) {
c = *(src_address++);
*(dst_address++) = _rgba_getr(c);
@ -341,12 +341,12 @@ static int save_JPEG(Sprite *sprite)
}
/* Grayscale */
else {
unsigned short *src_address;
unsigned char *dst_address;
ase_uint16 *src_address;
ase_uint8 *dst_address;
int x, y;
for (y=0; y<(int)buffer_height; y++) {
src_address = ((unsigned short **)image->line)[cinfo.next_scanline+y];
dst_address = ((unsigned char **)buffer)[y];
src_address = ((ase_uint16 **)image->line)[cinfo.next_scanline+y];
dst_address = ((ase_uint8 **)buffer)[y];
for (x=0; x<image->w; x++)
*(dst_address++) = _graya_getk(*(src_address++));
}

View File

@ -127,14 +127,14 @@ static Sprite *load_PCX(const char *filename)
if (bpp == 8) {
while (c--) {
if (x < image->w)
*(((unsigned char **)image->line)[y]+x) = ch;
*(((ase_uint8 **)image->line)[y]+x) = ch;
x++;
}
}
else {
while (c--) {
if (xx < image->w)
*(((unsigned long **)image->line)[y]+xx) |= (ch & 0xff) << po;
*(((ase_uint32 **)image->line)[y]+xx) |= (ch & 0xff) << po;
x++;
if (x == bytes_per_line) {
xx = 0;
@ -169,13 +169,13 @@ static Sprite *load_PCX(const char *filename)
}
if (*allegro_errno) {
console_printf (_("Error reading bytes.\n"));
pack_fclose (f);
console_printf(_("Error reading bytes.\n"));
pack_fclose(f);
return NULL;
}
pack_fclose (f);
return file_sequence_sprite ();
pack_fclose(f);
return file_sequence_sprite();
}
static int save_PCX(Sprite *sprite)
@ -189,13 +189,13 @@ static int save_PCX(Sprite *sprite)
char runchar;
char ch = 0;
f = pack_fopen (sprite->filename, F_WRITE);
f = pack_fopen(sprite->filename, F_WRITE);
if (!f) {
console_printf (_("Error creating file.\n"));
console_printf(_("Error creating file.\n"));
return -1;
}
image = file_sequence_image_to_save ();
image = file_sequence_image_to_save();
if (sprite->imgtype == IMAGE_RGB) {
depth = 24;
@ -249,16 +249,16 @@ static int save_PCX(Sprite *sprite)
}
else {
if (x < image->w) {
c = image->method->getpixel (image, x, y);
ch = _rgba_getr (c);
c = image->method->getpixel(image, x, y);
ch = _rgba_getr(c);
}
else if (x<image->w*2) {
c = image->method->getpixel (image, x-image->w, y);
ch = _rgba_getg (c);
c = image->method->getpixel(image, x-image->w, y);
ch = _rgba_getg(c);
}
else {
c = image->method->getpixel (image, x-image->w*2, y);
ch = _rgba_getb (c);
c = image->method->getpixel(image, x-image->w*2, y);
ch = _rgba_getb(c);
}
}
if (runcount == 0) {
@ -284,7 +284,7 @@ static int save_PCX(Sprite *sprite)
pack_putc(runchar, f);
if (image->h > 1)
do_progress (100 * y / (image->h-1));
do_progress(100 * y / (image->h-1));
}
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) {
console_printf (_("Error writing bytes.\n"));
console_printf(_("Error writing bytes.\n"));
return -1;
}
else

View File

@ -217,8 +217,8 @@ static Sprite *load_PNG(const char *filename)
/* RGB_ALPHA */
if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
register unsigned char *src_address = row_pointer;
register unsigned long *dst_address = ((unsigned long **)image->line)[y];
register ase_uint8 *src_address = row_pointer;
register ase_uint32 *dst_address = ((ase_uint32 **)image->line)[y];
register int x, r, g, b, a;
for (x=0; x<width; x++) {
@ -231,8 +231,8 @@ static Sprite *load_PNG(const char *filename)
}
/* RGB */
else if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) {
register unsigned char *src_address = row_pointer;
register unsigned long *dst_address = ((unsigned long **)image->line)[y];
register ase_uint8 *src_address = row_pointer;
register ase_uint32 *dst_address = ((ase_uint32 **)image->line)[y];
register int x, r, g, b;
for (x=0; x<width; x++) {
@ -244,8 +244,8 @@ static Sprite *load_PNG(const char *filename)
}
/* GRAY_ALPHA */
else if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
register unsigned char *src_address = row_pointer;
register unsigned short *dst_address = ((unsigned short **)image->line)[y];
register ase_uint8 *src_address = row_pointer;
register ase_uint16 *dst_address = ((ase_uint16 **)image->line)[y];
register int x, k, a;
for (x=0; x<width; x++) {
@ -256,8 +256,8 @@ static Sprite *load_PNG(const char *filename)
}
/* GRAY */
else if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY) {
register unsigned char *src_address = row_pointer;
register unsigned short *dst_address = ((unsigned short **)image->line)[y];
register ase_uint8 *src_address = row_pointer;
register ase_uint16 *dst_address = ((ase_uint16 **)image->line)[y];
int x, k;
for (x=0; x<width; x++) {
@ -267,8 +267,8 @@ static Sprite *load_PNG(const char *filename)
}
/* PALETTE */
else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
register unsigned char *src_address = row_pointer;
register unsigned char *dst_address = ((unsigned char **)image->line)[y];
register ase_uint8 *src_address = row_pointer;
register ase_uint8 *dst_address = ((ase_uint8 **)image->line)[y];
register int x, c;
for (x=0; x<width; x++) {
@ -414,8 +414,8 @@ static int save_PNG(Sprite *sprite)
for (y = 0; y < height; y++) {
/* RGB_ALPHA */
if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
register unsigned long *src_address = ((unsigned long **)image->line)[y];
register unsigned char *dst_address = row_pointer;
register ase_uint32 *src_address = ((ase_uint32 **)image->line)[y];
register ase_uint8 *dst_address = row_pointer;
register int x, c;
for (x=0; x<width; x++) {
@ -428,8 +428,8 @@ static int save_PNG(Sprite *sprite)
}
/* RGB */
else if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) {
register unsigned long *src_address = ((unsigned long **)image->line)[y];
register unsigned char *dst_address = row_pointer;
register ase_uint32 *src_address = ((ase_uint32 **)image->line)[y];
register ase_uint8 *dst_address = row_pointer;
register int x, c;
for (x=0; x<width; x++) {
@ -441,8 +441,8 @@ static int save_PNG(Sprite *sprite)
}
/* GRAY_ALPHA */
else if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
register unsigned short *src_address = ((unsigned short **)image->line)[y];
register unsigned char *dst_address = row_pointer;
register ase_uint16 *src_address = ((ase_uint16 **)image->line)[y];
register ase_uint8 *dst_address = row_pointer;
register int x, c;
for (x=0; x<width; x++) {
@ -453,8 +453,8 @@ static int save_PNG(Sprite *sprite)
}
/* GRAY */
else if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY) {
register unsigned short *src_address = ((unsigned short **)image->line)[y];
register unsigned char *dst_address = row_pointer;
register ase_uint16 *src_address = ((ase_uint16 **)image->line)[y];
register ase_uint8 *dst_address = row_pointer;
register int x, c;
for (x=0; x<width; x++) {
@ -464,8 +464,8 @@ static int save_PNG(Sprite *sprite)
}
/* PALETTE */
else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
register unsigned char *src_address = ((unsigned char **)image->line)[y];
register unsigned char *dst_address = row_pointer;
register ase_uint8 *src_address = ((ase_uint8 **)image->line)[y];
register ase_uint8 *dst_address = row_pointer;
register int x;
for (x=0; x<width; x++)

View File

@ -69,8 +69,8 @@ static void rle_tga_read(unsigned char *address, int w, int type, PACKFILE *f)
if (type == 1)
*(address++) = value;
else {
*((unsigned short *)address) = value;
address += sizeof(unsigned short);
*((ase_uint16 *)address) = value;
address += sizeof(ase_uint16);
}
}
}
@ -83,8 +83,8 @@ static void rle_tga_read(unsigned char *address, int w, int type, PACKFILE *f)
}
else {
for (g=0; g<count; g++) {
*((unsigned short *)address) = pack_getc(f);
address += sizeof(unsigned short);
*((ase_uint16 *)address) = pack_getc(f);
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:
* 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];
int count;
@ -123,7 +123,7 @@ static void rle_tga_read32 (unsigned long *address, int w, PACKFILE *f)
/* rle_tga_read24:
* 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];
int count;
@ -152,10 +152,10 @@ static void rle_tga_read24 (unsigned long *address, int w, PACKFILE *f)
/* rle_tga_read16:
* 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 short color;
ase_uint32 color;
int count;
int c = 0;
@ -165,21 +165,21 @@ static void rle_tga_read16 (unsigned long *address, int w, PACKFILE *f)
count = (count & 0x7F) + 1;
c += count;
value = pack_igetw(f);
color = _rgba (_rgb_scale_5[((value >> 10) & 0x1F)],
_rgb_scale_5[((value >> 5) & 0x1F)],
_rgb_scale_5[(value & 0x1F)], 255);
color = _rgba(_rgb_scale_5[((value >> 10) & 0x1F)],
_rgb_scale_5[((value >> 5) & 0x1F)],
_rgb_scale_5[(value & 0x1F)], 255);
while (count--)
*(address++) = color;
*(address++) = color;
}
else {
count++;
c += count;
while (count--) {
value = pack_igetw(f);
color = _rgba (_rgb_scale_5[((value >> 10) & 0x1F)],
_rgb_scale_5[((value >> 5) & 0x1F)],
_rgb_scale_5[(value & 0x1F)], 255);
color = _rgba(_rgb_scale_5[((value >> 10) & 0x1F)],
_rgb_scale_5[((value >> 5) & 0x1F)],
_rgb_scale_5[(value & 0x1F)], 255);
*(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
* 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 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);
else {
for (x=0; x<image_width; x++)
*(((unsigned short **)image->line)[yc]+x) =
*(((ase_uint16 **)image->line)[yc]+x) =
_graya (pack_getc(f), 255);
}
break;
@ -345,36 +345,36 @@ static Sprite *load_TGA (const char *filename)
case 2:
if (bpp == 32) {
if (compressed) {
rle_tga_read32(image->line[yc], image_width, f);
rle_tga_read32((ase_uint32 *)image->line[yc], image_width, f);
}
else {
for (x=0; x<image_width; x++) {
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]);
}
}
}
else if (bpp == 24) {
if (compressed) {
rle_tga_read24(image->line[yc], image_width, f);
rle_tga_read24((ase_uint32 *)image->line[yc], image_width, f);
}
else {
for (x=0; x<image_width; x++) {
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);
}
}
}
else {
if (compressed) {
rle_tga_read16(image->line[yc], image_width, f);
rle_tga_read16((ase_uint32 *)image->line[yc], image_width, f);
}
else {
for (x=0; x<image_width; x++) {
c = pack_igetw(f);
*(((unsigned long **)image->line)[yc]+x) =
*(((ase_uint32 **)image->line)[yc]+x) =
_rgba (((c >> 10) & 0x1F),
((c >> 5) & 0x1F),
(c & 0x1F), 255);

View File

@ -109,7 +109,7 @@ END_OF_STATIC_FUNCTION(display_switch_in_callback);
*/
int init_module_gui(void)
{
int min_possible_dsk_res;
int min_possible_dsk_res = 0;
int c, w, h, bpp, autodetect;
bool fullscreen;

View File

@ -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)
{
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;
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)
{
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;
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)
{
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)
{
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;
int c = _rgba (_rgba_getr (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)
{
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;
int c = _graya (_graya_getk (tool_color), glass_dirty);
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)
{
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;
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]].b], 255);
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]].b], 255);
while (x--) {
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].b], 255),
tc, glass_dirty);
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].b], 255),
tc, glass_dirty);
/* *(address++) = rgb_map->data[_rgba_getr (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 */
/**********************************************************************/
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;
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;
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;
for (x=x1; x<=x2; x++) {

View File

@ -70,7 +70,7 @@ static int flooder (Image *image, int x, int y,
case IMAGE_RGB:
{
unsigned long *address = ((unsigned long **)image->line)[y];
ase_uint32 *address = ((ase_uint32 **)image->line)[y];
/* check start pixel */
if ((int)*(address+x) != src_color)
@ -92,7 +92,7 @@ static int flooder (Image *image, int x, int y,
case IMAGE_GRAYSCALE:
{
unsigned short *address = ((unsigned short **)image->line)[y];
ase_uint16 *address = ((ase_uint16 **)image->line)[y];
/* check start pixel */
if ((int)*(address+x) != src_color)
@ -114,7 +114,7 @@ static int flooder (Image *image, int x, int y,
case IMAGE_INDEXED:
{
unsigned char *address = ((unsigned char **)image->line)[y];
ase_uint8 *address = ((ase_uint8 **)image->line)[y];
/* check start pixel */
if ((int)*(address+x) != src_color)
@ -139,7 +139,7 @@ static int flooder (Image *image, int x, int y,
right--;
/* draw the line */
(*proc) (left, y, right, data);
(*proc)(left, y, right, data);
/* store it in the list of flooded segments */
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
* number of tests.
*/
static int check_flood_line (Image *image, int y, int left, int right,
int src_color, void *data, AlgoHLine proc)
static int check_flood_line(Image *image, int y, int left, int right,
int src_color, void *data, AlgoHLine proc)
{
int c;
FLOODED_LINE *p;
@ -214,7 +214,7 @@ static int check_flood_line (Image *image, int y, int left, int right,
/* floodfill:
* 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 c, done;
@ -241,7 +241,7 @@ void algo_floodfill (Image *image, int x, int y, void *data, AlgoHLine proc)
}
/* 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 */
do {
@ -255,8 +255,8 @@ void algo_floodfill (Image *image, int x, int y, void *data, AlgoHLine proc)
/* check below the segment? */
if (p->flags & FLOOD_TODO_BELOW) {
p->flags &= ~FLOOD_TODO_BELOW;
if (check_flood_line (image, p->y+1, p->lpos, p->rpos,
src_color, data, proc)) {
if (check_flood_line(image, p->y+1, p->lpos, p->rpos,
src_color, data, proc)) {
done = FALSE;
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? */
if (p->flags & FLOOD_TODO_ABOVE) {
p->flags &= ~FLOOD_TODO_ABOVE;
if (check_flood_line (image, p->y-1, p->lpos, p->rpos,
src_color, data, proc)) {
if (check_flood_line(image, p->y-1, p->lpos, p->rpos,
src_color, data, proc)) {
done = FALSE;
/* special case shortcut for going backwards */
if ((c < image->h) && (c > 0))

View File

@ -32,11 +32,11 @@
#endif
#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 T_VAR
# define NT_VAR register int t;
extern int _int_mult (int a, int b);
extern int _int_mult(int a, int b);
#else
# define T_VAR register int t;
# define NT_VAR

View File

@ -32,45 +32,45 @@
#define ADD_COLUMN() \
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) \
memmove (row->col+u+1, row->col+u, \
sizeof (struct DirtyCol) * (row->cols-1-u));
memmove(row->col+u+1, row->col+u, \
sizeof(struct DirtyCol) * (row->cols-1-u));
#define ADD_ROW() \
dirty->rows++; \
dirty->row = jrealloc (dirty->row, \
sizeof (struct DirtyRow) * dirty->rows); \
dirty->row = jrealloc(dirty->row, \
sizeof(struct DirtyRow) * dirty->rows); \
\
if (v < dirty->rows-1) \
memmove (dirty->row+v+1, dirty->row+v, \
sizeof (struct DirtyRow) * (dirty->rows-1-v));
memmove(dirty->row+v+1, dirty->row+v, \
sizeof(struct DirtyRow) * (dirty->rows-1-v));
#define RESTORE_IMAGE(u) \
if (row->col[u].flags & DIRTY_VALID_COLUMN) { \
row->col[u].flags ^= DIRTY_VALID_COLUMN; \
\
memcpy (row->col[u].ptr, \
row->col[u].data, \
DIRTY_LINE_SIZE (row->col[u].w)); \
memcpy(row->col[u].ptr, \
row->col[u].data, \
DIRTY_LINE_SIZE(row->col[u].w)); \
}
#define JOIN_WITH_NEXT() \
{ \
RESTORE_IMAGE (u+1); \
RESTORE_IMAGE(u+1); \
\
row->col[u].w += row->col[u+1].w; \
\
if (row->col[u+1].data) \
jfree (row->col[u+1].data); \
jfree(row->col[u+1].data); \
\
if (u+1 < row->cols-1) \
memmove (row->col+u+1, row->col+u+2, \
sizeof (struct DirtyCol) * (row->cols-2-u)); \
memmove(row->col+u+1, row->col+u+2, \
sizeof(struct DirtyCol) * (row->cols-2-u)); \
\
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() \
@ -88,25 +88,25 @@
/* "eat" columns */ \
if (u2 > u) { \
for (u3=u+1; u3<=u2; u3++) { \
RESTORE_IMAGE (u3); \
RESTORE_IMAGE(u3); \
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) \
memmove (row->col+u+1, row->col+u2+1, \
sizeof (struct DirtyCol) * (row->cols-u2-1)); \
memmove(row->col+u+1, row->col+u2+1, \
sizeof(struct DirtyCol) * (row->cols-u2-1)); \
\
row->cols -= u2 - u; \
row->col = jrealloc (row->col, \
sizeof (struct DirtyCol) * row->cols); \
row->col = jrealloc(row->col, \
sizeof(struct DirtyCol) * row->cols); \
} \
\
row->col[u].w = to_x2 - row->col[u].x + 1; \
row->col[u].data = jrealloc (row->col[u].data, \
DIRTY_LINE_SIZE (row->col[u].w));
row->col[u].data = jrealloc(row->col[u].data, \
DIRTY_LINE_SIZE(row->col[u].w));
typedef struct AlgoData
{
@ -115,28 +115,28 @@ typedef struct AlgoData
int thickness;
} AlgoData;
static void algo_putpixel (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_putpixel(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 *swap_hline (Image *image);
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_hline4 (void *image, void *data, int x1, int x2);
static void *swap_hline(Image *image);
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_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 *)jnew (Dirty, 1);
dirty = (Dirty *)jnew(Dirty, 1);
if (!dirty)
return NULL;
dirty->image = image;
dirty->x1 = MID (0, x1, image->w-1);
dirty->y1 = MID (0, y1, image->h-1);
dirty->x2 = MID (x1, x2, image->w-1);
dirty->y2 = MID (y1, y2, image->h-1);
dirty->x1 = MID(0, x1, image->w-1);
dirty->y1 = MID(0, y1, image->h-1);
dirty->x2 = MID(x1, x2, image->w-1);
dirty->y2 = MID(y1, y2, image->h-1);
dirty->tiled = tiled;
dirty->rows = 0;
dirty->row = NULL;
@ -145,22 +145,22 @@ Dirty *dirty_new (Image *image, int x1, int y1, int x2, int y2, int tiled)
return dirty;
}
Dirty *dirty_new_copy (Dirty *src)
Dirty *dirty_new_copy(Dirty *src)
{
int u, v, size;
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)
return NULL;
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++) {
dst->row[v].y = src->row[v].y;
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++) {
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].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);
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;
}
void dirty_free (Dirty *dirty)
void dirty_free(Dirty *dirty)
{
int u, v;
if (dirty->row) {
for (v=0; v<dirty->rows; v++) {
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;
int u, v;
@ -226,9 +226,9 @@ void dirty_putpixel (Dirty *dirty, int x, int y)
return;
if ((dirty->mask->bitmap) &&
!(dirty->mask->bitmap->method->getpixel (dirty->mask->bitmap,
x-dirty->mask->x,
y-dirty->mask->y)))
!(dirty->mask->bitmap->method->getpixel(dirty->mask->bitmap,
x-dirty->mask->x,
y-dirty->mask->y)))
return;
}
@ -245,7 +245,7 @@ void dirty_putpixel (Dirty *dirty, int x, int y)
/* we must add a new row? */
if (!row) {
ADD_ROW ();
ADD_ROW();
dirty->row[v].y = y;
dirty->row[v].cols = 0;
@ -261,16 +261,16 @@ void dirty_putpixel (Dirty *dirty, int x, int y)
return;
/* the pixel is to right of the column */
else if (x == row->col[u].x+row->col[u].w) {
RESTORE_IMAGE (u);
RESTORE_IMAGE(u);
row->col[u].w++;
/* there is a left column? */
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,
DIRTY_LINE_SIZE (row->col[u].w));
row->col[u].data = jrealloc(row->col[u].data,
DIRTY_LINE_SIZE(row->col[u].w));
return;
}
/* 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);
}
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;
int x, u, v, w/* , len */;
/* int u1, u2; */
int x, u, v, w;
int u2, u3, to_x2;
if (dirty->tiled) {
@ -320,7 +319,7 @@ void dirty_hline (Dirty *dirty, int x1, int y, int x2)
w = x2-x1+1;
if (w >= dirty->image->w)
dirty_hline (dirty, 0, y, dirty->image->w-1);
dirty_hline(dirty, 0, y, dirty->image->w-1);
else {
x = x1;
if (x < 0)
@ -329,10 +328,10 @@ void dirty_hline (Dirty *dirty, int x1, int y, int x2)
x = x % dirty->image->w;
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 {
dirty_hline (dirty, x, y, dirty->image->w-1);
dirty_hline (dirty, 0, y, w-(dirty->image->w-x)-1);
dirty_hline(dirty, x, y, dirty->image->w-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) {
for (; x1<=x2; x1++)
if (dirty->mask->bitmap->method->getpixel (dirty->mask->bitmap,
x1-dirty->mask->x,
y-dirty->mask->y))
if (dirty->mask->bitmap->method->getpixel(dirty->mask->bitmap,
x1-dirty->mask->x,
y-dirty->mask->y))
break;
for (; x2>=x1; x2--)
if (dirty->mask->bitmap->method->getpixel (dirty->mask->bitmap,
x2-dirty->mask->x,
y-dirty->mask->y))
if (dirty->mask->bitmap->method->getpixel(dirty->mask->bitmap,
x2-dirty->mask->x,
y-dirty->mask->y))
break;
}
@ -395,7 +394,7 @@ void dirty_hline (Dirty *dirty, int x1, int y, int x2)
/* we must add a new row? */
if (!row) {
ADD_ROW ();
ADD_ROW();
dirty->row[v].y = y;
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) {
for (x=x1; x<=x2; x++) {
if (!dirty->mask->bitmap->method->getpixel (dirty->mask->bitmap,
x-dirty->mask->x,
y-dirty->mask->y)) {
if (!dirty->mask->bitmap->method->getpixel(dirty->mask->bitmap,
x-dirty->mask->x,
y-dirty->mask->y)) {
continue;
}
@ -422,7 +421,7 @@ void dirty_hline (Dirty *dirty, int x1, int y, int x2)
goto done;
/* the pixel is in the right of the column */
else if (x == row->col[u].x+row->col[u].w) {
RESTORE_IMAGE (u);
RESTORE_IMAGE(u);
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) {
row->col[u+1].flags ^= DIRTY_VALID_COLUMN;
memcpy (row->col[u+1].ptr,
row->col[u+1].data,
DIRTY_LINE_SIZE (row->col[u+1].w));
memcpy(row->col[u+1].ptr,
row->col[u+1].data,
DIRTY_LINE_SIZE(row->col[u+1].w));
}
row->col[u].w += row->col[u+1].w;
/* remove the col[u+1] */
if (row->col[u+1].data)
jfree (row->col[u+1].data);
jfree(row->col[u+1].data);
if (u+1 < row->cols-1)
memmove (row->col+u+1, row->col+u+2,
sizeof (struct DirtyCol) * (row->cols-2-u));
memmove(row->col+u+1, row->col+u+2,
sizeof(struct DirtyCol) * (row->cols-2-u));
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,
DIRTY_LINE_SIZE (row->col[u].w));
row->col[u].data = jrealloc(row->col[u].data,
DIRTY_LINE_SIZE(row->col[u].w));
goto done;
}
/* 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) {
row->col[u].flags ^= DIRTY_VALID_COLUMN;
memcpy (row->col[u].ptr,
row->col[u].data,
DIRTY_LINE_SIZE (row->col[u].w));
memcpy(row->col[u].ptr,
row->col[u].data,
DIRTY_LINE_SIZE(row->col[u].w));
}
row->col[u].x--;
row->col[u].w++;
row->col[u].data = jrealloc (row->col[u].data,
DIRTY_LINE_SIZE (row->col[u].w));
row->col[u].data = jrealloc(row->col[u].data,
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;
}
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 */
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)
memmove (row->col+u+1, row->col+u,
sizeof (struct DirtyCol) * (row->cols-1-u));
memmove(row->col+u+1, row->col+u,
sizeof (struct DirtyCol) * (row->cols-1-u));
row->col[u].x = x;
row->col[u].w = 1;
row->col[u].flags = 0;
row->col[u].data = jmalloc (DIRTY_LINE_SIZE (1));
row->col[u].ptr = IMAGE_ADDRESS (dirty->image, x, y);
row->col[u].data = jmalloc(DIRTY_LINE_SIZE(1));
row->col[u].ptr = IMAGE_ADDRESS(dirty->image, x, y);
done:;
}
@ -507,14 +506,14 @@ void dirty_hline (Dirty *dirty, int x1, int y, int x2)
return;
/* extend this column to "x2" */
else {
RESTORE_IMAGE (u);
EAT_COLUMNS ();
RESTORE_IMAGE(u);
EAT_COLUMNS();
return;
}
}
/* the hline is to left of the column */
else if ((x1 < row->col[u].x) && (x2 >= row->col[u].x-1)) {
RESTORE_IMAGE (u);
RESTORE_IMAGE(u);
/* extend to left */
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 */
if (x2 <= row->col[u].x+row->col[u].w-1) {
row->col[u].data = jrealloc (row->col[u].data,
DIRTY_LINE_SIZE (row->col[u].w));
row->col[u].data = jrealloc(row->col[u].data,
DIRTY_LINE_SIZE(row->col[u].w));
return;
}
/* extend this column to "x2" */
else {
EAT_COLUMNS ();
EAT_COLUMNS();
return;
}
}
@ -539,41 +538,41 @@ void dirty_hline (Dirty *dirty, int x1, int y, int x2)
}
/* add a new column */
ADD_COLUMN ();
ADD_COLUMN();
row->col[u].x = x1;
row->col[u].w = x2-x1+1;
row->col[u].flags = 0;
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].data = jmalloc(DIRTY_LINE_SIZE(row->col[u].w));
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 };
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, y2, x2);
dirty_vline (dirty, x1, y1, y2);
dirty_vline (dirty, x2, y1, y2);
dirty_hline(dirty, x1, y1, x2);
dirty_hline(dirty, x1, y2, x2);
dirty_vline(dirty, x1, 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;
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) */
@ -591,35 +590,35 @@ void dirty_rectfill (Dirty *dirty, int x1, int y1, int x2, int y2)
/* (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 };
if (brush->size == 1)
algo_putpixel (x, y, &data);
algo_putpixel(x, y, &data);
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 };
int x;
if (brush->size == 1)
for (x=x1; x<=x2; x++)
algo_putpixel (x, y, &data);
algo_putpixel(x, y, &data);
else
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 };
algo_line (x1, y1, x2, y2, &data,
(brush->size == 1)?
(AlgoPixel)algo_putpixel:
(AlgoPixel)algo_putbrush);
algo_line(x1, y1, x2, y2, &data,
(brush->size == 1)?
(AlgoPixel)algo_putpixel:
(AlgoPixel)algo_putbrush);
}
/* 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;
shift = IMAGE_SHIFT (dirty->image);
shift = IMAGE_SHIFT(dirty->image);
for (v=0; v<dirty->rows; v++)
for (u=0; u<dirty->row[v].cols; u++) {
if (!(dirty->row[v].col[u].flags & DIRTY_VALID_COLUMN)) {
memcpy (dirty->row[v].col[u].data,
dirty->row[v].col[u].ptr,
dirty->row[v].col[u].w<<shift);
memcpy(dirty->row[v].col[u].data,
dirty->row[v].col[u].ptr,
dirty->row[v].col[u].w<<shift);
dirty->row[v].col[u].flags |= DIRTY_VALID_COLUMN;
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;
shift = IMAGE_SHIFT (dirty->image);
shift = IMAGE_SHIFT(dirty->image);
for (v=0; v<dirty->rows; v++)
for (u=0; u<dirty->row[v].cols; u++) {
if (dirty->row[v].col[u].flags & DIRTY_VALID_COLUMN) {
memcpy (dirty->row[v].col[u].ptr,
dirty->row[v].col[u].data,
dirty->row[v].col[u].w<<shift);
memcpy(dirty->row[v].col[u].ptr,
dirty->row[v].col[u].data,
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;
proc = swap_hline (dirty->image);
proc = swap_hline(dirty->image);
for (v=0; v<dirty->rows; v++)
for (u=0; u<dirty->row[v].cols; u++) {
if (dirty->row[v].col[u].flags & DIRTY_VALID_COLUMN) {
(*proc) (dirty->row[v].col[u].ptr,
dirty->row[v].col[u].data,
dirty->row[v].col[u].x,
dirty->row[v].col[u].x+dirty->row[v].col[u].w-1);
(*proc)(dirty->row[v].col[u].ptr,
dirty->row[v].col[u].data,
dirty->row[v].col[u].x,
dirty->row[v].col[u].x+dirty->row[v].col[u].w-1);
}
}
}
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) */
@ -746,7 +745,7 @@ static void algo_putbrush (int x, int y, AlgoData *data)
for (c=0; c<data->brush->size; c++) {
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++;
}
}
@ -764,10 +763,10 @@ static void *swap_hline (Image *image)
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;
unsigned char *address2 = data;
ase_uint8 *address1 = image;
ase_uint8 *address2 = data;
register int c;
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;
unsigned short *address2 = data;
ase_uint16 *address1 = image;
ase_uint16 *address2 = data;
register int c;
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;
unsigned long *address2 = data;
ase_uint32 *address1 = image;
ase_uint32 *address2 = data;
register int c;
int x;

View File

@ -28,21 +28,21 @@ struct Mask;
#define IMAGE_ADDRESS(d,x,y) \
((void *)((d)->imgtype == IMAGE_RGB)? \
(void *)(((unsigned long **)(d)->line)[(y)]+(x)): \
(void *)(((ase_uint32 **)(d)->line)[(y)]+(x)): \
((d)->imgtype == IMAGE_GRAYSCALE)? \
(void *)(((unsigned short **)(d)->line)[(y)]+(x)): \
(void *)(((ase_uint16 **)(d)->line)[(y)]+(x)): \
((d)->imgtype == IMAGE_INDEXED)? \
(void *)(((unsigned char **)(d)->line)[(y)]+(x)): 0)
(void *)(((ase_uint8 **)(d)->line)[(y)]+(x)): 0)
#define IMAGE_SHIFT(d) \
(((d)->imgtype == IMAGE_RGB)? 2: \
((d)->imgtype == IMAGE_GRAYSCALE)? 1: 0)
#define IMAGE_LINE_SIZE(image, width) \
((width) << IMAGE_SHIFT (image))
((width) << IMAGE_SHIFT(image))
#define DIRTY_LINE_SIZE(width) \
(IMAGE_LINE_SIZE (dirty->image, width))
(IMAGE_LINE_SIZE(dirty->image, width))
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_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_put(Dirty *dirty);

View File

@ -16,8 +16,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* #define USE_ALLEGRO_IMAGE */
#include "config.h"
#ifndef USE_PRECOMPILED_HEADER
@ -47,205 +45,7 @@ static ImageMethods *image_methods[] =
&bitmap_methods, /* IMAGE_BITMAP */
};
#else
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
#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,
};
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
#include "imgalleg.c"
#endif
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))
return NULL;
trim = image_new (image->imgtype, w, h);
trim = image_new(image->imgtype, w, h);
if (!trim)
return NULL;
image_clear (trim, 0);
image_copy (trim, image, -x, -y);
image_clear(trim, 0);
image_copy(trim, image, -x, -y);
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 (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)
@ -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;
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)
@ -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)
{
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)
{
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)
{
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)
{
image->method->to_allegro (image, bmp, x, y);
image->method->to_allegro(image, bmp, x, y);
}
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))
return;
else if (src->imgtype == dst->imgtype) {
image_copy (dst, src, 0, 0);
image_copy(dst, src, 0, 0);
return;
}
@ -507,14 +307,14 @@ void image_convert(Image *dst, const Image *src)
case IMAGE_GRAYSCALE:
for (y=0; y<h; y++) {
for (x=0; x<w; x++) {
c = src->method->getpixel (src, x, y);
rgb_to_hsv (_rgba_getr (c),
_rgba_getg (c),
_rgba_getb (c), &hue, &s, &v);
c = src->method->getpixel(src, x, y);
rgb_to_hsv(_rgba_getr(c),
_rgba_getg(c),
_rgba_getb(c), &hue, &s, &v);
v = v * 255.0f;
dst->method->putpixel (dst, x, y,
_graya((int)MID (0, v, 255),
_rgba_geta (c)));
dst->method->putpixel(dst, x, y,
_graya((int)MID(0, v, 255),
_rgba_geta(c)));
}
}
break;
@ -523,14 +323,14 @@ void image_convert(Image *dst, const Image *src)
case IMAGE_INDEXED:
for (y=0; y<h; y++) {
for (x=0; x<w; x++) {
c = src->method->getpixel (src, x, y);
c = src->method->getpixel(src, x, y);
if (!_rgba_geta (c))
dst->method->putpixel (dst, x, y, 0);
dst->method->putpixel(dst, x, y, 0);
else
dst->method->putpixel (dst, x, y,
makecol8 (_rgba_getr (c),
_rgba_getg (c),
_rgba_getb (c)));
dst->method->putpixel(dst, x, y,
makecol8(_rgba_getr(c),
_rgba_getg(c),
_rgba_getb(c)));
}
}
break;
@ -544,12 +344,12 @@ void image_convert(Image *dst, const Image *src)
case IMAGE_RGB:
for (y=0; y<h; y++) {
for (x=0; x<w; x++) {
c = src->method->getpixel (src, x, y);
dst->method->putpixel (dst, x, y,
_rgba (_graya_getk (c),
_graya_getk (c),
_graya_getk (c),
_graya_geta (c)));
c = src->method->getpixel(src, x, y);
dst->method->putpixel(dst, x, y,
_rgba(_graya_getk(c),
_graya_getk(c),
_graya_getk(c),
_graya_geta(c)));
}
}
break;
@ -558,14 +358,14 @@ void image_convert(Image *dst, const Image *src)
case IMAGE_INDEXED:
for (y=0; y<h; y++) {
for (x=0; x<w; x++) {
c = src->method->getpixel (src, x, y);
c = src->method->getpixel(src, x, y);
if (!_graya_geta (c))
dst->method->putpixel (dst, x, y, 0);
dst->method->putpixel(dst, x, y, 0);
else
dst->method->putpixel (dst, x, y,
makecol8 (_graya_getk (c),
_graya_getk (c),
_graya_getk (c)));
dst->method->putpixel(dst, x, y,
makecol8(_graya_getk(c),
_graya_getk(c),
_graya_getk(c)));
}
}
break;
@ -579,14 +379,14 @@ void image_convert(Image *dst, const Image *src)
case IMAGE_RGB:
for (y=0; y<h; y++) {
for (x=0; x<w; x++) {
c = src->method->getpixel (src, x, y);
c = src->method->getpixel(src, x, y);
if (!c)
dst->method->putpixel (dst, x, y, 0);
dst->method->putpixel(dst, x, y, 0);
else
dst->method->putpixel (dst, x, y,
_rgba (getr8 (c),
getg8 (c),
getb8 (c), 255));
dst->method->putpixel(dst, x, y,
_rgba(getr8(c),
getg8(c),
getb8(c), 255));
}
}
break;
@ -595,14 +395,14 @@ void image_convert(Image *dst, const Image *src)
case IMAGE_GRAYSCALE:
for (y=0; y<h; y++) {
for (x=0; x<w; x++) {
c = src->method->getpixel (src, x, y);
c = src->method->getpixel(src, x, y);
if (!c)
dst->method->putpixel (dst, x, y, 0);
dst->method->putpixel(dst, x, y, 0);
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;
dst->method->putpixel (dst, x, y,
_graya ((int)MID (0, v, 255), 255));
dst->method->putpixel(dst, x, y,
_graya((int)MID(0, v, 255), 255));
}
}
}
@ -625,8 +425,8 @@ int image_count_diff(const Image *i1, const Image *i2)
case IMAGE_RGB:
{
unsigned long *address1 = (unsigned long *)i1->dat;
unsigned long *address2 = (unsigned long *)i2->dat;
ase_uint32 *address1 = (ase_uint32 *)i1->dat;
ase_uint32 *address2 = (ase_uint32 *)i2->dat;
for (c=0; c<size; c++)
if (*(address1++) != *(address2++))
diff++;
@ -635,8 +435,8 @@ int image_count_diff(const Image *i1, const Image *i2)
case IMAGE_GRAYSCALE:
{
unsigned short *address1 = (unsigned short *)i1->dat;
unsigned short *address2 = (unsigned short *)i2->dat;
ase_uint16 *address1 = (ase_uint16 *)i1->dat;
ase_uint16 *address2 = (ase_uint16 *)i2->dat;
for (c=0; c<size; c++)
if (*(address1++) != *(address2++))
diff++;
@ -645,8 +445,8 @@ int image_count_diff(const Image *i1, const Image *i2)
case IMAGE_INDEXED:
{
unsigned char *address1 = (unsigned char *)i1->dat;
unsigned char *address2 = (unsigned char *)i2->dat;
ase_uint8 *address1 = (ase_uint8 *)i1->dat;
ase_uint8 *address2 = (ase_uint8 *)i2->dat;
for (c=0; c<size; c++)
if (*(address1++) != *(address2++))
diff++;
@ -656,8 +456,8 @@ int image_count_diff(const Image *i1, const Image *i2)
case IMAGE_BITMAP:
/* TODO test it */
{
unsigned char *address1 = (unsigned char *)i1->dat;
unsigned char *address2 = (unsigned char *)i2->dat;
ase_uint8 *address1 = (ase_uint8 *)i1->dat;
ase_uint8 *address2 = (ase_uint8 *)i2->dat;
div_t d1 = div (0, 8);
div_t d2 = div (0, 8);
for (c=0; c<size; c++) {

View File

@ -19,26 +19,28 @@
#ifndef RASTER_IMAGE_H
#define RASTER_IMAGE_H
/* #define USE_ALLEGRO_IMAGE */
#include "raster/gfxobj.h"
#define _rgba_r_shift 0
#define _rgba_g_shift 8
#define _rgba_b_shift 16
#define _rgba_a_shift 24
#define _rgba_getr(c) (((c) >> _rgba_r_shift) & 0xff)
#define _rgba_getg(c) (((c) >> _rgba_g_shift) & 0xff)
#define _rgba_getb(c) (((c) >> _rgba_b_shift) & 0xff)
#define _rgba_geta(c) (((c) >> _rgba_a_shift) & 0xff)
#define _rgba_r_shift 0
#define _rgba_g_shift 8
#define _rgba_b_shift 16
#define _rgba_a_shift 24
#define _rgba_getr(c) (((c) >> _rgba_r_shift) & 0xff)
#define _rgba_getg(c) (((c) >> _rgba_g_shift) & 0xff)
#define _rgba_getb(c) (((c) >> _rgba_b_shift) & 0xff)
#define _rgba_geta(c) (((c) >> _rgba_a_shift) & 0xff)
#define _rgba(r,g,b,a) \
(((r) << _rgba_r_shift) | \
((g) << _rgba_g_shift) | \
((b) << _rgba_b_shift) | \
((a) << _rgba_a_shift))
#define _graya_k_shift 0
#define _graya_a_shift 8
#define _graya_getk(c) (((c) >> _graya_k_shift) & 0xff)
#define _graya_geta(c) (((c) >> _graya_a_shift) & 0xff)
#define _graya_k_shift 0
#define _graya_a_shift 8
#define _graya_getk(c) (((c) >> _graya_k_shift) & 0xff)
#define _graya_geta(c) (((c) >> _graya_a_shift) & 0xff)
#define _graya(k,a) \
(((k) << _graya_k_shift) | \
((a) << _graya_a_shift))
@ -69,10 +71,12 @@ struct Image
GfxObj gfxobj;
int imgtype;
int w, h;
unsigned char *dat; /* pixmap data */
unsigned char **line; /* start of each scanline */
ase_uint8 *dat; /* pixmap data */
ase_uint8 **line; /* start of each scanline */
struct ImageMethods *method;
// struct BITMAP *bmp;
#ifdef USE_ALLEGRO_IMAGE
struct BITMAP *bmp;
#endif
};
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_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_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);
void image_to_allegro(Image *image, struct BITMAP *bmp, int x, int y);

209
src/raster/imgalleg.c Normal file
View 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,
};

View File

@ -19,8 +19,8 @@
#undef BYTES
#undef LINES
#define BYTES(image) ((unsigned char *)image->dat)
#define LINES(image) ((unsigned char **)image->line)
#define BYTES(image) ((ase_uint8 *)image->dat)
#define LINES(image) ((ase_uint8 **)image->line)
#define BITMAP_HLINE(op) \
for (x=x1; x<=x2; x++) { \
@ -28,48 +28,47 @@
_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;
if (LINES (image))
jfree (LINES (image));
if (LINES(image))
jfree(LINES(image));
image->line = jmalloc (sizeof (unsigned char *) * image->h);
if (!LINES (image))
image->line = jmalloc(sizeof(ase_uint8 *) * image->h);
if (!LINES(image))
return -1;
for (y=0; y<image->h; y++) {
LINES (image)[y] = address;
LINES(image)[y] = address;
address += (image->w+7)/8;
}
return 0;
}
static int bitmap_init (Image *image)
static int bitmap_init(Image *image)
{
image->dat = jmalloc (sizeof (unsigned char) *
((image->w+7)/8) * image->h);
if (!BYTES (image))
image->dat = jmalloc(sizeof(ase_uint8) * ((image->w+7)/8) * image->h);
if (!BYTES(image))
return -1;
if (bitmap_regenerate_lines (image) < 0) {
jfree (BYTES (image));
if (bitmap_regenerate_lines(image) < 0) {
jfree(BYTES(image));
return -1;
}
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);
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);
@ -79,15 +78,15 @@ static void bitmap_putpixel (Image *image, int x, int y, int color)
*(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;
unsigned char *dst_address;
ase_uint8 *src_address;
ase_uint8 *dst_address;
int xbeg, xend, xsrc, xdst;
int ybeg, yend, ysrc, ydst;
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,
int x, int y, int opacity, int blend_mode)
static void bitmap_merge(Image *dst, const Image *src,
int x, int y, int opacity, int blend_mode)
{
unsigned char *src_address;
unsigned char *dst_address;
ase_uint8 *src_address;
ase_uint8 *dst_address;
int xbeg, xend, xsrc, xdst;
int ybeg, yend, ysrc, ydst;
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);
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);
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;
int depth = bitmap_color_depth (bmp);
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
if (is_planar_bitmap (bmp)) {
for (y=0; y<image->h; y++) {
address = LINES (image)[y];
address = LINES(image)[y];
bmp_address = (unsigned long)bmp->line[_y];
d = beg_d;
for (x=0; x<image->w; x++) {
outportw (0x3C4, (0x100<<((_x+x)&3))|2);
bmp_write8 (bmp_address+((_x+x)>>2),
color[((*address) & (1<<d.rem))? 1: 0]);
_image_bitmap_next_bit (d, address);
bmp_write8(bmp_address+((_x+x)>>2),
color[((*address) & (1<<d.rem))? 1: 0]);
_image_bitmap_next_bit(d, address);
}
_y++;
@ -285,12 +284,12 @@ static void bitmap_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
#endif
for (y=0; y<image->h; y++) {
address = LINES (image)[y];
bmp_address = bmp_write_line (bmp, _y)+_x;
bmp_address = bmp_write_line(bmp, _y)+_x;
d = beg_d;
for (x=0; x<image->w; x++) {
bmp_write8 (bmp_address++, color[((*address) & (1<<d.rem))? 1: 0]);
_image_bitmap_next_bit (d, address);
_image_bitmap_next_bit(d, address);
}
_y++;
@ -301,20 +300,20 @@ static void bitmap_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
break;
case 15:
color[0] = makecol15 (0, 0, 0);
color[1] = makecol15 (255, 255, 255);
color[0] = makecol15(0, 0, 0);
color[1] = makecol15(255, 255, 255);
_x <<= 1;
for (y=0; y<image->h; y++) {
address = LINES (image)[y];
bmp_address = bmp_write_line (bmp, _y)+_x;
bmp_address = bmp_write_line(bmp, _y)+_x;
d = beg_d;
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;
_image_bitmap_next_bit (d, address);
_image_bitmap_next_bit(d, address);
}
_y++;
@ -322,20 +321,20 @@ static void bitmap_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
break;
case 16:
color[0] = makecol16 (0, 0, 0);
color[1] = makecol16 (255, 255, 255);
color[0] = makecol16(0, 0, 0);
color[1] = makecol16(255, 255, 255);
_x <<= 1;
for (y=0; y<image->h; y++) {
address = LINES (image)[y];
bmp_address = bmp_write_line (bmp, _y)+_x;
bmp_address = bmp_write_line(bmp, _y)+_x;
d = beg_d;
for (x=0; x<image->w; x++) {
bmp_write16(bmp_address, color[((*address) & (1<<d.rem))? 1: 0]);
bmp_address += 2;
_image_bitmap_next_bit (d, address);
_image_bitmap_next_bit(d, address);
}
_y++;

View File

@ -19,18 +19,18 @@
#undef BYTES
#undef LINES
#define BYTES(image) ((unsigned short *)image->dat)
#define LINES(image) ((unsigned short **)image->line)
#define BYTES(image) ((ase_uint16 *)image->dat)
#define LINES(image) ((ase_uint16 **)image->line)
static int grayscale_regenerate_lines (Image *image)
{
unsigned short *address = BYTES (image);
ase_uint16 *address = BYTES (image);
int y;
if (LINES (image))
jfree (LINES (image));
image->line = jmalloc (sizeof (unsigned short *) * image->h);
image->line = jmalloc (sizeof (ase_uint16 *) * image->h);
if (!LINES (image))
return -1;
@ -44,7 +44,7 @@ static int grayscale_regenerate_lines (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))
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)
{
unsigned short *address = BYTES (image);
ase_uint16 *address = BYTES (image);
int c, size = image->w * image->h;
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)
{
unsigned short *src_address;
unsigned short *dst_address;
ase_uint16 *src_address;
ase_uint16 *dst_address;
int xbeg, xend, xsrc;
int ybeg, yend, ysrc, ydst;
int bytes;
@ -129,8 +129,8 @@ static void grayscale_merge (Image *dst, const Image *src,
int x, int y, int opacity, int blend_mode)
{
BLEND_COLOR blender = _graya_blenders[blend_mode];
unsigned short *src_address;
unsigned short *dst_address;
ase_uint16 *src_address;
ase_uint16 *dst_address;
int xbeg, xend, xsrc, xdst;
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)
{
unsigned short *address = LINES (image)[y]+x1;
ase_uint16 *address = LINES (image)[y]+x1;
int 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)
{
unsigned short *address;
ase_uint16 *address;
int x, 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;
int depth = bitmap_color_depth (bmp);
int depth = bitmap_color_depth(bmp);
int x, y;
bmp_select (bmp);
@ -217,14 +217,14 @@ static void grayscale_to_allegro (const Image *image, BITMAP *bmp, int _x, int _
case 8:
#ifdef GFX_MODEX
if (is_planar_bitmap (bmp)) {
if (is_planar_bitmap(bmp)) {
for (y=0; y<image->h; y++) {
bmp_address = (unsigned long)bmp->line[_y];
for (x=0; x<image->w; x++) {
outportw (0x3C4, (0x100<<((_x+x)&3))|2);
bmp_write8 (bmp_address+((_x+x)>>2),
_index_cmap[(*address) & 0xff]);
outportw(0x3C4, (0x100<<((_x+x)&3))|2);
bmp_write8(bmp_address+((_x+x)>>2),
_index_cmap[(*address) & 0xff]);
address++;
}

View File

@ -19,18 +19,18 @@
#undef BYTES
#undef LINES
#define BYTES(image) ((unsigned char *)image->dat)
#define LINES(image) ((unsigned char **)image->line)
#define BYTES(image) ((ase_uint8 *)image->dat)
#define LINES(image) ((ase_uint8 **)image->line)
static int indexed_regenerate_lines(Image *image)
{
unsigned char *address = BYTES(image);
ase_uint8 *address = BYTES(image);
int y;
if (LINES(image))
jfree(LINES(image));
image->line = jmalloc(sizeof(unsigned char *) * image->h);
image->line = jmalloc(sizeof(ase_uint8 *) * image->h);
if (!LINES(image))
return -1;
@ -44,7 +44,7 @@ static int indexed_regenerate_lines(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))
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)
{
unsigned char *src_address;
unsigned char *dst_address;
ase_uint8 *src_address;
ase_uint8 *dst_address;
int xbeg, xend, xsrc;
int ybeg, yend, ysrc, ydst;
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;
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,
int x, int y, int opacity, int blend_mode)
{
unsigned char *src_address;
unsigned char *dst_address;
ase_uint8 *src_address;
ase_uint8 *dst_address;
int xbeg, xend, xsrc, xdst;
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)
{
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)
@ -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;
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)
@ -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)]].b]
unsigned char *address = BYTES (image);
ase_uint8 *address = BYTES(image);
unsigned long bmp_address;
int depth = bitmap_color_depth (bmp);
int depth = bitmap_color_depth(bmp);
int x, y;
bmp_select (bmp);
bmp_select(bmp);
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;
for (x=0; x<image->w; x++) {
bmp_write15(bmp_address, makecol15 (RGB_TRIPLET));
bmp_write15(bmp_address, makecol15(RGB_TRIPLET));
address++;
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;
for (x=0; x<image->w; x++) {
bmp_write16(bmp_address, makecol16 (RGB_TRIPLET));
bmp_write16(bmp_address, makecol16(RGB_TRIPLET));
address++;
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;
for (x=0; x<image->w; x++) {
bmp_write24(bmp_address, makecol24 (RGB_TRIPLET));
bmp_write24(bmp_address, makecol24(RGB_TRIPLET));
address++;
bmp_address += 3;
}
@ -312,10 +312,10 @@ static void indexed_to_allegro(const Image *image, BITMAP *bmp, int _x, int _y)
_x <<= 2;
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++) {
bmp_write32(bmp_address, makeacol32 (RGB_TRIPLET, 255));
bmp_write32(bmp_address, makeacol32(RGB_TRIPLET, 255));
address++;
bmp_address += 4;
}

View File

@ -19,18 +19,18 @@
#undef BYTES
#undef LINES
#define BYTES(image) ((unsigned long *)image->dat)
#define LINES(image) ((unsigned long **)image->line)
#define BYTES(image) ((ase_uint32 *)image->dat)
#define LINES(image) ((ase_uint32 **)image->line)
static int rgb_regenerate_lines (Image *image)
{
unsigned long *address = BYTES (image);
ase_uint32 *address = BYTES (image);
int y;
if (LINES (image))
jfree (LINES (image));
image->line = jmalloc (sizeof (unsigned long *) * image->h);
image->line = jmalloc(sizeof(ase_uint32 *) * image->h);
if (!LINES (image))
return -1;
@ -44,7 +44,7 @@ static int rgb_regenerate_lines (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))
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)
{
unsigned long *address = BYTES (image);
ase_uint32 *address = BYTES (image);
unsigned int c, size = image->w * image->h;
for (c=0; c<size; c++)
*(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;
unsigned long *dst_address;
ase_uint32 *src_address;
ase_uint32 *dst_address;
int xbeg, xend, xsrc;
int ybeg, yend, ysrc, ydst;
int bytes;
@ -129,8 +129,8 @@ static void rgb_merge (Image *dst, const Image *src,
int x, int y, int opacity, int blend_mode)
{
BLEND_COLOR blender = _rgba_blenders[blend_mode];
unsigned long *src_address;
unsigned long *dst_address;
ase_uint32 *src_address;
ase_uint32 *dst_address;
int xbeg, xend, xsrc, xdst;
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)
{
unsigned long *address = LINES (image)[y]+x1;
ase_uint32 *address = LINES (image)[y]+x1;
int 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)
{
unsigned long *address;
ase_uint32 *address;
int x, 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)
{
unsigned long *address = BYTES (image);
ase_uint32 *address = BYTES(image);
unsigned long bmp_address;
int depth = bitmap_color_depth (bmp);
int depth = bitmap_color_depth(bmp);
int x, y;
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];
for (x=0; x<image->w; x++) {
outportw (0x3C4, (0x100<<((_x+x)&3))|2);
bmp_write8 (bmp_address+((_x+x)>>2),
makecol8 ((*address) & 0xff,
((*address)>>8) & 0xff,
((*address)>>16) & 0xff));
outportw(0x3C4, (0x100<<((_x+x)&3))|2);
bmp_write8(bmp_address+((_x+x)>>2),
makecol8((*address) & 0xff,
((*address)>>8) & 0xff,
((*address)>>16) & 0xff));
address++;
}
@ -236,13 +236,13 @@ static void rgb_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
else {
#endif
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++) {
bmp_write8 (bmp_address,
makecol8 ((*address) & 0xff,
((*address)>>8) & 0xff,
((*address)>>16) & 0xff));
bmp_write8(bmp_address,
makecol8((*address) & 0xff,
((*address)>>8) & 0xff,
((*address)>>16) & 0xff));
address++;
bmp_address++;
}
@ -258,13 +258,13 @@ static void rgb_to_allegro (const Image *image, BITMAP *bmp, int _x, int _y)
_x <<= 1;
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++) {
bmp_write15 (bmp_address,
makecol15 ((*address) & 0xff,
((*address)>>8) & 0xff,
((*address)>>16) & 0xff));
bmp_write15(bmp_address,
makecol15((*address) & 0xff,
((*address)>>8) & 0xff,
((*address)>>16) & 0xff));
address++;
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;
for (x=0; x<image->w; x++) {
bmp_write16 (bmp_address,
makecol16 ((*address) & 0xff,
((*address)>>8) & 0xff,
((*address)>>16) & 0xff));
bmp_write16(bmp_address,
makecol16((*address) & 0xff,
((*address)>>8) & 0xff,
((*address)>>16) & 0xff));
address++;
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;
for (x=0; x<image->w; x++) {
bmp_write24 (bmp_address,
makecol24 ((*address) & 0xff,
((*address)>>8) & 0xff,
((*address)>>16) & 0xff));
bmp_write24(bmp_address,
makecol24((*address) & 0xff,
((*address)>>8) & 0xff,
((*address)>>16) & 0xff));
address++;
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;
for (x=0; x<image->w; x++) {
bmp_write32 (bmp_address,
makeacol32 ((*address) & 0xff,
((*address)>>8) & 0xff,
((*address)>>16) & 0xff,
((*address)>>24) & 0xff));
bmp_write32(bmp_address,
makeacol32((*address) & 0xff,
((*address)>>8) & 0xff,
((*address)>>16) & 0xff,
((*address)>>24) & 0xff));
address++;
bmp_address += 4;
}

View File

@ -117,16 +117,16 @@ void mask_none (Mask *mask)
}
}
void mask_invert (Mask *mask)
void mask_invert(Mask *mask)
{
if (mask->bitmap) {
unsigned char *address;
ase_uint8 *address;
int u, v;
div_t d;
for (v=0; v<mask->h; v++) {
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++) {
*address ^= (1<<d.rem);
_image_bitmap_next_bit (d, address);
@ -219,42 +219,42 @@ void mask_merge (Mask *mask, const Mask *src)
/* 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;
mask_replace (mask, 0, 0, src->w, src->h);
mask_replace(mask, 0, 0, src->w, src->h);
dst = mask->bitmap;
switch (src->imgtype) {
case IMAGE_RGB: {
unsigned long *src_address;
unsigned char *dst_address;
ase_uint32 *src_address;
ase_uint8 *dst_address;
int src_r, src_g, src_b, src_a;
int dst_r, dst_g, dst_b, dst_a;
int u, v, c;
div_t d;
dst_r = _rgba_getr (color);
dst_g = _rgba_getg (color);
dst_b = _rgba_getb (color);
dst_a = _rgba_geta (color);
dst_r = _rgba_getr(color);
dst_g = _rgba_getg(color);
dst_b = _rgba_getb(color);
dst_a = _rgba_geta(color);
for (v=0; v<src->h; v++) {
src_address = ((unsigned long **)src->line)[v];
dst_address = ((unsigned char **)dst->line)[v];
src_address = ((ase_uint32 **)src->line)[v];
dst_address = ((ase_uint8 **)dst->line)[v];
d = div (0, 8);
for (u=0; u<src->w; u++) {
c = *(src_address++);
src_r = _rgba_getr (c);
src_g = _rgba_getg (c);
src_b = _rgba_getb (c);
src_a = _rgba_geta (c);
src_r = _rgba_getr(c);
src_g = _rgba_getg(c);
src_b = _rgba_getb(c);
src_a = _rgba_geta(c);
if (!((src_r >= dst_r-fuzziness) && (src_r <= dst_r+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)))
(*dst_address) ^= (1 << d.rem);
_image_bitmap_next_bit (d, dst_address);
_image_bitmap_next_bit(d, dst_address);
}
}
} break;
case IMAGE_GRAYSCALE: {
unsigned short *src_address;
unsigned char *dst_address;
ase_uint16 *src_address;
ase_uint8 *dst_address;
int src_k, src_a;
int dst_k, dst_a;
int u, v, c;
div_t d;
dst_k = _graya_getk (color);
dst_a = _graya_geta (color);
dst_k = _graya_getk(color);
dst_a = _graya_geta(color);
for (v=0; v<src->h; v++) {
src_address = ((unsigned short **)src->line)[v];
dst_address = ((unsigned char **)dst->line)[v];
src_address = ((ase_uint16 **)src->line)[v];
dst_address = ((ase_uint8 **)dst->line)[v];
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)))
(*dst_address) ^= (1 << d.rem);
_image_bitmap_next_bit (d, dst_address);
_image_bitmap_next_bit(d, dst_address);
}
}
} break;
case IMAGE_INDEXED: {
unsigned char *src_address;
unsigned char *dst_address;
ase_uint8 *src_address;
ase_uint8 *dst_address;
int u, v, c;
div_t d;
for (v=0; v<src->h; v++) {
src_address = ((unsigned char **)src->line)[v];
dst_address = ((unsigned char **)dst->line)[v];
src_address = ((ase_uint8 **)src->line)[v];
dst_address = ((ase_uint8 **)dst->line)[v];
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)))
(*dst_address) ^= (1 << d.rem);
_image_bitmap_next_bit (d, dst_address);
_image_bitmap_next_bit(d, dst_address);
}
}
} break;
}
shrink_mask (mask);
shrink_mask(mask);
}
/* void mask_fill (Mask *mask, Image *image, int color) */
/* { */
/* if (mask) { */
/* unsigned char *address; */
/* ase_uint8 *address; */
/* int u, v; */
/* div_t d; */
/* for (v=0; v<h; v++) { */
/* 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++) { */
/* if ((*address) & (1<<d.rem)) */

View File

@ -232,16 +232,16 @@ typedef struct _ArtBitmapSVPData ArtBitmapSVPData;
struct _ArtBitmapSVPData
{
Image *image;
unsigned char *address;
ase_uint8 *address;
int shift;
int x0, x1;
int color;
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;
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;
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;
if (a > 128)
@ -367,7 +367,7 @@ static void art_image_svp_aa (const ArtSVP *svp,
}
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.x1 = x1+1;
data.color = color;

View File

@ -26,14 +26,14 @@
#endif
Image *image_set_imgtype (Image *image, int imgtype,
int dithering_method,
RGB_MAP *rgb_map,
RGB *palette)
Image *image_set_imgtype(Image *image, int imgtype,
int dithering_method,
RGB_MAP *rgb_map,
RGB *palette)
{
unsigned long *rgb_address;
unsigned short *gray_address;
unsigned char *idx_address;
ase_uint32 *rgb_address;
ase_uint16 *gray_address;
ase_uint8 *idx_address;
int i, c, r, g, b, size;
Image *new_image;
@ -46,7 +46,7 @@ Image *image_set_imgtype (Image *image, int imgtype,
dithering_method == DITHERING_ORDERED)
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)
return NULL;
@ -55,12 +55,12 @@ Image *image_set_imgtype (Image *image, int imgtype,
switch (image->imgtype) {
case IMAGE_RGB:
rgb_address = image->dat;
rgb_address = (ase_uint32 *)image->dat;
switch (new_image->imgtype) {
/* RGB -> Grayscale */
case IMAGE_GRAYSCALE:
gray_address = new_image->dat;
gray_address = (ase_uint16 *)new_image->dat;
for (i=0; i<size; i++) {
c = *rgb_address;
r = _rgba_getr (c);
@ -77,10 +77,10 @@ Image *image_set_imgtype (Image *image, int imgtype,
idx_address = new_image->dat;
for (i=0; i<size; i++) {
c = *rgb_address;
r = _rgba_getr (c);
g = _rgba_getg (c);
b = _rgba_getb (c);
if (_rgba_geta (c) == 0)
r = _rgba_getr(c);
g = _rgba_getg(c);
b = _rgba_getb(c);
if (_rgba_geta(c) == 0)
*idx_address = 0;
else
*idx_address = rgb_map->data[r>>3][g>>3][b>>3];
@ -92,12 +92,12 @@ Image *image_set_imgtype (Image *image, int imgtype,
break;
case IMAGE_GRAYSCALE:
gray_address = image->dat;
gray_address = (ase_uint16 *)image->dat;
switch (new_image->imgtype) {
/* Grayscale -> RGB */
case IMAGE_RGB:
rgb_address = new_image->dat;
rgb_address = (ase_uint32 *)new_image->dat;
for (i=0; i<size; i++) {
c = *gray_address;
g = _graya_getk (c);
@ -128,7 +128,7 @@ Image *image_set_imgtype (Image *image, int imgtype,
switch (new_image->imgtype) {
/* Indexed -> RGB */
case IMAGE_RGB:
rgb_address = new_image->dat;
rgb_address = (ase_uint32 *)new_image->dat;
for (i=0; i<size; i++) {
c = *idx_address;
if (c == 0)
@ -143,7 +143,7 @@ Image *image_set_imgtype (Image *image, int imgtype,
break;
/* Indexed -> Grayscale */
case IMAGE_GRAYSCALE:
gray_address = new_image->dat;
gray_address = (ase_uint16 *)new_image->dat;
for (i=0; i<size; i++) {
c = *idx_address;
if (c == 0)
@ -197,10 +197,10 @@ static int pattern[8][8] = {
4 * ((g1)-(g2)) * ((g1)-(g2)) + \
2 * ((b1)-(b2)) * ((b1)-(b2)))
Image *image_rgb_to_indexed (Image *src_image,
int offsetx, int offsety,
RGB_MAP *rgb_map,
RGB *palette)
Image *image_rgb_to_indexed(Image *src_image,
int offsetx, int offsety,
RGB_MAP *rgb_map,
RGB *palette)
{
int oppr, oppg, oppb, oppnrcm;
Image *dst_image;

View File

@ -450,9 +450,10 @@ void sprite_set_frame(Sprite *sprite, int frame)
*/
void sprite_set_imgtype(Sprite *sprite, int imgtype, int dithering_method)
{
RGB *palette = sprite_get_palette(sprite, 0);
Image *old_image;
Image *new_image;
int c;
int c, r, g, b;
/* nothing to do */
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))
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 */
if (undo_is_enabled(sprite->undo)) {
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);
stock_replace_image(sprite->stock, c, new_image);
}
/* change "sprite.imgtype" field */
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;
@ -509,6 +587,7 @@ void sprite_set_imgtype(Sprite *sprite, int imgtype, int dithering_method)
}
}
#endif
if (undo_is_enabled(sprite->undo))
undo_close(sprite->undo);
}

View File

@ -83,7 +83,7 @@ typedef struct UndoChunk
int max_size;
int size;
int pos;
unsigned char *data;
ase_uint8 *data;
} UndoChunk;
typedef struct UndoStream
@ -192,8 +192,8 @@ static void undo_chunk_put32(UndoChunk *chunk, long c);
/* static double undo_chunk_get64(UndoChunk *chunk); */
/* static void undo_chunk_put64(UndoChunk *chunk, double c); */
static int undo_chunk_read(UndoChunk *chunk, unsigned char *buf, int size);
static void undo_chunk_write(UndoChunk *chunk, const 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 ase_uint8 *buf, int size);
static char *undo_chunk_read_string(UndoChunk *chunk);
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 void undo_stream_raw_write_dword(UndoStream *stream, long dword); */
/* static int undo_stream_raw_read(UndoStream *stream, unsigned char *buf, int size); */
/* static void undo_stream_raw_write(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, ase_uint8 *buf, int size); */
/* 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)
{
UndoChunk *chunk = undo_chunk_new(UNDO_TYPE_DATA);
unsigned int offset = (unsigned int)(((unsigned char *)data) -
((unsigned char *)gfxobj));
unsigned int offset = (unsigned int)(((ase_uint8 *)data) -
((ase_uint8 *)gfxobj));
unsigned int c;
undo_chunk_put32(chunk, gfxobj->id);
undo_chunk_put32(chunk, offset);
undo_chunk_put32(chunk, size);
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);
}
@ -487,13 +487,13 @@ static void chunk_data_invert(UndoStream *stream, UndoChunk *chunk, int state)
GfxObj *gfxobj = gfxobj_find(id);
if (gfxobj) {
void *data = (void *)(((unsigned char *)gfxobj) + offset);
void *data = (void *)(((ase_uint8 *)gfxobj) + offset);
chunk_data(stream, gfxobj, data, size);
/* get the string from the chunk */
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)
{
unsigned long id = undo_chunk_get32 (chunk);
unsigned long id = undo_chunk_get32(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) &&
(image->imgtype == imgtype)) {
@ -1334,7 +1334,7 @@ static void undo_chunk_put32(UndoChunk *chunk, long c)
/* 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)
return 0;
@ -1345,7 +1345,7 @@ static int undo_chunk_read(UndoChunk *chunk, unsigned char *buf, int 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) {
chunk->max_size = chunk->size+size;

View File

@ -20,9 +20,8 @@
.align 4
/* Function: int _int_mult (int a, int b) */
.globl _int_mult
/* .type _int_mult,@function */
_int_mult:
.globl __int_mult
__int_mult:
pushl %ebp
movl %esp,%ebp

View File

@ -119,7 +119,7 @@ find_empty_segs (PixelRegion *maskPR,
gint x2,
gint y2)
{
unsigned char *data;
ase_uint8 *data;
int x;
int start, end;
int val, last;
@ -171,7 +171,7 @@ find_empty_segs (PixelRegion *maskPR,
l_num_empty = *num_empty;
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;)
{

View File

@ -49,13 +49,13 @@
static void (*function)(void *) = NULL;
static HashTable *the_table = NULL;
static unsigned long hash (const unsigned char *str);
static void free_node (const char *key, void *data);
static unsigned long hash(const unsigned char *str);
static void free_node(const char *key, void *data);
/* hash_new:
* Creates a new hash table to the size asked for.
*/
HashTable *hash_new (int size)
HashTable *hash_new(int size)
{
HashTable *table;
int i;
@ -84,20 +84,20 @@ HashTable *hash_new (int size)
* responsible for freeing the data, or doing whatever is needed with
* it.
*/
void hash_free (HashTable *table, void (*func) (void *))
void hash_free(HashTable *table, void (*func)(void *))
{
function = func;
the_table = table;
hash_enumerate (table, free_node);
jfree (table->table);
hash_enumerate(table, free_node);
jfree(table->table);
table->table = NULL;
table->size = 0;
the_table = NULL;
function = NULL;
jfree (table);
jfree(table);
}
/* 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
* 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;
/* 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.
* 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;
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
* 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;
HashBucket *ptr, *last = NULL;
@ -170,8 +170,8 @@ void *hash_remove (HashTable *table, const char *key)
else
table->table[val] = ptr->next;
data = ptr->data;
jfree (ptr->key);
jfree (ptr);
jfree(ptr->key);
jfree(ptr);
return data;
}
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
* 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;
HashBucket *bucket, *next;
@ -199,7 +199,7 @@ void hash_enumerate (HashTable *table, void (*callback) (const char *, void *))
/* hash:
* Hashes a string.
*/
static unsigned long hash (const unsigned char *str)
static unsigned long hash(const unsigned char *str)
{
unsigned long hash = 0, c;
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,
* 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)
function (hash_remove (the_table, key));
function(hash_remove(the_table, key));
else
hash_remove (the_table, key);
hash_remove(the_table, key);
}

View File

@ -132,7 +132,7 @@ void ClearMask(void)
{
Sprite *sprite = current_sprite;
int x, y, u, v, putx, puty;
unsigned char *address;
ase_uint8 *address;
Image *image;
div_t d;
int color;
@ -165,7 +165,7 @@ void ClearMask(void)
/* clear the masked zones */
for (v=0; v<sprite->mask->h; v++) {
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++) {
if ((*address & (1<<d.rem))) {
@ -186,7 +186,7 @@ void ClearMask(void)
sprite, the layer isn't added to the sprite */
Layer *NewLayerFromMask(Sprite *src_sprite, Sprite *dst_sprite)
{
unsigned char *address;
ase_uint8 *address;
int x, y, u, v, getx, gety;
Image *dst, *src = GetImage2(src_sprite, &x, &y, NULL);
Layer *layer;
@ -208,7 +208,7 @@ Layer *NewLayerFromMask(Sprite *src_sprite, Sprite *dst_sprite)
/* copy the masked zones */
for (v=0; v<src_sprite->mask->h; v++) {
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++) {
if ((*address & (1<<d.rem))) {

View File

@ -51,10 +51,10 @@ void sprite_quantize_ex(Sprite *sprite, RGB *palette)
stock = sprite_get_images(sprite, TARGET_ALL, FALSE, NULL, NULL);
if (stock) {
/* add a flat image with the current sprite's frame rendered */
flat_image = image_new (sprite->imgtype, sprite->w, sprite->h);
image_clear (flat_image, 0);
sprite_render (sprite, flat_image, 0, 0);
stock_add_image (stock, flat_image);
flat_image = image_new(sprite->imgtype, sprite->w, sprite->h);
image_clear(flat_image, 0);
sprite_render(sprite, flat_image, 0, 0);
stock_add_image(stock, flat_image);
/* generate the optimized palette */
{

View File

@ -256,9 +256,9 @@ static void merge_zoomed_image1(Image *dst, Image *src,
int x, int y, int opacity,
int blend_mode, int zoom)
{
unsigned char *src_address;
unsigned char *dst_address;
unsigned char *scanline, *scanline_address;
ase_uint8 *src_address;
ase_uint8 *dst_address;
ase_uint8 *scanline, *scanline_address;
int src_x, src_y, src_w, src_h;
int dst_x, dst_y, dst_w, dst_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))
return;
sizeof_box = sizeof(unsigned char) * box_w;
sizeof_box = sizeof(ase_uint8) * box_w;
right = dst_x+dst_w-1;
bottom = dst_y+dst_h-1;
scanline = jmalloc (sizeof(unsigned char) * src_w);
scanline = jmalloc(sizeof(ase_uint8) * src_w);
/* merge process */
for (y=0; y<src_h; y++) {
/* process a new line */
src_address = ((unsigned char **)src->line)[src_y] + src_x;
dst_address = ((unsigned char **)dst->line)[dst_y] + dst_x;
src_address = ((ase_uint8 **)src->line)[src_y] + src_x;
dst_address = ((ase_uint8 **)dst->line)[dst_y] + dst_x;
scanline_address = 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' */
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;
line_x = dst_x;
@ -399,7 +399,7 @@ done_with_line:;
}
done_with_blit:;
jfree (scanline);
jfree(scanline);
}
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)
{
BLEND_COLOR blender = _graya_blenders[blend_mode];
unsigned short *src_address;
unsigned short *dst_address;
unsigned short *scanline, *scanline_address;
ase_uint16 *src_address;
ase_uint16 *dst_address;
ase_uint16 *scanline, *scanline_address;
int src_x, src_y, src_w, src_h;
int dst_x, dst_y, dst_w, dst_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))
return;
sizeof_box = sizeof(unsigned short) * box_w;
sizeof_box = sizeof(ase_uint16) * box_w;
right = dst_x+dst_w-1;
bottom = dst_y+dst_h-1;
scanline = jmalloc(sizeof(unsigned short) * src_w);
scanline = jmalloc(sizeof(ase_uint16) * src_w);
/* merge process */
// opacity = (opacity)? opacity+1: 0;
/* opacity = (opacity)? opacity+1: 0; */
for (y=0; y<src_h; y++) {
/* process a new line */
src_address = ((unsigned short **)src->line)[src_y] + src_x;
dst_address = ((unsigned short **)dst->line)[dst_y] + dst_x;
src_address = ((ase_uint16 **)src->line)[src_y] + src_x;
dst_address = ((ase_uint16 **)dst->line)[dst_y] + dst_x;
scanline_address = scanline;
/* read `src' and `dst' and blend them, put the result in `scanline' */
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++;
dst_address += box_w;
@ -495,7 +495,7 @@ static void merge_zoomed_image2(Image *dst, Image *src,
/* put the line in `dst' */
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;
line_x = dst_x;
@ -540,7 +540,7 @@ done_with_line:;
}
done_with_blit:;
jfree (scanline);
jfree(scanline);
}
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)
{
BLEND_COLOR blender = _rgba_blenders[blend_mode];
unsigned long *src_address;
unsigned long *dst_address;
unsigned long *scanline, *scanline_address;
ase_uint32 *src_address;
ase_uint32 *dst_address;
ase_uint32 *scanline, *scanline_address;
int src_x, src_y, src_w, src_h;
int dst_x, dst_y, dst_w, dst_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))
return;
sizeof_box = sizeof(unsigned long) * box_w;
sizeof_box = sizeof(ase_uint32) * box_w;
right = dst_x+dst_w-1;
bottom = dst_y+dst_h-1;
scanline = jmalloc(sizeof(unsigned long) * src_w);
scanline = jmalloc(sizeof(ase_uint32) * src_w);
/* merge process */
// opacity = (opacity)? opacity+1: 0;
/* opacity = (opacity)? opacity+1: 0; */
for (y=0; y<src_h; y++) {
/* process a new line */
src_address = ((unsigned long **)src->line)[src_y] + src_x;
dst_address = ((unsigned long **)dst->line)[dst_y] + dst_x;
src_address = ((ase_uint32 **)src->line)[src_y] + src_x;
dst_address = ((ase_uint32 **)dst->line)[dst_y] + dst_x;
scanline_address = scanline;
/* read `src' and `dst' and blend them, put the result in `scanline' */
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++;
dst_address += box_w;
@ -636,7 +636,7 @@ static void merge_zoomed_image4(Image *dst, Image *src,
/* put the line in `dst' */
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;
line_x = dst_x;
@ -681,5 +681,5 @@ done_with_line:;
}
done_with_blit:;
jfree (scanline);
jfree(scanline);
}