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
|
|
|
*/
|
|
|
|
|
2015-04-14 01:19:04 +03:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* implementation of content handler for BMP images.
|
2008-08-24 19:44:29 +04:00
|
|
|
*/
|
|
|
|
|
2006-02-25 21:51:51 +03:00
|
|
|
#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>
|
2011-08-28 18:29:15 +04:00
|
|
|
|
2015-04-14 01:19:04 +03:00
|
|
|
#include "utils/messages.h"
|
2010-03-28 16:56:39 +04:00
|
|
|
#include "content/content_protected.h"
|
2015-04-14 01:19:04 +03:00
|
|
|
#include "desktop/gui_internal.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "desktop/plotters.h"
|
2006-02-25 21:51:51 +03:00
|
|
|
|
2011-08-28 18:29:15 +04:00
|
|
|
#include "image/bitmap.h"
|
|
|
|
#include "image/bmp.h"
|
|
|
|
|
2015-06-19 11:07:31 +03:00
|
|
|
/** bmp context. */
|
2011-05-07 00:40:09 +04:00
|
|
|
typedef struct nsbmp_content {
|
|
|
|
struct content base;
|
|
|
|
|
|
|
|
bmp_image *bmp; /** BMP image data */
|
2011-08-31 16:12:41 +04:00
|
|
|
|
|
|
|
struct bitmap *bitmap; /**< Created NetSurf bitmap */
|
2011-05-07 00:40:09 +04:00
|
|
|
} nsbmp_content;
|
|
|
|
|
2015-04-14 01:19:04 +03:00
|
|
|
/**
|
|
|
|
* Callback for libnsbmp; forwards the call to bitmap_create()
|
|
|
|
*
|
2015-06-19 11:07:31 +03:00
|
|
|
* \param width width of image in pixels
|
|
|
|
* \param height width of image in pixels
|
|
|
|
* \param bmp_state A flag word indicating the initial state
|
|
|
|
* \return An opaque struct bitmap, or NULL on memory exhaustion
|
2015-04-14 01:19:04 +03:00
|
|
|
*/
|
|
|
|
static void *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 guit->bitmap->create(width, height, bitmap_state);
|
|
|
|
}
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
static nserror nsbmp_create_bmp_data(nsbmp_content *bmp)
|
|
|
|
{
|
|
|
|
union content_msg_data msg_data;
|
2015-04-14 01:19:04 +03:00
|
|
|
bmp_bitmap_callback_vt bmp_bitmap_callbacks = {
|
|
|
|
.bitmap_create = nsbmp_bitmap_create,
|
|
|
|
.bitmap_destroy = guit->bitmap->destroy,
|
|
|
|
.bitmap_get_buffer = guit->bitmap->get_buffer,
|
|
|
|
.bitmap_get_bpp = guit->bitmap->get_bpp
|
|
|
|
};
|
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;
|
|
|
|
|
2012-10-03 22:24:58 +04:00
|
|
|
bmp = calloc(1, sizeof(nsbmp_content));
|
2011-05-07 00:40:09 +04:00
|
|
|
if (bmp == NULL)
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
|
|
|
|
error = content__init(&bmp->base, handler, imime_type, params,
|
|
|
|
llcache, fallback_charset, quirks);
|
|
|
|
if (error != NSERROR_OK) {
|
2012-10-03 22:24:58 +04:00
|
|
|
free(bmp);
|
2011-05-07 00:40:09 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = nsbmp_create_bmp_data(bmp);
|
|
|
|
if (error != NSERROR_OK) {
|
2012-10-03 22:24:58 +04:00
|
|
|
free(bmp);
|
2011-05-07 00:40:09 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
*c = (struct content *) bmp;
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
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;
|
2012-10-25 14:12:41 +04:00
|
|
|
char *title;
|
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;
|
|
|
|
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
|
|
|
|
2012-10-25 14:12:41 +04:00
|
|
|
/* set title text */
|
|
|
|
title = messages_get_buff("BMPTitle",
|
|
|
|
nsurl_access_leaf(llcache_handle_get_url(c->llcache)),
|
|
|
|
c->width, c->height);
|
|
|
|
if (title != NULL) {
|
|
|
|
content__set_title(c, title);
|
|
|
|
free(title);
|
|
|
|
}
|
|
|
|
|
2006-02-25 21:51:51 +03:00
|
|
|
/* exit as a success */
|
2011-08-31 16:12:41 +04:00
|
|
|
bmp->bitmap = bmp->bmp->bitmap;
|
2015-04-14 01:19:04 +03:00
|
|
|
guit->bitmap->modified(bmp->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-08-31 16:12:41 +04:00
|
|
|
bmp->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-08-31 16:12:41 +04:00
|
|
|
bmp->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;
|
|
|
|
|
2012-10-03 22:24:58 +04:00
|
|
|
new_bmp = calloc(1, sizeof(nsbmp_content));
|
2011-05-07 00:40:09 +04:00
|
|
|
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-08-31 16:12:41 +04:00
|
|
|
static void *nsbmp_get_internal(const struct content *c, void *context)
|
|
|
|
{
|
|
|
|
nsbmp_content *bmp = (nsbmp_content *)c;
|
|
|
|
|
|
|
|
return bmp->bitmap;
|
|
|
|
}
|
|
|
|
|
2011-09-03 13:27:42 +04:00
|
|
|
static content_type nsbmp_content_type(void)
|
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,
|
2011-08-31 16:12:41 +04:00
|
|
|
.get_internal = nsbmp_get_internal,
|
2011-05-09 19:32:34 +04:00
|
|
|
.type = nsbmp_content_type,
|
|
|
|
.no_share = false,
|
2011-05-08 23:54:35 +04:00
|
|
|
};
|
|
|
|
|
2011-08-27 12:43:51 +04:00
|
|
|
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"
|
|
|
|
};
|
2011-05-08 23:54:35 +04:00
|
|
|
|
2011-08-27 12:43:51 +04:00
|
|
|
CONTENT_FACTORY_REGISTER_TYPES(nsbmp, nsbmp_types, nsbmp_content_handler);
|