2006-02-25 21:51:51 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2006 Richard Wilson <info@tinct.net>
|
Merged revisions 4345-4346,4350-4351,4389,4391,4395,4401-4403,4423,4485-4486 via svnmerge from
svn://semichrome.net/branches/dynis/netsurf
........
r4345 | dynis | 2008-06-15 18:37:23 -0500 (Sun, 15 Jun 2008) | 1 line
Move NetSurf's gifread.h to libnsgif
........
r4346 | dynis | 2008-06-15 18:38:38 -0500 (Sun, 15 Jun 2008) | 1 line
Remove NetSurf's gifread.c (replaced by libnsgif)
........
r4350 | dynis | 2008-06-15 18:57:17 -0500 (Sun, 15 Jun 2008) | 1 line
Added references to libnsgif where necessary; corrected function calls where callbacks were implemented
........
r4351 | dynis | 2008-06-15 19:00:33 -0500 (Sun, 15 Jun 2008) | 1 line
Updated Makefile to compile with libnsgif
........
r4389 | dynis | 2008-06-18 13:58:51 -0500 (Wed, 18 Jun 2008) | 1 line
Altered bitmap callback table name for gif images to avoid ambiguity when bmp image library is created
........
r4391 | dynis | 2008-06-18 14:08:39 -0500 (Wed, 18 Jun 2008) | 1 line
Updated netsurf branch to use new bitmap callback table structure name that was altered in libnsgif
........
r4395 | dynis | 2008-06-18 14:54:51 -0500 (Wed, 18 Jun 2008) | 1 line
Corrected param comments for bitmap_set_suspendable()
........
r4401 | dynis | 2008-06-18 18:39:50 -0500 (Wed, 18 Jun 2008) | 1 line
Added references to libnsbmp where necessary; corrected function calls where callbacks were implemented
........
r4402 | dynis | 2008-06-18 18:40:47 -0500 (Wed, 18 Jun 2008) | 1 line
Updated Makefile to compile with libnsbmp
........
r4403 | dynis | 2008-06-18 18:41:53 -0500 (Wed, 18 Jun 2008) | 1 line
Remove NetSurf's bmpread.c and bmpread.h (replaced by libnsbmp)
........
r4423 | dynis | 2008-06-22 14:21:30 -0500 (Sun, 22 Jun 2008) | 1 line
Correct a silly mistake in nsbmp_bitmap_create
........
r4485 | dynis | 2008-07-01 04:13:48 -0500 (Tue, 01 Jul 2008) | 1 line
Integrated the latest versions of libnsgif and libnsbmp into NetSurf
........
r4486 | dynis | 2008-07-01 05:27:10 -0500 (Tue, 01 Jul 2008) | 1 line
Altered bitmap functions to receive void pointers for proper utilisation of libnsgif and libnsbmp
........
svn path=/trunk/netsurf/; revision=5071
2008-08-12 07:49:34 +04:00
|
|
|
* Copyright 2008 Sean Fox <dyntryx@gmail.com>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* 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/>.
|
2006-02-25 21:51:51 +03:00
|
|
|
*/
|
|
|
|
|
2008-08-24 19:44:29 +04:00
|
|
|
/** \file
|
|
|
|
* Content for image/bmp (implementation)
|
|
|
|
*/
|
|
|
|
|
2008-07-27 03:42:24 +04:00
|
|
|
#include "utils/config.h"
|
|
|
|
#ifdef WITH_BMP
|
|
|
|
|
2006-02-25 21:51:51 +03:00
|
|
|
#include <assert.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdlib.h>
|
Merged revisions 4345-4346,4350-4351,4389,4391,4395,4401-4403,4423,4485-4486 via svnmerge from
svn://semichrome.net/branches/dynis/netsurf
........
r4345 | dynis | 2008-06-15 18:37:23 -0500 (Sun, 15 Jun 2008) | 1 line
Move NetSurf's gifread.h to libnsgif
........
r4346 | dynis | 2008-06-15 18:38:38 -0500 (Sun, 15 Jun 2008) | 1 line
Remove NetSurf's gifread.c (replaced by libnsgif)
........
r4350 | dynis | 2008-06-15 18:57:17 -0500 (Sun, 15 Jun 2008) | 1 line
Added references to libnsgif where necessary; corrected function calls where callbacks were implemented
........
r4351 | dynis | 2008-06-15 19:00:33 -0500 (Sun, 15 Jun 2008) | 1 line
Updated Makefile to compile with libnsgif
........
r4389 | dynis | 2008-06-18 13:58:51 -0500 (Wed, 18 Jun 2008) | 1 line
Altered bitmap callback table name for gif images to avoid ambiguity when bmp image library is created
........
r4391 | dynis | 2008-06-18 14:08:39 -0500 (Wed, 18 Jun 2008) | 1 line
Updated netsurf branch to use new bitmap callback table structure name that was altered in libnsgif
........
r4395 | dynis | 2008-06-18 14:54:51 -0500 (Wed, 18 Jun 2008) | 1 line
Corrected param comments for bitmap_set_suspendable()
........
r4401 | dynis | 2008-06-18 18:39:50 -0500 (Wed, 18 Jun 2008) | 1 line
Added references to libnsbmp where necessary; corrected function calls where callbacks were implemented
........
r4402 | dynis | 2008-06-18 18:40:47 -0500 (Wed, 18 Jun 2008) | 1 line
Updated Makefile to compile with libnsbmp
........
r4403 | dynis | 2008-06-18 18:41:53 -0500 (Wed, 18 Jun 2008) | 1 line
Remove NetSurf's bmpread.c and bmpread.h (replaced by libnsbmp)
........
r4423 | dynis | 2008-06-22 14:21:30 -0500 (Sun, 22 Jun 2008) | 1 line
Correct a silly mistake in nsbmp_bitmap_create
........
r4485 | dynis | 2008-07-01 04:13:48 -0500 (Tue, 01 Jul 2008) | 1 line
Integrated the latest versions of libnsgif and libnsbmp into NetSurf
........
r4486 | dynis | 2008-07-01 05:27:10 -0500 (Tue, 01 Jul 2008) | 1 line
Altered bitmap functions to receive void pointers for proper utilisation of libnsgif and libnsbmp
........
svn path=/trunk/netsurf/; revision=5071
2008-08-12 07:49:34 +04:00
|
|
|
#include <libnsbmp.h>
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/config.h"
|
2010-03-28 16:56:39 +04:00
|
|
|
#include "content/content_protected.h"
|
2011-05-07 00:40:09 +04:00
|
|
|
#include "content/hlcache.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "desktop/plotters.h"
|
|
|
|
#include "image/bitmap.h"
|
|
|
|
#include "image/bmp.h"
|
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/messages.h"
|
2011-05-07 00:40:09 +04:00
|
|
|
#include "utils/talloc.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/utils.h"
|
2006-02-25 21:51:51 +03:00
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
typedef struct nsbmp_content {
|
|
|
|
struct content base;
|
|
|
|
|
|
|
|
bmp_image *bmp; /** BMP image data */
|
|
|
|
} nsbmp_content;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const char *nsbmp_types[] = {
|
|
|
|
"application/bmp",
|
|
|
|
"application/preview",
|
|
|
|
"application/x-bmp",
|
|
|
|
"application/x-win-bitmap",
|
|
|
|
"image/bmp",
|
|
|
|
"image/ms-bmp",
|
|
|
|
"image/x-bitmap",
|
|
|
|
"image/x-bmp",
|
|
|
|
"image/x-ms-bmp",
|
|
|
|
"image/x-win-bitmap",
|
|
|
|
"image/x-windows-bmp",
|
|
|
|
"image/x-xbitmap"
|
|
|
|
};
|
|
|
|
|
|
|
|
static lwc_string *nsbmp_mime_types[NOF_ELEMENTS(nsbmp_types)];
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
static nserror nsbmp_create_bmp_data(nsbmp_content *bmp)
|
|
|
|
{
|
|
|
|
union content_msg_data msg_data;
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
bmp->bmp = calloc(sizeof(struct bmp_image), 1);
|
|
|
|
if (bmp->bmp == NULL) {
|
|
|
|
msg_data.error = messages_get("NoMemory");
|
|
|
|
content_broadcast(&bmp->base, CONTENT_MSG_ERROR, msg_data);
|
|
|
|
return NSERROR_NOMEM;
|
2011-05-07 00:40:09 +04:00
|
|
|
}
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
bmp_create(bmp->bmp, &bmp_bitmap_callbacks);
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
return NSERROR_OK;
|
2011-05-07 00:40:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
static nserror nsbmp_create(const content_handler *handler,
|
2011-05-07 00:40:09 +04:00
|
|
|
lwc_string *imime_type, const struct http_parameter *params,
|
|
|
|
llcache_handle *llcache, const char *fallback_charset,
|
|
|
|
bool quirks, struct content **c)
|
|
|
|
{
|
|
|
|
nsbmp_content *bmp;
|
|
|
|
nserror error;
|
|
|
|
|
|
|
|
bmp = talloc_zero(0, nsbmp_content);
|
|
|
|
if (bmp == NULL)
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
|
|
|
|
error = content__init(&bmp->base, handler, imime_type, params,
|
|
|
|
llcache, fallback_charset, quirks);
|
|
|
|
if (error != NSERROR_OK) {
|
|
|
|
talloc_free(bmp);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = nsbmp_create_bmp_data(bmp);
|
|
|
|
if (error != NSERROR_OK) {
|
|
|
|
talloc_free(bmp);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
*c = (struct content *) bmp;
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
static void *nsbmp_bitmap_create(int width, int height, unsigned int bmp_state)
|
|
|
|
{
|
|
|
|
unsigned int bitmap_state = BITMAP_NEW;
|
2006-02-25 21:51:51 +03:00
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
/* 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;
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
/* return the created bitmap */
|
|
|
|
return bitmap_create(width, height, bitmap_state);
|
2011-05-07 00:40:09 +04:00
|
|
|
}
|
2006-02-25 21:51:51 +03:00
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
/* The Bitmap callbacks function table;
|
|
|
|
* necessary for interaction with nsbmplib.
|
|
|
|
*/
|
|
|
|
bmp_bitmap_callback_vt bmp_bitmap_callbacks = {
|
|
|
|
.bitmap_create = nsbmp_bitmap_create,
|
|
|
|
.bitmap_destroy = bitmap_destroy,
|
|
|
|
.bitmap_set_suspendable = bitmap_set_suspendable,
|
|
|
|
.bitmap_get_buffer = bitmap_get_buffer,
|
|
|
|
.bitmap_get_bpp = bitmap_get_bpp
|
|
|
|
};
|
|
|
|
|
|
|
|
static bool nsbmp_convert(struct content *c)
|
2008-08-24 19:44:29 +04:00
|
|
|
{
|
2011-05-07 00:40:09 +04:00
|
|
|
nsbmp_content *bmp = (nsbmp_content *) c;
|
2006-02-25 21:51:51 +03:00
|
|
|
bmp_result res;
|
|
|
|
union content_msg_data msg_data;
|
Merged revisions 4345-4346,4350-4351,4389,4391,4395,4401-4403,4423,4485-4486 via svnmerge from
svn://semichrome.net/branches/dynis/netsurf
........
r4345 | dynis | 2008-06-15 18:37:23 -0500 (Sun, 15 Jun 2008) | 1 line
Move NetSurf's gifread.h to libnsgif
........
r4346 | dynis | 2008-06-15 18:38:38 -0500 (Sun, 15 Jun 2008) | 1 line
Remove NetSurf's gifread.c (replaced by libnsgif)
........
r4350 | dynis | 2008-06-15 18:57:17 -0500 (Sun, 15 Jun 2008) | 1 line
Added references to libnsgif where necessary; corrected function calls where callbacks were implemented
........
r4351 | dynis | 2008-06-15 19:00:33 -0500 (Sun, 15 Jun 2008) | 1 line
Updated Makefile to compile with libnsgif
........
r4389 | dynis | 2008-06-18 13:58:51 -0500 (Wed, 18 Jun 2008) | 1 line
Altered bitmap callback table name for gif images to avoid ambiguity when bmp image library is created
........
r4391 | dynis | 2008-06-18 14:08:39 -0500 (Wed, 18 Jun 2008) | 1 line
Updated netsurf branch to use new bitmap callback table structure name that was altered in libnsgif
........
r4395 | dynis | 2008-06-18 14:54:51 -0500 (Wed, 18 Jun 2008) | 1 line
Corrected param comments for bitmap_set_suspendable()
........
r4401 | dynis | 2008-06-18 18:39:50 -0500 (Wed, 18 Jun 2008) | 1 line
Added references to libnsbmp where necessary; corrected function calls where callbacks were implemented
........
r4402 | dynis | 2008-06-18 18:40:47 -0500 (Wed, 18 Jun 2008) | 1 line
Updated Makefile to compile with libnsbmp
........
r4403 | dynis | 2008-06-18 18:41:53 -0500 (Wed, 18 Jun 2008) | 1 line
Remove NetSurf's bmpread.c and bmpread.h (replaced by libnsbmp)
........
r4423 | dynis | 2008-06-22 14:21:30 -0500 (Sun, 22 Jun 2008) | 1 line
Correct a silly mistake in nsbmp_bitmap_create
........
r4485 | dynis | 2008-07-01 04:13:48 -0500 (Tue, 01 Jul 2008) | 1 line
Integrated the latest versions of libnsgif and libnsbmp into NetSurf
........
r4486 | dynis | 2008-07-01 05:27:10 -0500 (Tue, 01 Jul 2008) | 1 line
Altered bitmap functions to receive void pointers for proper utilisation of libnsgif and libnsbmp
........
svn path=/trunk/netsurf/; revision=5071
2008-08-12 07:49:34 +04:00
|
|
|
uint32_t swidth;
|
2010-03-28 16:56:39 +04:00
|
|
|
const char *data;
|
|
|
|
unsigned long size;
|
2010-04-03 15:55:28 +04:00
|
|
|
char title[100];
|
2006-02-25 21:51:51 +03:00
|
|
|
|
Merged revisions 4345-4346,4350-4351,4389,4391,4395,4401-4403,4423,4485-4486 via svnmerge from
svn://semichrome.net/branches/dynis/netsurf
........
r4345 | dynis | 2008-06-15 18:37:23 -0500 (Sun, 15 Jun 2008) | 1 line
Move NetSurf's gifread.h to libnsgif
........
r4346 | dynis | 2008-06-15 18:38:38 -0500 (Sun, 15 Jun 2008) | 1 line
Remove NetSurf's gifread.c (replaced by libnsgif)
........
r4350 | dynis | 2008-06-15 18:57:17 -0500 (Sun, 15 Jun 2008) | 1 line
Added references to libnsgif where necessary; corrected function calls where callbacks were implemented
........
r4351 | dynis | 2008-06-15 19:00:33 -0500 (Sun, 15 Jun 2008) | 1 line
Updated Makefile to compile with libnsgif
........
r4389 | dynis | 2008-06-18 13:58:51 -0500 (Wed, 18 Jun 2008) | 1 line
Altered bitmap callback table name for gif images to avoid ambiguity when bmp image library is created
........
r4391 | dynis | 2008-06-18 14:08:39 -0500 (Wed, 18 Jun 2008) | 1 line
Updated netsurf branch to use new bitmap callback table structure name that was altered in libnsgif
........
r4395 | dynis | 2008-06-18 14:54:51 -0500 (Wed, 18 Jun 2008) | 1 line
Corrected param comments for bitmap_set_suspendable()
........
r4401 | dynis | 2008-06-18 18:39:50 -0500 (Wed, 18 Jun 2008) | 1 line
Added references to libnsbmp where necessary; corrected function calls where callbacks were implemented
........
r4402 | dynis | 2008-06-18 18:40:47 -0500 (Wed, 18 Jun 2008) | 1 line
Updated Makefile to compile with libnsbmp
........
r4403 | dynis | 2008-06-18 18:41:53 -0500 (Wed, 18 Jun 2008) | 1 line
Remove NetSurf's bmpread.c and bmpread.h (replaced by libnsbmp)
........
r4423 | dynis | 2008-06-22 14:21:30 -0500 (Sun, 22 Jun 2008) | 1 line
Correct a silly mistake in nsbmp_bitmap_create
........
r4485 | dynis | 2008-07-01 04:13:48 -0500 (Tue, 01 Jul 2008) | 1 line
Integrated the latest versions of libnsgif and libnsbmp into NetSurf
........
r4486 | dynis | 2008-07-01 05:27:10 -0500 (Tue, 01 Jul 2008) | 1 line
Altered bitmap functions to receive void pointers for proper utilisation of libnsgif and libnsbmp
........
svn path=/trunk/netsurf/; revision=5071
2008-08-12 07:49:34 +04:00
|
|
|
/* set the bmp data */
|
2010-03-28 16:56:39 +04:00
|
|
|
data = content__get_source_data(c, &size);
|
|
|
|
|
2006-02-25 21:51:51 +03:00
|
|
|
/* analyse the BMP */
|
2011-05-07 00:40:09 +04:00
|
|
|
res = bmp_analyse(bmp->bmp, size, (unsigned char *) data);
|
2006-02-25 21:51:51 +03:00
|
|
|
switch (res) {
|
|
|
|
case BMP_OK:
|
|
|
|
break;
|
|
|
|
case BMP_INSUFFICIENT_MEMORY:
|
|
|
|
msg_data.error = messages_get("NoMemory");
|
|
|
|
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
|
|
|
|
return false;
|
|
|
|
case BMP_INSUFFICIENT_DATA:
|
|
|
|
case BMP_DATA_ERROR:
|
|
|
|
msg_data.error = messages_get("BadBMP");
|
|
|
|
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-08-24 19:44:29 +04:00
|
|
|
/* Store our content width and description */
|
2011-05-07 00:40:09 +04:00
|
|
|
c->width = bmp->bmp->width;
|
|
|
|
c->height = bmp->bmp->height;
|
2010-01-28 03:03:44 +03:00
|
|
|
LOG(("BMP width %u height %u", c->width, c->height));
|
2010-04-03 15:55:28 +04:00
|
|
|
snprintf(title, sizeof(title), messages_get("BMPTitle"),
|
|
|
|
c->width, c->height, size);
|
|
|
|
content__set_title(c, title);
|
2011-05-07 00:40:09 +04:00
|
|
|
swidth = bmp->bmp->bitmap_callbacks.bitmap_get_bpp(bmp->bmp->bitmap) *
|
|
|
|
bmp->bmp->width;
|
|
|
|
c->size += (swidth * bmp->bmp->height) + 16 + 44;
|
2006-02-25 21:51:51 +03:00
|
|
|
|
|
|
|
/* exit as a success */
|
2011-05-07 00:40:09 +04:00
|
|
|
c->bitmap = bmp->bmp->bitmap;
|
2008-10-11 00:54:49 +04:00
|
|
|
bitmap_modified(c->bitmap);
|
2011-02-27 23:11:39 +03:00
|
|
|
|
|
|
|
content_set_ready(c);
|
|
|
|
content_set_done(c);
|
2008-08-24 19:44:29 +04:00
|
|
|
|
2008-03-10 15:41:41 +03:00
|
|
|
/* Done: update status bar */
|
|
|
|
content_set_status(c, "");
|
2006-02-25 21:51:51 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-06-29 00:17:39 +04:00
|
|
|
static bool nsbmp_redraw(struct content *c, struct content_redraw_data *data,
|
2011-06-30 19:48:07 +04:00
|
|
|
const struct rect *clip, const struct redraw_context *ctx)
|
2008-08-24 19:44:29 +04:00
|
|
|
{
|
2011-05-07 00:40:09 +04:00
|
|
|
nsbmp_content *bmp = (nsbmp_content *) c;
|
2009-06-30 17:02:23 +04:00
|
|
|
bitmap_flags_t flags = BITMAPF_NONE;
|
2006-02-25 21:51:51 +03:00
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
if (bmp->bmp->decoded == false)
|
|
|
|
if (bmp_decode(bmp->bmp) != BMP_OK)
|
Merged revisions 4345-4346,4350-4351,4389,4391,4395,4401-4403,4423,4485-4486 via svnmerge from
svn://semichrome.net/branches/dynis/netsurf
........
r4345 | dynis | 2008-06-15 18:37:23 -0500 (Sun, 15 Jun 2008) | 1 line
Move NetSurf's gifread.h to libnsgif
........
r4346 | dynis | 2008-06-15 18:38:38 -0500 (Sun, 15 Jun 2008) | 1 line
Remove NetSurf's gifread.c (replaced by libnsgif)
........
r4350 | dynis | 2008-06-15 18:57:17 -0500 (Sun, 15 Jun 2008) | 1 line
Added references to libnsgif where necessary; corrected function calls where callbacks were implemented
........
r4351 | dynis | 2008-06-15 19:00:33 -0500 (Sun, 15 Jun 2008) | 1 line
Updated Makefile to compile with libnsgif
........
r4389 | dynis | 2008-06-18 13:58:51 -0500 (Wed, 18 Jun 2008) | 1 line
Altered bitmap callback table name for gif images to avoid ambiguity when bmp image library is created
........
r4391 | dynis | 2008-06-18 14:08:39 -0500 (Wed, 18 Jun 2008) | 1 line
Updated netsurf branch to use new bitmap callback table structure name that was altered in libnsgif
........
r4395 | dynis | 2008-06-18 14:54:51 -0500 (Wed, 18 Jun 2008) | 1 line
Corrected param comments for bitmap_set_suspendable()
........
r4401 | dynis | 2008-06-18 18:39:50 -0500 (Wed, 18 Jun 2008) | 1 line
Added references to libnsbmp where necessary; corrected function calls where callbacks were implemented
........
r4402 | dynis | 2008-06-18 18:40:47 -0500 (Wed, 18 Jun 2008) | 1 line
Updated Makefile to compile with libnsbmp
........
r4403 | dynis | 2008-06-18 18:41:53 -0500 (Wed, 18 Jun 2008) | 1 line
Remove NetSurf's bmpread.c and bmpread.h (replaced by libnsbmp)
........
r4423 | dynis | 2008-06-22 14:21:30 -0500 (Sun, 22 Jun 2008) | 1 line
Correct a silly mistake in nsbmp_bitmap_create
........
r4485 | dynis | 2008-07-01 04:13:48 -0500 (Tue, 01 Jul 2008) | 1 line
Integrated the latest versions of libnsgif and libnsbmp into NetSurf
........
r4486 | dynis | 2008-07-01 05:27:10 -0500 (Tue, 01 Jul 2008) | 1 line
Altered bitmap functions to receive void pointers for proper utilisation of libnsgif and libnsbmp
........
svn path=/trunk/netsurf/; revision=5071
2008-08-12 07:49:34 +04:00
|
|
|
return false;
|
2009-06-30 17:02:23 +04:00
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
c->bitmap = bmp->bmp->bitmap;
|
2009-06-30 17:02:23 +04:00
|
|
|
|
2011-06-29 00:17:39 +04:00
|
|
|
if (data->repeat_x)
|
2009-06-30 17:02:23 +04:00
|
|
|
flags |= BITMAPF_REPEAT_X;
|
2011-06-29 00:17:39 +04:00
|
|
|
if (data->repeat_y)
|
2009-06-30 17:02:23 +04:00
|
|
|
flags |= BITMAPF_REPEAT_Y;
|
|
|
|
|
2011-06-30 19:48:07 +04:00
|
|
|
return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
|
2011-06-29 00:17:39 +04:00
|
|
|
c->bitmap, data->background_colour, flags);
|
2006-02-25 21:51:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
static void nsbmp_destroy(struct content *c)
|
2006-02-25 21:51:51 +03:00
|
|
|
{
|
2011-05-07 00:40:09 +04:00
|
|
|
nsbmp_content *bmp = (nsbmp_content *) c;
|
2006-02-25 21:51:51 +03:00
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
bmp_finalise(bmp->bmp);
|
|
|
|
free(bmp->bmp);
|
|
|
|
}
|
Merged revisions 4345-4346,4350-4351,4389,4391,4395,4401-4403,4423,4485-4486 via svnmerge from
svn://semichrome.net/branches/dynis/netsurf
........
r4345 | dynis | 2008-06-15 18:37:23 -0500 (Sun, 15 Jun 2008) | 1 line
Move NetSurf's gifread.h to libnsgif
........
r4346 | dynis | 2008-06-15 18:38:38 -0500 (Sun, 15 Jun 2008) | 1 line
Remove NetSurf's gifread.c (replaced by libnsgif)
........
r4350 | dynis | 2008-06-15 18:57:17 -0500 (Sun, 15 Jun 2008) | 1 line
Added references to libnsgif where necessary; corrected function calls where callbacks were implemented
........
r4351 | dynis | 2008-06-15 19:00:33 -0500 (Sun, 15 Jun 2008) | 1 line
Updated Makefile to compile with libnsgif
........
r4389 | dynis | 2008-06-18 13:58:51 -0500 (Wed, 18 Jun 2008) | 1 line
Altered bitmap callback table name for gif images to avoid ambiguity when bmp image library is created
........
r4391 | dynis | 2008-06-18 14:08:39 -0500 (Wed, 18 Jun 2008) | 1 line
Updated netsurf branch to use new bitmap callback table structure name that was altered in libnsgif
........
r4395 | dynis | 2008-06-18 14:54:51 -0500 (Wed, 18 Jun 2008) | 1 line
Corrected param comments for bitmap_set_suspendable()
........
r4401 | dynis | 2008-06-18 18:39:50 -0500 (Wed, 18 Jun 2008) | 1 line
Added references to libnsbmp where necessary; corrected function calls where callbacks were implemented
........
r4402 | dynis | 2008-06-18 18:40:47 -0500 (Wed, 18 Jun 2008) | 1 line
Updated Makefile to compile with libnsbmp
........
r4403 | dynis | 2008-06-18 18:41:53 -0500 (Wed, 18 Jun 2008) | 1 line
Remove NetSurf's bmpread.c and bmpread.h (replaced by libnsbmp)
........
r4423 | dynis | 2008-06-22 14:21:30 -0500 (Sun, 22 Jun 2008) | 1 line
Correct a silly mistake in nsbmp_bitmap_create
........
r4485 | dynis | 2008-07-01 04:13:48 -0500 (Tue, 01 Jul 2008) | 1 line
Integrated the latest versions of libnsgif and libnsbmp into NetSurf
........
r4486 | dynis | 2008-07-01 05:27:10 -0500 (Tue, 01 Jul 2008) | 1 line
Altered bitmap functions to receive void pointers for proper utilisation of libnsgif and libnsbmp
........
svn path=/trunk/netsurf/; revision=5071
2008-08-12 07:49:34 +04:00
|
|
|
|
2010-04-04 16:41:19 +04:00
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
static nserror nsbmp_clone(const struct content *old, struct content **newc)
|
2010-04-04 16:41:19 +04:00
|
|
|
{
|
2011-05-07 00:40:09 +04:00
|
|
|
nsbmp_content *new_bmp;
|
|
|
|
nserror error;
|
|
|
|
|
|
|
|
new_bmp = talloc_zero(0, nsbmp_content);
|
|
|
|
if (new_bmp == NULL)
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
|
|
|
|
error = content__clone(old, &new_bmp->base);
|
|
|
|
if (error != NSERROR_OK) {
|
|
|
|
content_destroy(&new_bmp->base);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2010-04-04 16:41:19 +04:00
|
|
|
/* We "clone" the old content by replaying creation and conversion */
|
2011-05-07 00:40:09 +04:00
|
|
|
error = nsbmp_create_bmp_data(new_bmp);
|
|
|
|
if (error != NSERROR_OK) {
|
|
|
|
content_destroy(&new_bmp->base);
|
|
|
|
return error;
|
|
|
|
}
|
2010-04-04 16:41:19 +04:00
|
|
|
|
|
|
|
if (old->status == CONTENT_STATUS_READY ||
|
|
|
|
old->status == CONTENT_STATUS_DONE) {
|
2011-05-07 00:40:09 +04:00
|
|
|
if (nsbmp_convert(&new_bmp->base) == false) {
|
|
|
|
content_destroy(&new_bmp->base);
|
|
|
|
return NSERROR_CLONE_FAILED;
|
|
|
|
}
|
2010-04-04 16:41:19 +04:00
|
|
|
}
|
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
*newc = (struct content *) new_bmp;
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
2010-04-04 16:41:19 +04:00
|
|
|
}
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
static content_type nsbmp_content_type(lwc_string *mime_type)
|
2011-05-07 00:40:09 +04:00
|
|
|
{
|
|
|
|
return CONTENT_IMAGE;
|
|
|
|
}
|
2010-04-04 16:41:19 +04:00
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
|
|
|
|
static const content_handler nsbmp_content_handler = {
|
2011-05-09 19:32:34 +04:00
|
|
|
.create = nsbmp_create,
|
|
|
|
.data_complete = nsbmp_convert,
|
|
|
|
.destroy = nsbmp_destroy,
|
|
|
|
.redraw = nsbmp_redraw,
|
|
|
|
.clone = nsbmp_clone,
|
|
|
|
.type = nsbmp_content_type,
|
|
|
|
.no_share = false,
|
2011-05-08 23:54:35 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
nserror nsbmp_init(void)
|
2008-08-24 19:44:29 +04:00
|
|
|
{
|
2011-05-08 23:54:35 +04:00
|
|
|
uint32_t i;
|
|
|
|
lwc_error lerror;
|
|
|
|
nserror error;
|
2008-08-24 19:44:29 +04:00
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
for (i = 0; i < NOF_ELEMENTS(nsbmp_mime_types); i++) {
|
|
|
|
lerror = lwc_intern_string(nsbmp_types[i],
|
|
|
|
strlen(nsbmp_types[i]),
|
|
|
|
&nsbmp_mime_types[i]);
|
|
|
|
if (lerror != lwc_error_ok) {
|
|
|
|
error = NSERROR_NOMEM;
|
|
|
|
goto error;
|
|
|
|
}
|
2008-08-24 19:44:29 +04:00
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
error = content_factory_register_handler(nsbmp_mime_types[i],
|
|
|
|
&nsbmp_content_handler);
|
|
|
|
if (error != NSERROR_OK)
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
|
|
|
|
error:
|
|
|
|
nsbmp_fini();
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsbmp_fini(void)
|
|
|
|
{
|
|
|
|
uint32_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < NOF_ELEMENTS(nsbmp_mime_types); i++) {
|
|
|
|
if (nsbmp_mime_types[i] != NULL)
|
|
|
|
lwc_string_unref(nsbmp_mime_types[i]);
|
|
|
|
}
|
Merged revisions 4345-4346,4350-4351,4389,4391,4395,4401-4403,4423,4485-4486 via svnmerge from
svn://semichrome.net/branches/dynis/netsurf
........
r4345 | dynis | 2008-06-15 18:37:23 -0500 (Sun, 15 Jun 2008) | 1 line
Move NetSurf's gifread.h to libnsgif
........
r4346 | dynis | 2008-06-15 18:38:38 -0500 (Sun, 15 Jun 2008) | 1 line
Remove NetSurf's gifread.c (replaced by libnsgif)
........
r4350 | dynis | 2008-06-15 18:57:17 -0500 (Sun, 15 Jun 2008) | 1 line
Added references to libnsgif where necessary; corrected function calls where callbacks were implemented
........
r4351 | dynis | 2008-06-15 19:00:33 -0500 (Sun, 15 Jun 2008) | 1 line
Updated Makefile to compile with libnsgif
........
r4389 | dynis | 2008-06-18 13:58:51 -0500 (Wed, 18 Jun 2008) | 1 line
Altered bitmap callback table name for gif images to avoid ambiguity when bmp image library is created
........
r4391 | dynis | 2008-06-18 14:08:39 -0500 (Wed, 18 Jun 2008) | 1 line
Updated netsurf branch to use new bitmap callback table structure name that was altered in libnsgif
........
r4395 | dynis | 2008-06-18 14:54:51 -0500 (Wed, 18 Jun 2008) | 1 line
Corrected param comments for bitmap_set_suspendable()
........
r4401 | dynis | 2008-06-18 18:39:50 -0500 (Wed, 18 Jun 2008) | 1 line
Added references to libnsbmp where necessary; corrected function calls where callbacks were implemented
........
r4402 | dynis | 2008-06-18 18:40:47 -0500 (Wed, 18 Jun 2008) | 1 line
Updated Makefile to compile with libnsbmp
........
r4403 | dynis | 2008-06-18 18:41:53 -0500 (Wed, 18 Jun 2008) | 1 line
Remove NetSurf's bmpread.c and bmpread.h (replaced by libnsbmp)
........
r4423 | dynis | 2008-06-22 14:21:30 -0500 (Sun, 22 Jun 2008) | 1 line
Correct a silly mistake in nsbmp_bitmap_create
........
r4485 | dynis | 2008-07-01 04:13:48 -0500 (Tue, 01 Jul 2008) | 1 line
Integrated the latest versions of libnsgif and libnsbmp into NetSurf
........
r4486 | dynis | 2008-07-01 05:27:10 -0500 (Tue, 01 Jul 2008) | 1 line
Altered bitmap functions to receive void pointers for proper utilisation of libnsgif and libnsbmp
........
svn path=/trunk/netsurf/; revision=5071
2008-08-12 07:49:34 +04:00
|
|
|
}
|
|
|
|
|
2006-02-25 21:51:51 +03:00
|
|
|
#endif
|