summaryrefslogtreecommitdiff
path: root/riscos/bitmap.c
diff options
context:
space:
mode:
authorAdrian Lees <adrian@aemulor.com>2006-03-24 03:44:37 +0000
committerAdrian Lees <adrian@aemulor.com>2006-03-24 03:44:37 +0000
commit4b03028b5111ca43dc5028c4aee471a83dbae58f (patch)
tree8c815dc593b719817a2d5c4a59e3ece5b926e289 /riscos/bitmap.c
parent4c7a6f4f5c92c35cf48cb4816bd386b9b2985221 (diff)
downloadnetsurf-4b03028b5111ca43dc5028c4aee471a83dbae58f.tar.gz
netsurf-4b03028b5111ca43dc5028c4aee471a83dbae58f.tar.bz2
[project @ 2006-03-24 03:44:33 by adrianl]
Use thumbnails for iconised windows svn path=/import/netsurf/; revision=2157
Diffstat (limited to 'riscos/bitmap.c')
-rw-r--r--riscos/bitmap.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/riscos/bitmap.c b/riscos/bitmap.c
index f9c66bb34..b0d245fd0 100644
--- a/riscos/bitmap.c
+++ b/riscos/bitmap.c
@@ -25,10 +25,14 @@
#include "netsurf/riscos/filename.h"
#include "netsurf/riscos/image.h"
#include "netsurf/riscos/options.h"
+#include "netsurf/riscos/sprite.h"
#include "netsurf/riscos/tinct.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/utils.h"
+/** Colour in the overlay sprite that allows the bitmap to show through */
+#define OVERLAY_KEY 0xff0000U
+
#define MAINTENANCE_THRESHOLD 32
/** The head of the bitmap list
@@ -223,6 +227,92 @@ struct bitmap *bitmap_create_file(char *file)
/**
+ * Overlay a sprite onto the given bitmap
+ *
+ * \param bitmap bitmap object
+ * \param s 8bpp sprite to be overlayed onto bitmap
+ */
+
+void bitmap_overlay_sprite(struct bitmap *bitmap, const osspriteop_header *s)
+{
+ const os_colour *palette;
+ const byte *sp, *mp;
+ bool masked = false;
+ bool alpha = false;
+ os_error *error;
+ int dp_offset;
+ int sp_offset;
+ unsigned *dp;
+ int x, y;
+ int w, h;
+
+ assert(sprite_bpp(s) == 8);
+
+ if ((unsigned)s->mode & 0x80000000U)
+ alpha = true;
+
+ error = xosspriteop_read_sprite_info(osspriteop_PTR,
+ (osspriteop_area *)0x100,
+ (osspriteop_id)s,
+ &w, &h, NULL, NULL);
+ if (error) {
+ LOG(("xosspriteop_read_sprite_info: 0x%x:%s",
+ error->errnum, error->errmess));
+ return;
+ }
+
+ sp_offset = ((s->width + 1) * 4) - w;
+
+ if (w > bitmap->width) w = bitmap->width;
+ if (h > bitmap->height) h = bitmap->height;
+
+ dp_offset = bitmap_get_rowstride(bitmap)/4;
+
+ dp = (unsigned*)bitmap_get_buffer(bitmap);
+ sp = (byte*)s + s->image;
+ mp = (byte*)s + s->mask;
+
+ sp += s->left_bit / 8;
+ mp += s->left_bit / 8;
+
+ if (s->image > sizeof(*s))
+ palette = (os_colour*)(s + 1);
+ else
+ palette = default_palette8;
+
+ if (s->mask != s->image) {
+ masked = true;
+ bitmap_set_opaque(bitmap, false);
+ }
+
+ /* (partially-)transparent pixels in the overlayed sprite retain
+ their transparency in the output bitmap; opaque sprite pixels
+ are also propagated to the bitmap, except those which are the
+ OVERLAY_KEY colour which allow the original bitmap contents to
+ show through */
+
+ for(y = 0; y < h; y++) {
+ unsigned *sdp = dp;
+ for(x = 0; x < w; x++) {
+ os_colour d = ((unsigned)palette[(*sp++) << 1]) >> 8;
+ if (d == OVERLAY_KEY) d = *dp;
+ if (masked) {
+ if (alpha)
+ d |= ((*mp << 24) ^ 0xff000000U);
+ else if (*mp)
+ d |= 0xff000000U;
+ }
+ *dp++ = d;
+ mp++;
+ }
+ dp = sdp + dp_offset;
+ sp += sp_offset;
+ mp += sp_offset;
+ }
+}
+
+
+/**
* Initialise a bitmaps sprite area.
*
* \param bitmap the bitmap to initialise
@@ -852,3 +942,15 @@ void bitmap_delete_file(struct bitmap *bitmap)
ro_filename_release(bitmap->filename);
bitmap->filename[0] = 0;
}
+
+
+int bitmap_get_width(struct bitmap *bitmap)
+{
+ return bitmap->width;
+}
+
+
+int bitmap_get_height(struct bitmap *bitmap)
+{
+ return bitmap->height;
+}