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 >
<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 />
<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; \
@ -220,18 +220,18 @@ static Image *render_text (FONT *f, const char *text, int color)
switch (image->imgtype) {
case IMAGE_RGB:
DO(unsigned long, _rgba(_rgba_getr(color),
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;
}

View File

@ -263,12 +263,12 @@ void set_color_curve(Curve *curve)
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) {
@ -300,12 +300,12 @@ void apply_color_curve4 (Effect *effect)
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) {
@ -333,12 +333,12 @@ void apply_color_curve2 (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) {

View File

@ -323,8 +323,8 @@ 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,7 +350,8 @@ void apply_convolution_matrix4 (Effect *effect)
r = g = b = a = 0;
GET_CONVMATR_DATA (unsigned long,
GET_CONVMATR_DATA
(ase_uint32,
if (_rgba_geta(color) == 0)
div -= *mdata;
else {
@ -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,7 +427,8 @@ void apply_convolution_matrix2 (Effect *effect)
k = a = 0;
GET_CONVMATR_DATA (unsigned short,
GET_CONVMATR_DATA
(ase_uint16,
if (_graya_geta(color) == 0)
div -= *mdata;
else {
@ -459,8 +461,8 @@ 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);

View File

@ -251,7 +251,7 @@ bool effect_apply_step (Effect *effect)
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

@ -28,12 +28,12 @@
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) {
@ -65,12 +65,12 @@ void apply_invert_color4 (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) {
@ -98,12 +98,12 @@ void apply_invert_color2 (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) {

View File

@ -62,15 +62,15 @@ 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,7 +86,8 @@ void apply_median4 (Effect *effect)
c = 0;
GET_MATRIX_DATA (unsigned long, data.w, data.h, data.w/2, data.h/2,
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);
@ -128,15 +129,15 @@ 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,7 +153,8 @@ void apply_median2 (Effect *effect)
c = 0;
GET_MATRIX_DATA (unsigned short, data.w, data.h, data.w/2, data.h/2,
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);
@ -182,15 +184,15 @@ 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,7 +208,8 @@ void apply_median1 (Effect *effect)
c = 0;
GET_MATRIX_DATA (unsigned char, data.w, data.h, data.w/2, data.h/2,
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;

View File

@ -40,14 +40,14 @@ void set_replace_colors (int from, int to, int fuzziness)
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);
@ -85,14 +85,14 @@ void apply_replace_color4 (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);
@ -124,12 +124,12 @@ void apply_replace_color2 (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) {

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,32 +68,32 @@ 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:

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;

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;
@ -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,7 +1366,7 @@ 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],
@ -1395,7 +1395,7 @@ static void my_image_hline1_glass(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++) {
@ -1407,7 +1407,7 @@ 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)
{
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++) {
@ -1419,7 +1419,7 @@ 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)
{
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)

View File

@ -32,7 +32,7 @@
#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;

View File

@ -303,8 +303,7 @@ void dirty_putpixel (Dirty *dirty, int x, int y)
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) {
@ -766,8 +765,8 @@ static void *swap_hline (Image *image)
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;
@ -782,8 +781,8 @@ static void swap_hline1 (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;
@ -798,8 +797,8 @@ static void swap_hline2 (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,11 +28,11 @@ 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: \

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)
@ -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,6 +19,8 @@
#ifndef RASTER_IMAGE_H
#define RASTER_IMAGE_H
/* #define USE_ALLEGRO_IMAGE */
#include "raster/gfxobj.h"
#define _rgba_r_shift 0
@ -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++) { \
@ -30,13 +30,13 @@
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));
image->line = jmalloc (sizeof (unsigned char *) * image->h);
image->line = jmalloc(sizeof(ase_uint8 *) * image->h);
if (!LINES(image))
return -1;
@ -50,8 +50,7 @@ static int bitmap_regenerate_lines (Image *image)
static int bitmap_init(Image *image)
{
image->dat = jmalloc (sizeof (unsigned char) *
((image->w+7)/8) * image->h);
image->dat = jmalloc(sizeof(ase_uint8) * ((image->w+7)/8) * image->h);
if (!BYTES(image))
return -1;
@ -86,8 +85,8 @@ static void bitmap_clear (Image *image, int color)
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;
@ -150,8 +149,8 @@ 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)
{
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;
@ -211,7 +210,7 @@ static void bitmap_merge (Image *dst, const Image *src,
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;
@ -227,7 +226,7 @@ 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)
{
unsigned char *address;
ase_uint8 *address;
div_t d, beg_d = div (x1, 8);
int x, y;
@ -249,7 +248,7 @@ 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)
{
unsigned char *address;
ase_uint8 *address;
unsigned long bmp_address;
int depth = bitmap_color_depth (bmp);
div_t d, beg_d = div (0, 8);

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++) {
@ -206,7 +206,7 @@ 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)
{
unsigned short *address = BYTES (image);
ase_uint16 *address = BYTES(image);
unsigned long bmp_address;
int depth = bitmap_color_depth(bmp);
int x, y;

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;
@ -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;
@ -218,7 +218,7 @@ 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 x, y;

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,7 +68,7 @@ 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++)
@ -77,8 +77,8 @@ static void rgb_clear (Image *image, int color)
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,7 +206,7 @@ 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 x, y;

View File

@ -120,13 +120,13 @@ void mask_none (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);
@ -230,8 +230,8 @@ void mask_by_color (Mask *mask, const Image *src, int color, int fuzziness)
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;
@ -243,8 +243,8 @@ void mask_by_color (Mask *mask, const Image *src, int color, int fuzziness)
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);
@ -268,8 +268,8 @@ void mask_by_color (Mask *mask, const Image *src, int color, int fuzziness)
} 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;
@ -279,8 +279,8 @@ void mask_by_color (Mask *mask, const Image *src, int color, int fuzziness)
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);
@ -300,14 +300,14 @@ void mask_by_color (Mask *mask, const Image *src, int color, int fuzziness)
} 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);
@ -329,13 +329,13 @@ void mask_by_color (Mask *mask, const Image *src, int color, int fuzziness)
/* 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,7 +232,7 @@ typedef struct _ArtBitmapSVPData ArtBitmapSVPData;
struct _ArtBitmapSVPData
{
Image *image;
unsigned char *address;
ase_uint8 *address;
int shift;
int x0, x1;
int color;
@ -241,7 +241,7 @@ struct _ArtBitmapSVPData
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++) {
@ -252,7 +252,7 @@ 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)
{
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++) {
@ -263,7 +263,7 @@ 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)
{
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

@ -31,9 +31,9 @@ Image *image_set_imgtype (Image *image, int imgtype,
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;
@ -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);
@ -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)

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);
@ -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);
}
}
@ -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

@ -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

@ -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;
@ -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,20 +462,20 @@ 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' */
@ -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;
@ -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,20 +603,20 @@ 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' */
@ -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;