diff options
Diffstat (limited to 'amiga/bitmap.c')
-rw-r--r-- | amiga/bitmap.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/amiga/bitmap.c b/amiga/bitmap.c index 162eb9d0d..ff07da910 100644 --- a/amiga/bitmap.c +++ b/amiga/bitmap.c @@ -20,6 +20,7 @@ #include "assert.h" #include "amiga/bitmap.h" +#include "amiga/download.h" #include <proto/exec.h> #include <proto/Picasso96API.h> #ifdef __amigaos4__ @@ -137,6 +138,8 @@ bool bitmap_save(void *bitmap, const char *path, unsigned flags) int err = 0; Object *dto = NULL; + if(!ami_download_check_overwrite(path, NULL)) return false; + if(dto = ami_datatype_object_from_bitmap(bitmap)) { err = SaveDTObjectA(dto, NULL, NULL, path, DTWM_IFF, FALSE, NULL); @@ -418,3 +421,26 @@ struct BitMap *ami_getcachenativebm(struct bitmap *bitmap,int width,int height,s return tbm; } + +APTR ami_colormap_to_clut(struct ColorMap *cmap) +{ + int i; + UBYTE *clut = AllocVec(256 * 4, MEMF_PRIVATE | MEMF_CLEAR); + ULONG colour[3 * 256]; + + if(!clut) return NULL; + + /* Get the palette from the ColorMap */ + GetRGB32(cmap, 0, 256, (ULONG *)&colour); + + /* convert it to a table of ARGB values */ + for(i = 0; i < 1024; i += 4) + { + clut[i] = (0xff << 24) | + ((colour[i] & 0xff000000) >> 8) | + ((colour[i + 1] & 0xff000000) >> 16) | + ((colour[i + 2] & 0xff000000) >> 24); + } + + return clut; +} |