summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--amiga/bitmap.c59
-rwxr-xr-xamiga/bitmap.h2
-rw-r--r--image/bitmap.h5
-rw-r--r--image/gif.c2
4 files changed, 59 insertions, 9 deletions
diff --git a/amiga/bitmap.c b/amiga/bitmap.c
index 23141bac7..c1eab445e 100644
--- a/amiga/bitmap.c
+++ b/amiga/bitmap.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008,2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ * Copyright 2008, 2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -28,6 +28,7 @@
#include <proto/dos.h>
#include <proto/intuition.h>
#include "utils/messages.h"
+#include <graphics/blitattr.h>
/**
* Create a bitmap.
@@ -53,6 +54,9 @@ void *bitmap_create(int width, int height, unsigned int state)
bitmap->height = height;
if(state & BITMAP_OPAQUE) bitmap->opaque = true;
else bitmap->opaque = false;
+
+ if(state & BITMAP_ABGR) bitmap->format = RGBFB_A8B8G8R8;
+ else bitmap->format = RGBFB_R8G8B8A8;
}
return bitmap;
}
@@ -294,9 +298,45 @@ Object *ami_datatype_object_from_bitmap(struct bitmap *bitmap)
PDTA_SourceMode,PMODE_V43,
TAG_DONE);
- IDoMethod(dto,PDTM_WRITEPIXELARRAY,bitmap_get_buffer(bitmap),
- PBPAFMT_RGBA,bitmap_get_rowstride(bitmap),0,0,
- bitmap_get_width(bitmap),bitmap_get_height(bitmap));
+ if(bitmap->format == RGBFB_A8B8G8R8)
+ {
+ struct RenderInfo ri;
+ struct RastPort trp;
+ UBYTE *argb_pixarray = AllocVec(bmhd->bmh_Width * bmhd->bmh_Height *
+ bitmap_get_bpp(bitmap), MEMF_CLEAR);
+ struct BitMap *tbm = ami_getcachenativebm(bitmap, bmhd->bmh_Width,
+ bmhd->bmh_Height, NULL);
+
+ if(argb_pixarray)
+ {
+ ri.Memory = argb_pixarray;
+ ri.BytesPerRow = bitmap_get_rowstride(bitmap);
+ ri.RGBFormat = RGBFB_A8R8G8B8;
+
+ InitRastPort(&trp);
+ trp.BitMap = tbm;
+
+ p96ReadPixelArray((struct RenderInfo *)&ri, 0, 0, &trp, 0, 0,
+ bmhd->bmh_Width, bmhd->bmh_Height);
+
+ if(tbm != bitmap->nativebm)
+ {
+ p96FreeBitMap(tbm);
+ }
+
+ IDoMethod(dto,PDTM_WRITEPIXELARRAY,argb_pixarray,
+ PBPAFMT_ARGB,bitmap_get_rowstride(bitmap),0,0,
+ bitmap_get_width(bitmap),bitmap_get_height(bitmap));
+
+ FreeVec(argb_pixarray);
+ }
+ }
+ else
+ {
+ IDoMethod(dto,PDTM_WRITEPIXELARRAY,bitmap_get_buffer(bitmap),
+ PBPAFMT_RGBA,bitmap_get_rowstride(bitmap),0,0,
+ bitmap_get_width(bitmap),bitmap_get_height(bitmap));
+ }
}
return dto;
@@ -332,13 +372,15 @@ struct BitMap *ami_getcachenativebm(struct bitmap *bitmap,int width,int height,s
{
ri.Memory = bitmap->pixdata;
ri.BytesPerRow = bitmap->width * 4;
- ri.RGBFormat = RGBFB_R8G8B8A8;
+ ri.RGBFormat = bitmap->format;
- if(tbm = p96AllocBitMap(bitmap->width,bitmap->height,32,0,friendbm,RGBFB_R8G8B8A8))
+ if(tbm = p96AllocBitMap(bitmap->width, bitmap->height, 32, 0,
+ friendbm, bitmap->format))
{
InitRastPort(&trp);
trp.BitMap = tbm;
- p96WritePixelArray((struct RenderInfo *)&ri,0,0,&trp,0,0,bitmap->width,bitmap->height);
+ p96WritePixelArray((struct RenderInfo *)&ri, 0, 0, &trp, 0, 0,
+ bitmap->width, bitmap->height);
}
if(option_cache_bitmaps == 2)
@@ -354,7 +396,8 @@ struct BitMap *ami_getcachenativebm(struct bitmap *bitmap,int width,int height,s
struct BitMap *scaledbm;
struct BitScaleArgs bsa;
- scaledbm = p96AllocBitMap(width,height,32,BMF_DISPLAYABLE,friendbm,RGBFB_R8G8B8A8);
+ scaledbm = p96AllocBitMap(width, height, 32, BMF_DISPLAYABLE,
+ friendbm, bitmap->format);
if(GfxBase->lib_Version >= 53) // AutoDoc says v52, but this function isn't in OS4.0, so checking for v53 (OS4.1)
{
diff --git a/amiga/bitmap.h b/amiga/bitmap.h
index 48dc9d758..aa8d02460 100755
--- a/amiga/bitmap.h
+++ b/amiga/bitmap.h
@@ -21,6 +21,7 @@
#include <exec/types.h>
#include <proto/graphics.h>
#include <intuition/classusr.h>
+#include <libraries/Picasso96.h>
struct bitmap {
int width;
@@ -30,6 +31,7 @@ struct bitmap {
struct BitMap *nativebm;
int nativebmwidth;
int nativebmheight;
+ RGBFTYPE format;
char *url; /* temporary storage space */
char *title; /* temporary storage space */
};
diff --git a/image/bitmap.h b/image/bitmap.h
index 4a99de17e..61760decf 100644
--- a/image/bitmap.h
+++ b/image/bitmap.h
@@ -38,6 +38,11 @@
#define BITMAP_CLEAR_MEMORY (1 << 3) /** memory should be wiped */
#define BITMAP_SUSPENDED (1 << 4) /** currently suspended */
#define BITMAP_READY (1 << 5) /** fully initialised */
+#define BITMAP_ABGR (1 << 6) /** This bitmap is in ABGR format on
+ big-endian platforms (if not set,
+ bitmap is RGBA). This flag has
+ no relevance on LE platforms,
+ where data is always ABGR */
#define BITMAP_SAVE_FULL_ALPHA (1 << 0) /** save with full alpha channel (if not opaque) */
diff --git a/image/gif.c b/image/gif.c
index 62d73f0b0..5f8e6c525 100644
--- a/image/gif.c
+++ b/image/gif.c
@@ -338,7 +338,7 @@ void nsgif_animate(void *p)
*/
void *nsgif_bitmap_create(int width, int height)
{
- return bitmap_create(width, height, BITMAP_NEW);
+ return bitmap_create(width, height, BITMAP_NEW | BITMAP_ABGR);
}
#endif