r4402 dynis - in /branches/dynis/netsurf: Makefile Makefile.sources
by netsurf@semichrome.net
Author: dynis
Date: Wed Jun 18 18:40:47 2008
New Revision: 4402
URL: http://source.netsurf-browser.org?rev=4402&view=rev
Log:
Updated Makefile to compile with libnsbmp
Modified:
branches/dynis/netsurf/Makefile
branches/dynis/netsurf/Makefile.sources
Modified: branches/dynis/netsurf/Makefile
URL: http://source.netsurf-browser.org/branches/dynis/netsurf/Makefile?rev=440...
==============================================================================
--- branches/dynis/netsurf/Makefile (original)
+++ branches/dynis/netsurf/Makefile Wed Jun 18 18:40:47 2008
@@ -167,10 +167,10 @@
-D_NETBSD_SOURCE \
$(WARNFLAGS) -I. -I../../libsprite/trunk/ -g $(OPT2FLAGS) \
$(shell $(PKG_CONFIG) --cflags libglade-2.0 gtk+-2.0 librsvg-2.0) \
- $(shell $(PKG_CONFIG) --cflags libnsgif) \
+ $(shell $(PKG_CONFIG) --cflags libnsgif libnsbmp) \
$(shell xml2-config --cflags)
-GTKLDFLAGS := $(shell $(PKG_CONFIG) --cflags --libs libglade-2.0 gtk+-2.0 gthread-2.0 gmodule-2.0 librsvg-2.0 libnsgif)
+GTKLDFLAGS := $(shell $(PKG_CONFIG) --cflags --libs libglade-2.0 gtk+-2.0 gthread-2.0 gmodule-2.0 librsvg-2.0 libnsgif libnsbmp)
CFLAGS += $(GTKCFLAGS)
LDFLAGS += $(GTKLDFLAGS) $(shell $(PKG_CONFIG) --libs lcms)
@@ -259,9 +259,9 @@
-D_POSIX_C_SOURCE=200112L \
-D_NETBSD_SOURCE \
$(WARNFLAGS) -I. -I../../libsprite/trunk/ -g $(OPT0FLAGS) \
- $(shell $(PKG_CONFIG) --cflags libnsgif) \
+ $(shell $(PKG_CONFIG) --cflags libnsgif libnsbmp) \
$(shell xml2-config --cflags)
-LDFLAGS += $(shell $(PKG_CONFIG) --libs libnsgif)
+LDFLAGS += $(shell $(PKG_CONFIG) --libs libnsgif libnsbmp)
endif
$(OBJROOT)/created:
Modified: branches/dynis/netsurf/Makefile.sources
URL: http://source.netsurf-browser.org/branches/dynis/netsurf/Makefile.sources...
==============================================================================
--- branches/dynis/netsurf/Makefile.sources (original)
+++ branches/dynis/netsurf/Makefile.sources Wed Jun 18 18:40:47 2008
@@ -22,7 +22,7 @@
$(addprefix utils/,$(S_UTILS)) \
$(addprefix desktop/,$(S_DESKTOP))
-S_IMAGE := bmp.c bmpread.c gif.c ico.c jpeg.c \
+S_IMAGE := bmp.c gif.c ico.c jpeg.c \
mng.c nssprite.c svg.c rsvg.c
# S_IMAGE are sources related to image management
S_IMAGE := $(addprefix image/,$(S_IMAGE))
14 years, 11 months
r4401 dynis - in /branches/dynis/netsurf/image: bmp.c bmp.h ico.c ico.h
by netsurf@semichrome.net
Author: dynis
Date: Wed Jun 18 18:39:50 2008
New Revision: 4401
URL: http://source.netsurf-browser.org?rev=4401&view=rev
Log:
Added references to libnsbmp where necessary; corrected function calls where callbacks were implemented
Modified:
branches/dynis/netsurf/image/bmp.c
branches/dynis/netsurf/image/bmp.h
branches/dynis/netsurf/image/ico.c
branches/dynis/netsurf/image/ico.h
Modified: branches/dynis/netsurf/image/bmp.c
URL: http://source.netsurf-browser.org/branches/dynis/netsurf/image/bmp.c?rev=...
==============================================================================
--- branches/dynis/netsurf/image/bmp.c (original)
+++ branches/dynis/netsurf/image/bmp.c Wed Jun 18 18:39:50 2008
@@ -1,5 +1,6 @@
/*
* Copyright 2006 Richard Wilson <info(a)tinct.net>
+ * Copyright 2008 Sean Fox <dyntryx(a)gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -20,17 +21,28 @@
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
+#include <libnsbmp.h>
#include "utils/config.h"
#include "content/content.h"
#include "desktop/plotters.h"
#include "image/bitmap.h"
#include "image/bmp.h"
-#include "image/bmpread.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
#ifdef WITH_BMP
+
+/* The Bitmap callbacks function table;
+ necessary for interaction with nsgiflib.
+*/
+bmp_bitmap_callback_vt bmp_bitmap_callbacks = {
+ .bitmap_create = (void *)nsbmp_bitmap_create,
+ .bitmap_destroy = (void *)bitmap_destroy,
+ .bitmap_set_suspendable = (void *)bitmap_set_suspendable,
+ .bitmap_get_buffer = (void *)bitmap_get_buffer,
+ .bitmap_get_rowstride = (void *)bitmap_get_rowstride
+};
bool nsbmp_create(struct content *c, const char *params[]) {
union content_msg_data msg_data;
@@ -56,7 +68,7 @@
bmp->buffer_size = c->source_size;
/* analyse the BMP */
- res = bmp_analyse(bmp);
+ res = bmp_analyse(bmp, &bmp_bitmap_callbacks);
switch (res) {
case BMP_OK:
break;
@@ -96,9 +108,9 @@
float scale, unsigned long background_colour) {
if (!c->data.bmp.bmp->decoded)
- bmp_decode(c->data.bmp.bmp);
+ bmp_decode(c->data.bmp.bmp, &bmp_bitmap_callbacks);
c->bitmap = c->data.bmp.bmp->bitmap;
- return plot.bitmap(x, y, width, height, c->bitmap, background_colour);
+ return plot.bitmap(x, y, width, height, c->bitmap, background_colour);
}
@@ -109,7 +121,7 @@
bool repeat_x, bool repeat_y) {
if (!c->data.bmp.bmp->decoded)
- bmp_decode(c->data.bmp.bmp);
+ bmp_decode(c->data.bmp.bmp, &bmp_bitmap_callbacks);
c->bitmap = c->data.bmp.bmp->bitmap;
return plot.bitmap_tile(x, y, width, height, c->bitmap,
background_colour, repeat_x, repeat_y);
@@ -118,9 +130,29 @@
void nsbmp_destroy(struct content *c)
{
- bmp_finalise(c->data.bmp.bmp);
+ bmp_finalise(c->data.bmp.bmp, &bmp_bitmap_callbacks);
free(c->data.bmp.bmp);
free(c->title);
}
+
+/**
+ * Callback for libnsbmp; forwards the call to bitmap_create()
+ *
+ * \param width width of image in pixels
+ * \param height width of image in pixels
+ * \param state a flag word indicating the initial state
+ * \return an opaque struct bitmap, or NULL on memory exhaustion
+ */
+struct bitmap *nsbmp_bitmap_create(int width, int height, unsigned int bmp_state) {
+ unsigned int bitmap_state = BITMAP_NEW;
+
+ /* set bitmap state based on bmp state */
+ bitmap_state |= (bmp_state & BMP_OPAQUE) ? BITMAP_OPAQUE : 0;
+ bitmap_state |= (bmp_state & BMP_CLEAR_MEMORY) ? BITMAP_CLEAR_MEMORY : 0;
+
+ /* return the created bitmap */
+ return bitmap_create(width, height, BITMAP_NEW);
+}
+
#endif
Modified: branches/dynis/netsurf/image/bmp.h
URL: http://source.netsurf-browser.org/branches/dynis/netsurf/image/bmp.h?rev=...
==============================================================================
--- branches/dynis/netsurf/image/bmp.h (original)
+++ branches/dynis/netsurf/image/bmp.h Wed Jun 18 18:39:50 2008
@@ -1,5 +1,6 @@
/*
* Copyright 2006 Richard Wilson <info(a)tinct.net>
+ * Copyright 2008 Sean Fox <dyntryx(a)gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -20,9 +21,11 @@
#define _NETSURF_IMAGE_BMP_H_
#include <stdbool.h>
-#include "image/bmpread.h"
+#include <libnsbmp.h>
+#include "image/bitmap.h"
struct content;
+struct bitmap;
struct content_bmp_data {
struct bmp_image *bmp; /** BMP image data */
@@ -40,5 +43,6 @@
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
float scale, unsigned long background_colour,
bool repeat_x, bool repeat_y);
+struct bitmap *nsbmp_bitmap_create(int width, int height, unsigned int bmp_state);
#endif
Modified: branches/dynis/netsurf/image/ico.c
URL: http://source.netsurf-browser.org/branches/dynis/netsurf/image/ico.c?rev=...
==============================================================================
--- branches/dynis/netsurf/image/ico.c (original)
+++ branches/dynis/netsurf/image/ico.c Wed Jun 18 18:39:50 2008
@@ -20,11 +20,11 @@
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
+#include <libnsbmp.h>
#include "utils/config.h"
#include "content/content.h"
#include "desktop/plotters.h"
#include "image/bitmap.h"
-#include "image/bmpread.h"
#include "image/ico.h"
#include "utils/log.h"
#include "utils/messages.h"
@@ -50,6 +50,8 @@
bmp_result res;
struct ico_collection *ico;
union content_msg_data msg_data;
+ extern bmp_bitmap_callback_vt bmp_bitmap_callbacks; /**< external structure containing
+ * bitmap callback functions */
/* set our source data */
ico = c->data.ico.ico;
@@ -57,7 +59,7 @@
ico->buffer_size = c->source_size;
/* analyse the BMP */
- res = ico_analyse(ico);
+ res = ico_analyse(ico, &bmp_bitmap_callbacks);
switch (res) {
case BMP_OK:
break;
@@ -96,9 +98,11 @@
int width, int height,
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
float scale, unsigned long background_colour) {
+ extern bmp_bitmap_callback_vt bmp_bitmap_callbacks; /**< external structure containing
+ * bitmap callback functions */
struct bmp_image *bmp = ico_find(c->data.ico.ico, width, height);
if (!bmp->decoded)
- bmp_decode(bmp);
+ bmp_decode(bmp, &bmp_bitmap_callbacks);
c->bitmap = bmp->bitmap;
return plot.bitmap(x, y, width, height, c->bitmap,
background_colour);
@@ -110,9 +114,11 @@
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
float scale, unsigned long background_colour,
bool repeat_x, bool repeat_y) {
+ extern bmp_bitmap_callback_vt bmp_bitmap_callbacks; /**< external structure containing
+ * bitmap callback functions */
struct bmp_image *bmp = ico_find(c->data.ico.ico, width, height);
if (!bmp->decoded)
- bmp_decode(bmp);
+ bmp_decode(bmp, &bmp_bitmap_callbacks);
c->bitmap = bmp->bitmap;
return plot.bitmap_tile(x, y, width, height, c->bitmap,
background_colour, repeat_x, repeat_y);
@@ -121,7 +127,9 @@
void nsico_destroy(struct content *c)
{
- ico_finalise(c->data.ico.ico);
+ extern bmp_bitmap_callback_vt bmp_bitmap_callbacks; /**< external structure containing
+ * bitmap callback functions */
+ ico_finalise(c->data.ico.ico, &bmp_bitmap_callbacks);
free(c->data.ico.ico);
free(c->title);
}
Modified: branches/dynis/netsurf/image/ico.h
URL: http://source.netsurf-browser.org/branches/dynis/netsurf/image/ico.h?rev=...
==============================================================================
--- branches/dynis/netsurf/image/ico.h (original)
+++ branches/dynis/netsurf/image/ico.h Wed Jun 18 18:39:50 2008
@@ -20,7 +20,7 @@
#define _NETSURF_IMAGE_ICO_H_
#include <stdbool.h>
-#include "image/bmpread.h"
+#include <libnsbmp.h>
struct content;
14 years, 11 months
r4400 dynis - in /branches/dynis/libnsbmp/utils: ./ log.h
by netsurf@semichrome.net
Author: dynis
Date: Wed Jun 18 18:32:07 2008
New Revision: 4400
URL: http://source.netsurf-browser.org?rev=4400&view=rev
Log:
Added NetSurf's log file for debugging
Added:
branches/dynis/libnsbmp/utils/
branches/dynis/libnsbmp/utils/log.h
Added: branches/dynis/libnsbmp/utils/log.h
URL: http://source.netsurf-browser.org/branches/dynis/libnsbmp/utils/log.h?rev...
==============================================================================
--- branches/dynis/libnsbmp/utils/log.h (added)
+++ branches/dynis/libnsbmp/utils/log.h Wed Jun 18 18:32:07 2008
@@ -1,0 +1,38 @@
+/*
+ * Copyright 2003 James Bursa <bursa(a)users.sourceforge.net>
+ * Copyright 2004 John Tytgat <John.Tytgat(a)aaug.net>
+ * Copyright 2008 Sean Fox <dyntryx(a)gmail.com>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf 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; version 2 of the License.
+ *
+ * NetSurf 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+
+#ifndef _LIBNSBMP_LOG_H_
+#define _LIBNSBMP_LOG_H_
+
+#ifdef NDEBUG
+# define LOG(x) ((void) 0)
+#else
+# ifdef __GNUC__
+# define LOG(x) do { printf x, fputc('\n', stdout)); } while (0)
+# elif defined(__CC_NORCROFT)
+# define LOG(x) do { printf x, fputc('\n', stdout)); } while (0)
+# else
+# define LOG(x) do { printf x, fputc('\n', stdout)); } while (0)
+# endif
+#endif
+
+#endif
14 years, 11 months
r4399 dynis - /branches/dynis/libnsgif/libnsgif.h
by netsurf@semichrome.net
Author: dynis
Date: Wed Jun 18 18:30:44 2008
New Revision: 4399
URL: http://source.netsurf-browser.org?rev=4399&view=rev
Log:
More naming convention changes to the header to squash compiler errors
Modified:
branches/dynis/libnsgif/libnsgif.h
Modified: branches/dynis/libnsgif/libnsgif.h
URL: http://source.netsurf-browser.org/branches/dynis/libnsgif/libnsgif.h?rev=...
==============================================================================
--- branches/dynis/libnsgif/libnsgif.h (original)
+++ branches/dynis/libnsgif/libnsgif.h Wed Jun 18 18:30:44 2008
@@ -58,22 +58,22 @@
/* API for Bitmap callbacks
*/
-typedef void* (*bitmap_cb_create)(int width, int height);
-typedef void (*bitmap_cb_destroy)(void *bitmap);
-typedef char* (*bitmap_cb_get_buffer)(void *bitmap);
-typedef void (*bitmap_cb_set_opaque)(void *bitmap, bool opaque);
-typedef bool (*bitmap_cb_test_opaque)(void *bitmap);
-typedef void (*bitmap_cb_modified)(void *bitmap);
+typedef void* (*gif_bitmap_cb_create)(int width, int height);
+typedef void (*gif_bitmap_cb_destroy)(void *bitmap);
+typedef char* (*gif_bitmap_cb_get_buffer)(void *bitmap);
+typedef void (*gif_bitmap_cb_set_opaque)(void *bitmap, bool opaque);
+typedef bool (*gif_bitmap_cb_test_opaque)(void *bitmap);
+typedef void (*gif_bitmap_cb_modified)(void *bitmap);
/* The Bitmap callbacks function table
*/
typedef struct gif_bitmap_callback_vt_s {
- bitmap_cb_create bitmap_create; /**< Create a bitmap. */
- bitmap_cb_destroy bitmap_destroy; /**< Free a bitmap. */
- bitmap_cb_get_buffer bitmap_get_buffer; /**< Return a pointer to the pixel data in a bitmap. */
- bitmap_cb_set_opaque bitmap_set_opaque; /**< Sets whether a bitmap should be plotted opaque. */
- bitmap_cb_test_opaque bitmap_test_opaque; /**< Tests whether a bitmap has an opaque alpha channel. */
- bitmap_cb_modified bitmap_modified; /**< The bitmap image has changed, so flush any persistant cache. */
+ gif_bitmap_cb_create bitmap_create; /**< Create a bitmap. */
+ gif_bitmap_cb_destroy bitmap_destroy; /**< Free a bitmap. */
+ gif_bitmap_cb_get_buffer bitmap_get_buffer; /**< Return a pointer to the pixel data in a bitmap. */
+ gif_bitmap_cb_set_opaque bitmap_set_opaque; /**< Sets whether a bitmap should be plotted opaque. */
+ gif_bitmap_cb_test_opaque bitmap_test_opaque; /**< Tests whether a bitmap has an opaque alpha channel. */
+ gif_bitmap_cb_modified bitmap_modified; /**< The bitmap image has changed, so flush any persistant cache. */
} gif_bitmap_callback_vt;
/* The GIF animation data
14 years, 11 months
r4398 dynis - /branches/dynis/libnsbmp/libnsbmp.h
by netsurf@semichrome.net
Author: dynis
Date: Wed Jun 18 18:30:19 2008
New Revision: 4398
URL: http://source.netsurf-browser.org?rev=4398&view=rev
Log:
More naming convention changes to the header to squash compiler errors
Modified:
branches/dynis/libnsbmp/libnsbmp.h
Modified: branches/dynis/libnsbmp/libnsbmp.h
URL: http://source.netsurf-browser.org/branches/dynis/libnsbmp/libnsbmp.h?rev=...
==============================================================================
--- branches/dynis/libnsbmp/libnsbmp.h (original)
+++ branches/dynis/libnsbmp/libnsbmp.h Wed Jun 18 18:30:19 2008
@@ -49,21 +49,21 @@
/* API for Bitmap callbacks
*/
-typedef void* (*bitmap_cb_create)(int width, int height, unsigned int state);
-typedef void (*bitmap_cb_destroy)(void *bitmap);
-typedef void (*bitmap_cb_set_suspendable)(void *bitmap, void *private_word,
+typedef void* (*bmp_bitmap_cb_create)(int width, int height, unsigned int state);
+typedef void (*bmp_bitmap_cb_destroy)(void *bitmap);
+typedef void (*bmp_bitmap_cb_set_suspendable)(void *bitmap, void *private_word,
void (*invalidate)(void *bitmap, void *private_word));
-typedef char* (*bitmap_cb_get_buffer)(void *bitmap);
-typedef size_t (*bitmap_cb_get_rowstride)(void *bitmap);
+typedef char* (*bmp_bitmap_cb_get_buffer)(void *bitmap);
+typedef size_t (*bmp_bitmap_cb_get_rowstride)(void *bitmap);
/* The Bitmap callbacks function table
*/
typedef struct bmp_bitmap_callback_vt_s {
- bitmap_cb_create bitmap_create; /**< Create a bitmap. */
- bitmap_cb_destroy bitmap_destroy; /**< Free a bitmap. */
- bitmap_cb_set_suspendable bitmap_set_suspendable; /**< The bitmap image can be suspended. */
- bitmap_cb_get_buffer bitmap_get_buffer; /**< Return a pointer to the pixel data in a bitmap. */
- bitmap_cb_get_rowstride bitmap_get_rowstride; /**< Find the width of a pixel row in bytes. */
+ bmp_bitmap_cb_create bitmap_create; /**< Create a bitmap. */
+ bmp_bitmap_cb_destroy bitmap_destroy; /**< Free a bitmap. */
+ bmp_bitmap_cb_set_suspendable bitmap_set_suspendable; /**< The bitmap image can be suspended. */
+ bmp_bitmap_cb_get_buffer bitmap_get_buffer; /**< Return a pointer to the pixel data in a bitmap. */
+ bmp_bitmap_cb_get_rowstride bitmap_get_rowstride; /**< Find the width of a pixel row in bytes. */
} bmp_bitmap_callback_vt;
struct bmp_image {
14 years, 11 months
r4397 dynis - in /branches/dynis/libnsbmp: Makefile libnsbmp.pc.in
by netsurf@semichrome.net
Author: dynis
Date: Wed Jun 18 17:12:23 2008
New Revision: 4397
URL: http://source.netsurf-browser.org?rev=4397&view=rev
Log:
Added Makefile for installation
Added:
branches/dynis/libnsbmp/Makefile
branches/dynis/libnsbmp/libnsbmp.pc.in
Added: branches/dynis/libnsbmp/Makefile
URL: http://source.netsurf-browser.org/branches/dynis/libnsbmp/Makefile?rev=43...
==============================================================================
--- branches/dynis/libnsbmp/Makefile (added)
+++ branches/dynis/libnsbmp/Makefile Wed Jun 18 17:12:23 2008
@@ -1,0 +1,55 @@
+AR = ar
+CC = gcc
+LD = gcc
+DOXYGEN = doxygen
+INSTALL = install
+SED = sed
+MKDIR = mkdir
+PKG_CONFIG = pkg-config
+
+ARFLAGS = -cru
+CFLAGS = -g -Wall -Wextra -Wundef -Wpointer-arith -Wcast-align \
+ -Wwrite-strings -Wstrict-prototypes \
+ -Wnested-externs -Werror -pedantic -std=c99 \
+ -Wno-format-zero-length -Wformat-security -Wstrict-aliasing=2 \
+ -Wmissing-format-attribute -Wunused -Wunreachable-code \
+ -Wformat=2 -Werror-implicit-function-declaration \
+ -Wmissing-declarations -Wmissing-prototypes
+LDFLAGS = -g -L./
+
+# Installation prefix, if not already defined (e.g. on command line)
+PREFIX ?= /usr/local
+DESTDIR ?=
+
+.PHONY: all clean docs install uninstall
+
+all: libnsbmp.a
+
+libnsbmp.a: libnsbmp.o libnsbmp.pc
+ ${AR} ${ARFLAGS} libnsbmp.a libnsbmp.o
+
+libnsbmp.pc: libnsbmp.pc.in
+ $(SED) -e 's#PREFIX#$(PREFIX)#' libnsbmp.pc.in > libnsbmp.pc
+
+%.o: %.c
+ ${CC} -c ${CFLAGS} -o $@ $<
+
+docs:
+ ${DOXYGEN}
+
+clean:
+ rm -f $(wildcard *.o) $(wildcard *.a) libnsbmp.pc
+ rm -rf doc
+
+install: libnsbmp.a libnsbmp.pc
+ $(MKDIR) -p $(DESTDIR)$(PREFIX)/lib/pkgconfig
+ $(MKDIR) -p $(DESTDIR)$(PREFIX)/lib
+ $(MKDIR) -p $(DESTDIR)$(PREFIX)/include
+ $(INSTALL) --mode=644 -t $(DESTDIR)$(PREFIX)/lib libnsbmp.a
+ $(INSTALL) --mode=644 -t $(DESTDIR)$(PREFIX)/include libnsbmp.h
+ $(INSTALL) --mode=644 -t $(DESTDIR)$(PREFIX)/lib/pkgconfig libnsbmp.pc
+
+uninstall:
+ rm $(DESTDIR)$(PREFIX)/lib/libnsbmp.a
+ rm $(DESTDIR)$(PREFIX)/include/libnsbmp.h
+ rm $(DESTDIR)$(PREFIX)/lib/pkgconfig/libnsbmp.pc
Added: branches/dynis/libnsbmp/libnsbmp.pc.in
URL: http://source.netsurf-browser.org/branches/dynis/libnsbmp/libnsbmp.pc.in?...
==============================================================================
--- branches/dynis/libnsbmp/libnsbmp.pc.in (added)
+++ branches/dynis/libnsbmp/libnsbmp.pc.in Wed Jun 18 17:12:23 2008
@@ -1,0 +1,10 @@
+prefix=PREFIX
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: libnsbmp
+Description: Provides bmp loading and conversion
+Version: 0.0.1
+Libs: -L${libdir} -lnsbmp
+Cflags: -I${includedir}
14 years, 11 months
r4396 dynis - in /branches/dynis/libnsbmp: libnsbmp.c libnsbmp.h
by netsurf@semichrome.net
Author: dynis
Date: Wed Jun 18 17:11:17 2008
New Revision: 4396
URL: http://source.netsurf-browser.org?rev=4396&view=rev
Log:
Incorporated bitmap callbacks to make libnsbmp stand-alone
Modified:
branches/dynis/libnsbmp/libnsbmp.c
branches/dynis/libnsbmp/libnsbmp.h
Modified: branches/dynis/libnsbmp/libnsbmp.c
URL: http://source.netsurf-browser.org/branches/dynis/libnsbmp/libnsbmp.c?rev=...
==============================================================================
--- branches/dynis/libnsbmp/libnsbmp.c (original)
+++ branches/dynis/libnsbmp/libnsbmp.c Wed Jun 18 17:11:17 2008
@@ -1,5 +1,6 @@
/*
* Copyright 2006 Richard Wilson <info(a)tinct.net>
+ * Copyright 2008 Sean Fox <dyntryx(a)gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -22,21 +23,22 @@
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
-#include "image/bmpread.h"
-#include "image/bitmap.h"
+#include "libnsbmp.h"
#include "utils/log.h"
-#include "utils/config.h"
#define READ_SHORT(a, o) (a[o]|(a[o+1]<<8))
#define READ_INT(a, o) (a[o]|(a[o+1]<<8)|(a[o+2]<<16)|(a[o+3]<<24))
-bmp_result bmp_analyse_header(struct bmp_image *bmp, char *data);
-bmp_result bmp_decode_rgb24(struct bmp_image *bmp, char **start, int bytes);
-bmp_result bmp_decode_rgb16(struct bmp_image *bmp, char **start, int bytes);
-bmp_result bmp_decode_rgb(struct bmp_image *bmp, char **start, int bytes);
-bmp_result bmp_decode_mask(struct bmp_image *bmp, char *data, int bytes);
-bmp_result bmp_decode_rle(struct bmp_image *bmp, char *data, int bytes, int size);
-void bmp_invalidate(struct bitmap *bitmap, void *private_word);
+/* squashes unused variable compiler warnings */
+#define UNUSED(x) ((x)=(x))
+
+bmp_result bmp_analyse_header(struct bmp_image *bmp, char *data, bmp_bitmap_callback_vt *bitmap_callbacks);
+bmp_result bmp_decode_rgb24(struct bmp_image *bmp, char **start, int bytes, bmp_bitmap_callback_vt *bitmap_callbacks);
+bmp_result bmp_decode_rgb16(struct bmp_image *bmp, char **start, int bytes, bmp_bitmap_callback_vt *bitmap_callbacks);
+bmp_result bmp_decode_rgb(struct bmp_image *bmp, char **start, int bytes, bmp_bitmap_callback_vt *bitmap_callbacks);
+bmp_result bmp_decode_mask(struct bmp_image *bmp, char *data, int bytes, bmp_bitmap_callback_vt *bitmap_callbacks);
+bmp_result bmp_decode_rle(struct bmp_image *bmp, char *data, int bytes, int size, bmp_bitmap_callback_vt *bitmap_callbacks);
+void bmp_invalidate(void *bitmap, void *private_word);
/**
@@ -51,7 +53,7 @@
* \param bmp the BMP image to analyse
* \return BMP_OK on success
*/
-bmp_result bmp_analyse(struct bmp_image *bmp) {
+bmp_result bmp_analyse(struct bmp_image *bmp, bmp_bitmap_callback_vt *bitmap_callbacks) {
char *data = (char *) bmp->bmp_data;
/* ensure we aren't already initialised */
@@ -73,7 +75,7 @@
bmp->bitmap_offset = READ_INT(data, 10);
/* decode the BMP header */
- return bmp_analyse_header(bmp, data + 14);
+ return bmp_analyse_header(bmp, data + 14, bitmap_callbacks);
}
@@ -88,7 +90,7 @@
* \param ico the ICO image to analyse
* \return BMP_OK on success
*/
-bmp_result ico_analyse(struct ico_collection *ico) {
+bmp_result ico_analyse(struct ico_collection *ico, bmp_bitmap_callback_vt *bitmap_callbacks) {
char *data = (char *) ico->ico_data;
unsigned int count, i;
bmp_result result;
@@ -129,7 +131,7 @@
image->bmp.ico = true;
data += 16;
result = bmp_analyse_header(&image->bmp,
- (char *) image->bmp.bmp_data);
+ (char *) image->bmp.bmp_data, bitmap_callbacks);
if (result != BMP_OK)
return result;
area = image->bmp.width * image->bmp.height;
@@ -143,7 +145,7 @@
}
-bmp_result bmp_analyse_header(struct bmp_image *bmp, char *data) {
+bmp_result bmp_analyse_header(struct bmp_image *bmp, char *data, bmp_bitmap_callback_vt *bitmap_callbacks) {
unsigned int header_size;
unsigned int i;
int width, height, j;
@@ -295,10 +297,10 @@
}
/* create our bitmap */
- flags = BITMAP_NEW | BITMAP_CLEAR_MEMORY;
+ flags = BMP_NEW | BMP_CLEAR_MEMORY;
if ((!bmp->ico) && (bmp->mask[3] == 0))
- flags |= BITMAP_OPAQUE;
- bmp->bitmap = bitmap_create(bmp->width, bmp->height, flags);
+ flags |= BMP_OPAQUE;
+ bmp->bitmap = bitmap_callbacks->bitmap_create(bmp->width, bmp->height, flags);
if (!bmp->bitmap) {
if (bmp->colour_table)
free(bmp->colour_table);
@@ -306,7 +308,7 @@
return BMP_INSUFFICIENT_MEMORY;
}
bmp->bitmap_offset = (intptr_t)data - (intptr_t)bmp->bmp_data;
- bitmap_set_suspendable(bmp->bitmap, bmp, bmp_invalidate);
+ bitmap_callbacks->bitmap_set_suspendable(bmp->bitmap, bmp, bmp_invalidate);
return BMP_OK;
}
@@ -349,7 +351,8 @@
*
* \param bmp the BMP image to invalidate
*/
-void bmp_invalidate(struct bitmap *bitmap, void *private_word) {
+void bmp_invalidate(void *bitmap, void *private_word) {
+ UNUSED(bitmap);
struct bmp_image *bmp = (struct bmp_image *)private_word;
bmp->decoded = false;
@@ -366,7 +369,7 @@
* \param bmp the BMP image to decode
* \return BMP_OK on success
*/
-bmp_result bmp_decode(struct bmp_image *bmp) {
+bmp_result bmp_decode(struct bmp_image *bmp, bmp_bitmap_callback_vt *bitmap_callbacks) {
char *data;
int bytes;
bmp_result result = BMP_OK;
@@ -379,23 +382,23 @@
switch (bmp->encoding) {
case BMP_ENCODING_RGB:
if (bmp->bpp >= 24)
- result = bmp_decode_rgb24(bmp, &data, bytes);
+ result = bmp_decode_rgb24(bmp, &data, bytes, bitmap_callbacks);
else if (bmp->bpp > 8)
- result = bmp_decode_rgb16(bmp, &data, bytes);
+ result = bmp_decode_rgb16(bmp, &data, bytes, bitmap_callbacks);
else
- result = bmp_decode_rgb(bmp, &data, bytes);
+ result = bmp_decode_rgb(bmp, &data, bytes, bitmap_callbacks);
break;
case BMP_ENCODING_RLE8:
- result = bmp_decode_rle(bmp, data, bytes, 8);
+ result = bmp_decode_rle(bmp, data, bytes, 8, bitmap_callbacks);
break;
case BMP_ENCODING_RLE4:
- result = bmp_decode_rle(bmp, data, bytes, 4);
+ result = bmp_decode_rle(bmp, data, bytes, 4, bitmap_callbacks);
break;
case BMP_ENCODING_BITFIELDS:
if (bmp->bpp == 32)
- result = bmp_decode_rgb24(bmp, &data, bytes);
+ result = bmp_decode_rgb24(bmp, &data, bytes, bitmap_callbacks);
else if (bmp->bpp == 16)
- result = bmp_decode_rgb16(bmp, &data, bytes);
+ result = bmp_decode_rgb16(bmp, &data, bytes, bitmap_callbacks);
else
return BMP_DATA_ERROR;
}
@@ -404,7 +407,7 @@
return result;
bytes = (intptr_t)bmp->bmp_data + bmp->buffer_size - (intptr_t)data;
- return bmp_decode_mask(bmp, data, bytes);
+ return bmp_decode_mask(bmp, data, bytes, bitmap_callbacks);
}
@@ -416,7 +419,7 @@
* \param bytes the number of bytes of data available
* \return BMP_OK on success
*/
-bmp_result bmp_decode_rgb24(struct bmp_image *bmp, char **start, int bytes) {
+bmp_result bmp_decode_rgb24(struct bmp_image *bmp, char **start, int bytes, bmp_bitmap_callback_vt *bitmap_callbacks) {
char *top, *bottom, *end, *data;
unsigned int *scanline;
unsigned int x, y, swidth, skip;
@@ -424,8 +427,8 @@
unsigned int i, word;
data = *start;
- swidth = bitmap_get_rowstride(bmp->bitmap);
- top = bitmap_get_buffer(bmp->bitmap);
+ swidth = bitmap_callbacks->bitmap_get_rowstride(bmp->bitmap);
+ top = bitmap_callbacks->bitmap_get_buffer(bmp->bitmap);
if (!top)
return BMP_INSUFFICIENT_MEMORY;
bottom = top + swidth * (bmp->height - 1);
@@ -478,7 +481,7 @@
* \param bytes the number of bytes of data available
* \return BMP_OK on success
*/
-bmp_result bmp_decode_rgb16(struct bmp_image *bmp, char **start, int bytes) {
+bmp_result bmp_decode_rgb16(struct bmp_image *bmp, char **start, int bytes, bmp_bitmap_callback_vt *bitmap_callbacks) {
char *top, *bottom, *end, *data;
unsigned int *scanline;
unsigned int x, y, swidth;
@@ -486,8 +489,8 @@
unsigned int word, i;
data = *start;
- swidth = bitmap_get_rowstride(bmp->bitmap);
- top = bitmap_get_buffer(bmp->bitmap);
+ swidth = bitmap_callbacks->bitmap_get_rowstride(bmp->bitmap);
+ top = bitmap_callbacks->bitmap_get_buffer(bmp->bitmap);
if (!top)
return BMP_INSUFFICIENT_MEMORY;
bottom = top + swidth * (bmp->height - 1);
@@ -540,7 +543,7 @@
* \param bytes the number of bytes of data available
* \return BMP_OK on success
*/
-bmp_result bmp_decode_rgb(struct bmp_image *bmp, char **start, int bytes) {
+bmp_result bmp_decode_rgb(struct bmp_image *bmp, char **start, int bytes, bmp_bitmap_callback_vt *bitmap_callbacks) {
char *top, *bottom, *end, *data;
unsigned int *scanline;
intptr_t addr;
@@ -555,8 +558,8 @@
bit_shifts[i] = 8 - ((i + 1) * bmp->bpp);
data = *start;
- swidth = bitmap_get_rowstride(bmp->bitmap);
- top = bitmap_get_buffer(bmp->bitmap);
+ swidth = bitmap_callbacks->bitmap_get_rowstride(bmp->bitmap);
+ top = bitmap_callbacks->bitmap_get_buffer(bmp->bitmap);
if (!top)
return BMP_INSUFFICIENT_MEMORY;
bottom = top + swidth * (bmp->height - 1);
@@ -596,15 +599,15 @@
* \param bytes the number of bytes of data available
* \return BMP_OK on success
*/
-bmp_result bmp_decode_mask(struct bmp_image *bmp, char *data, int bytes) {
+bmp_result bmp_decode_mask(struct bmp_image *bmp, char *data, int bytes, bmp_bitmap_callback_vt *bitmap_callbacks) {
char *top, *bottom, *end;
unsigned int *scanline;
intptr_t addr;
unsigned int x, y, swidth;
int cur_byte = 0;
- swidth = bitmap_get_rowstride(bmp->bitmap);
- top = bitmap_get_buffer(bmp->bitmap);
+ swidth = bitmap_callbacks->bitmap_get_rowstride(bmp->bitmap);
+ top = bitmap_callbacks->bitmap_get_buffer(bmp->bitmap);
if (!top)
return BMP_INSUFFICIENT_MEMORY;
bottom = top + swidth * (bmp->height - 1);
@@ -638,7 +641,7 @@
* \param size the size of the RLE tokens (4 or 8)
* \return BMP_OK on success
*/
-bmp_result bmp_decode_rle(struct bmp_image *bmp, char *data, int bytes, int size) {
+bmp_result bmp_decode_rle(struct bmp_image *bmp, char *data, int bytes, int size, bmp_bitmap_callback_vt *bitmap_callbacks) {
char *top, *bottom, *end;
unsigned int *scanline;
unsigned int swidth;
@@ -649,8 +652,8 @@
if (bmp->ico)
return BMP_DATA_ERROR;
- swidth = bitmap_get_rowstride(bmp->bitmap);
- top = bitmap_get_buffer(bmp->bitmap);
+ swidth = bitmap_callbacks->bitmap_get_rowstride(bmp->bitmap);
+ top = bitmap_callbacks->bitmap_get_buffer(bmp->bitmap);
if (!top)
return BMP_INSUFFICIENT_MEMORY;
bottom = top + swidth * (bmp->height - 1);
@@ -788,9 +791,9 @@
*
* \param bmp the BMP image to finalise
*/
-void bmp_finalise(struct bmp_image *bmp) {
+void bmp_finalise(struct bmp_image *bmp, bmp_bitmap_callback_vt *bitmap_callbacks) {
if (bmp->bitmap)
- bitmap_destroy(bmp->bitmap);
+ bitmap_callbacks->bitmap_destroy(bmp->bitmap);
bmp->bitmap = NULL;
if (bmp->colour_table)
free(bmp->colour_table);
@@ -803,11 +806,11 @@
*
* \param ico the ICO image to finalise
*/
-void ico_finalise(struct ico_collection *ico) {
+void ico_finalise(struct ico_collection *ico, bmp_bitmap_callback_vt *bitmap_callbacks) {
struct ico_image *image;
for (image = ico->first; image; image = image->next)
- bmp_finalise(&image->bmp);
+ bmp_finalise(&image->bmp, bitmap_callbacks);
while (ico->first) {
image = ico->first;
ico->first = image->next;
Modified: branches/dynis/libnsbmp/libnsbmp.h
URL: http://source.netsurf-browser.org/branches/dynis/libnsbmp/libnsbmp.h?rev=...
==============================================================================
--- branches/dynis/libnsbmp/libnsbmp.h (original)
+++ branches/dynis/libnsbmp/libnsbmp.h Wed Jun 18 17:11:17 2008
@@ -1,5 +1,6 @@
/*
* Copyright 2006 Richard Wilson <info(a)tinct.net>
+ * Copyright 2008 Sean Fox <dyntryx(a)gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -24,7 +25,11 @@
#define _NETSURF_IMAGE_BMPREAD_H_
#include <stdbool.h>
-#include "image/bitmap.h"
+
+/* bmp flags */
+#define BMP_NEW 0
+#define BMP_OPAQUE (1 << 0) /** image is opaque */
+#define BMP_CLEAR_MEMORY (1 << 1) /** memory should be wiped */
/* error return values */
typedef enum {
@@ -42,6 +47,25 @@
BMP_ENCODING_BITFIELDS = 3
} bmp_encoding;
+/* API for Bitmap callbacks
+*/
+typedef void* (*bitmap_cb_create)(int width, int height, unsigned int state);
+typedef void (*bitmap_cb_destroy)(void *bitmap);
+typedef void (*bitmap_cb_set_suspendable)(void *bitmap, void *private_word,
+ void (*invalidate)(void *bitmap, void *private_word));
+typedef char* (*bitmap_cb_get_buffer)(void *bitmap);
+typedef size_t (*bitmap_cb_get_rowstride)(void *bitmap);
+
+/* The Bitmap callbacks function table
+*/
+typedef struct bmp_bitmap_callback_vt_s {
+ bitmap_cb_create bitmap_create; /**< Create a bitmap. */
+ bitmap_cb_destroy bitmap_destroy; /**< Free a bitmap. */
+ bitmap_cb_set_suspendable bitmap_set_suspendable; /**< The bitmap image can be suspended. */
+ bitmap_cb_get_buffer bitmap_get_buffer; /**< Return a pointer to the pixel data in a bitmap. */
+ bitmap_cb_get_rowstride bitmap_get_rowstride; /**< Find the width of a pixel row in bytes. */
+} bmp_bitmap_callback_vt;
+
struct bmp_image {
unsigned char *bmp_data; /** pointer to BMP data */
unsigned int buffer_size; /** total number of bytes of BMP data available */
@@ -57,7 +81,7 @@
bool ico; /** image is part of an ICO, mask follows */
unsigned int mask[4]; /** four bitwise mask */
int shift[4]; /** four bitwise shifts */
- struct bitmap *bitmap; /** decoded image */
+ void *bitmap; /** decoded image */
};
struct ico_image {
@@ -73,12 +97,12 @@
struct ico_image *first;
};
-bmp_result bmp_analyse(struct bmp_image *bmp);
-bmp_result bmp_decode(struct bmp_image *bmp);
-void bmp_finalise(struct bmp_image *bmp);
+bmp_result bmp_analyse(struct bmp_image *bmp, bmp_bitmap_callback_vt *bitmap_callbacks);
+bmp_result bmp_decode(struct bmp_image *bmp, bmp_bitmap_callback_vt *bitmap_callbacks);
+void bmp_finalise(struct bmp_image *bmp, bmp_bitmap_callback_vt *bitmap_callbacks);
-bmp_result ico_analyse(struct ico_collection *ico);
+bmp_result ico_analyse(struct ico_collection *ico, bmp_bitmap_callback_vt *bitmap_callbacks);
struct bmp_image *ico_find(struct ico_collection *ico, int width, int height);
-void ico_finalise(struct ico_collection *ico);
+void ico_finalise(struct ico_collection *ico, bmp_bitmap_callback_vt *bitmap_callbacks);
#endif
14 years, 11 months
r4395 dynis - /branches/dynis/netsurf/gtk/gtk_bitmap.c
by netsurf@semichrome.net
Author: dynis
Date: Wed Jun 18 14:54:51 2008
New Revision: 4395
URL: http://source.netsurf-browser.org?rev=4395&view=rev
Log:
Corrected param comments for bitmap_set_suspendable()
Modified:
branches/dynis/netsurf/gtk/gtk_bitmap.c
Modified: branches/dynis/netsurf/gtk/gtk_bitmap.c
URL: http://source.netsurf-browser.org/branches/dynis/netsurf/gtk/gtk_bitmap.c...
==============================================================================
--- branches/dynis/netsurf/gtk/gtk_bitmap.c (original)
+++ branches/dynis/netsurf/gtk/gtk_bitmap.c Wed Jun 18 14:54:51 2008
@@ -202,10 +202,9 @@
/**
* The bitmap image can be suspended.
*
- * \param bitmap a bitmap, as returned by bitmap_create()
- * \param private_word a private word to be returned later
- * \param suspend the function to be called upon suspension
- * \param resume the function to be called when resuming
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ * \param private_word a private word to be returned later
+ * \param invalidate the function to be called upon suspension
*/
void bitmap_set_suspendable(struct bitmap *bitmap, void *private_word,
void (*invalidate)(struct bitmap *bitmap, void *private_word)) {
14 years, 11 months