From 59784ba8528182089c77e710f5ff31b3c78d6dc1 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 11 Aug 2012 17:19:54 +0100 Subject: fix mask --- amiga/bitmap.c | 27 +++++++++------------------ amiga/bitmap.h | 3 ++- amiga/gui.c | 4 ++-- amiga/plotters.c | 4 ++-- 4 files changed, 15 insertions(+), 23 deletions(-) diff --git a/amiga/bitmap.c b/amiga/bitmap.c index 381958b34..97e00f302 100644 --- a/amiga/bitmap.c +++ b/amiga/bitmap.c @@ -472,39 +472,30 @@ static struct BitMap *ami_bitmap_get_truecolour(struct bitmap *bitmap,int width, return tbm; } -PLANEPTR ami_bitmap_get_mask(struct bitmap *bitmap, int width, int height) +PLANEPTR ami_bitmap_get_mask(struct bitmap *bitmap, int width, + int height, struct BitMap *n_bm) { uint32 *bmi = (uint32 *) bitmap->pixdata; UBYTE maskbit = 0; + ULONG bm_width; int y, x, w; if((height != bitmap->height) || (width != bitmap->width)) return NULL; if(bitmap_get_opaque(bitmap) == true) return NULL; if(bitmap->native_mask) return bitmap->native_mask; - bitmap->native_mask = AllocRaster(width, height); + bm_width = GetBitMapAttr(n_bm, BMA_WIDTH); + bitmap->native_mask = AllocRaster(bm_width, height); - w = width / 8; - -/* - int wu = width; - while((wu % 16) != 0) { - wu += 8; - w++; - } -*/ - - for(int i=0; i<(height * (width / 8)); i++) { - bitmap->native_mask[i] = 0; - } + int bpr = RASSIZE(bm_width, 1); for(y=0; ynative_mask[(y*w) + (x/8)] = - (bitmap->native_mask[(y*w) + (x/8)] << 1) | maskbit; + bitmap->native_mask[(y*bpr) + (x/8)] = + (bitmap->native_mask[(y*bpr) + (x/8)] << 1) | maskbit; } } @@ -552,7 +543,7 @@ static struct BitMap *ami_bitmap_get_palettemapped(struct bitmap *bitmap, bitmap->nativebmwidth = width; bitmap->nativebmheight = height; - ami_bitmap_get_mask(bitmap, width, height); + ami_bitmap_get_mask(bitmap, width, height, dtbm); return dtbm; } diff --git a/amiga/bitmap.h b/amiga/bitmap.h index 87c569f85..0fbfc52b0 100755 --- a/amiga/bitmap.h +++ b/amiga/bitmap.h @@ -44,7 +44,8 @@ struct bitmap { struct BitMap *ami_bitmap_get_native(struct bitmap *bitmap, int width, int height, struct BitMap *friendbm); -PLANEPTR ami_bitmap_get_mask(struct bitmap *bitmap, int width, int height); +PLANEPTR ami_bitmap_get_mask(struct bitmap *bitmap, int width, + int height, struct BitMap *n_bm); Object *ami_datatype_object_from_bitmap(struct bitmap *bitmap); struct bitmap *ami_bitmap_from_datatype(char *filename); diff --git a/amiga/gui.c b/amiga/gui.c index 2c9eeb50e..8aef21a3f 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -3845,7 +3845,7 @@ void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon) minterm = 0xc0; } else { tag = BLITA_MaskPlane; - tag_data = (ULONG)ami_bitmap_get_mask(icon_bitmap, 16, 16); + tag_data = (ULONG)ami_bitmap_get_mask(icon_bitmap, 16, 16, bm); minterm = (ABC|ABNC|ANBC); } @@ -3928,7 +3928,7 @@ void gui_window_set_search_ico(hlcache_handle *ico) minterm = 0xc0; } else { tag = BLITA_MaskPlane; - tag_data = (ULONG)ami_bitmap_get_mask(ico_bitmap, 16, 16); + tag_data = (ULONG)ami_bitmap_get_mask(ico_bitmap, 16, 16, bm); minterm = (ABC|ABNC|ANBC); } diff --git a/amiga/plotters.c b/amiga/plotters.c index f12ef1ae1..9d86fdeb2 100755 --- a/amiga/plotters.c +++ b/amiga/plotters.c @@ -678,7 +678,7 @@ static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitma minterm = 0xc0; } else { tag = BLITA_MaskPlane; - if(tag_data = (ULONG)ami_bitmap_get_mask(bitmap, width, height)) + if(tag_data = (ULONG)ami_bitmap_get_mask(bitmap, width, height, tbm)) minterm = (ABC|ABNC|ANBC); } @@ -782,7 +782,7 @@ bool ami_bitmap_tile(int x, int y, int width, int height, bfbm.height = height; bfbm.offsetx = ox; bfbm.offsety = oy; - bfbm.mask = ami_bitmap_get_mask(bitmap, width, height);; + bfbm.mask = ami_bitmap_get_mask(bitmap, width, height, tbm); bfh = AllocVec(sizeof(struct Hook),MEMF_CLEAR); bfh->h_Entry = (HOOKFUNC)ami_bitmap_tile_hook; bfh->h_SubEntry = 0; -- cgit v1.2.3