2004-12-25 14:37:35 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2004 James Bursa <bursa@users.sourceforge.net>
|
2005-06-23 21:22:28 +04:00
|
|
|
* Copyright 2005 Richard Wilson <info@tinct.net>
|
2008-03-24 04:35:13 +03:00
|
|
|
* Copyright 2008 Adrian Lees <adrianl@users.sourceforge.net>
|
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/>.
|
2004-12-25 14:37:35 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* Generic bitmap handling (RISC OS implementation).
|
|
|
|
*
|
|
|
|
* This implements the interface given by desktop/bitmap.h using RISC OS
|
|
|
|
* sprites.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <string.h>
|
2005-06-23 21:22:28 +04:00
|
|
|
#include <swis.h>
|
2006-04-22 03:49:52 +04:00
|
|
|
#include <unixlib/local.h>
|
2005-06-23 21:22:28 +04:00
|
|
|
#include "oslib/osfile.h"
|
2008-03-24 04:35:13 +03:00
|
|
|
#include "oslib/osfind.h"
|
|
|
|
#include "oslib/osgbpb.h"
|
|
|
|
#include "oslib/osspriteop.h"
|
2008-09-17 01:15:30 +04:00
|
|
|
#include "oslib/wimp.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "content/content.h"
|
|
|
|
#include "image/bitmap.h"
|
|
|
|
#include "riscos/bitmap.h"
|
|
|
|
#include "riscos/image.h"
|
|
|
|
#include "riscos/options.h"
|
|
|
|
#include "riscos/palettes.h"
|
2011-05-09 13:57:40 +04:00
|
|
|
#include "riscos/content-handlers/sprite.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/tinct.h"
|
|
|
|
#include "utils/filename.h"
|
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/utils.h"
|
2004-12-25 14:37:35 +03:00
|
|
|
|
2006-03-24 06:44:37 +03:00
|
|
|
/** Colour in the overlay sprite that allows the bitmap to show through */
|
2006-08-04 23:18:27 +04:00
|
|
|
#define OVERLAY_INDEX 0xfe
|
2006-03-24 06:44:37 +03:00
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
#define MAINTENANCE_THRESHOLD 32
|
|
|
|
|
2008-03-24 04:35:13 +03:00
|
|
|
/** Size of buffer used when constructing mask data to be saved */
|
|
|
|
#define SAVE_CHUNK_SIZE 4096
|
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
/** The head of the bitmap list
|
|
|
|
*/
|
|
|
|
struct bitmap *bitmap_head = NULL;
|
|
|
|
|
|
|
|
/** Whether maintenance of the pool states is needed
|
|
|
|
*/
|
|
|
|
bool bitmap_maintenance = false;
|
|
|
|
|
|
|
|
/** Whether maintenance of the pool is high priority
|
|
|
|
*/
|
|
|
|
bool bitmap_maintenance_priority = false;
|
|
|
|
|
|
|
|
/** Maximum amount of memory for direct images
|
|
|
|
*/
|
|
|
|
unsigned int bitmap_direct_size;
|
|
|
|
|
|
|
|
/** Current amount of memory for direct images
|
|
|
|
*/
|
|
|
|
unsigned int bitmap_direct_used = 0;
|
|
|
|
|
|
|
|
/** Total size of compressed area
|
|
|
|
*/
|
|
|
|
unsigned int bitmap_compressed_size;
|
|
|
|
|
|
|
|
/** Total size of compressed area
|
|
|
|
*/
|
|
|
|
unsigned int bitmap_compressed_used = 0;
|
|
|
|
|
2006-02-22 04:58:19 +03:00
|
|
|
/** Total number of suspendable bitmaps
|
|
|
|
*/
|
|
|
|
unsigned int bitmap_suspendable = 0;
|
|
|
|
|
|
|
|
/** Total number of suspended bitmaps
|
|
|
|
*/
|
|
|
|
unsigned int bitmap_suspended = 0;
|
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
/** Compressed data header
|
|
|
|
*/
|
|
|
|
struct bitmap_compressed_header {
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
char name[12];
|
|
|
|
unsigned int flags;
|
|
|
|
unsigned int input_size;
|
|
|
|
};
|
|
|
|
|
2006-04-22 03:49:52 +04:00
|
|
|
char bitmap_unixname[256];
|
2005-06-23 21:22:28 +04:00
|
|
|
char bitmap_filename[256];
|
|
|
|
|
2006-02-21 23:49:12 +03:00
|
|
|
static bool bitmap_initialise(struct bitmap *bitmap);
|
2005-09-08 00:22:33 +04:00
|
|
|
static void bitmap_decompress(struct bitmap *bitmap);
|
|
|
|
static void bitmap_compress(struct bitmap *bitmap);
|
|
|
|
static void bitmap_load_file(struct bitmap *bitmap);
|
|
|
|
static void bitmap_save_file(struct bitmap *bitmap);
|
|
|
|
static void bitmap_delete_file(struct bitmap *bitmap);
|
2005-06-23 21:22:28 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialise the bitmap memory pool.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void bitmap_initialise_memory(void)
|
|
|
|
{
|
|
|
|
int available_memory, direct_size, compressed_size;
|
2005-06-27 03:24:03 +04:00
|
|
|
int free_slot;
|
2005-06-23 21:22:28 +04:00
|
|
|
os_error *error;
|
|
|
|
|
2005-06-27 03:24:03 +04:00
|
|
|
/* calculate how much memory is currently free
|
|
|
|
(Note that the free_slot returned by wimp_slot_size
|
|
|
|
includes the next_slot; the value displayed by the
|
|
|
|
TaskManager has been adjusted to make it more logical
|
|
|
|
for the user).
|
|
|
|
*/
|
2008-09-17 01:15:30 +04:00
|
|
|
error = xwimp_slot_size(-1, -1, NULL, NULL, &free_slot);
|
2005-06-23 21:22:28 +04:00
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_slot_size: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
2005-06-27 03:24:03 +04:00
|
|
|
available_memory = free_slot;
|
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
/* calculate our memory block sizes */
|
|
|
|
if (option_image_memory_direct == -1) {
|
2006-01-02 05:52:53 +03:00
|
|
|
/* claim 25% of free memory - min 256KB, max 32768KB */
|
|
|
|
direct_size = available_memory / 4;
|
2005-06-23 21:22:28 +04:00
|
|
|
if (direct_size < (256 << 10))
|
|
|
|
direct_size = (256 << 10);
|
|
|
|
if (direct_size > (32768 << 10))
|
|
|
|
direct_size = (32768 << 10);
|
|
|
|
} else {
|
|
|
|
direct_size = (option_image_memory_direct << 10);
|
|
|
|
}
|
|
|
|
if (option_image_memory_compressed == -1) {
|
2006-01-02 05:52:53 +03:00
|
|
|
/* claim 10% of free memory - min 256KB, max 4192KB */
|
|
|
|
compressed_size = available_memory / 10;
|
2005-06-23 21:22:28 +04:00
|
|
|
if (compressed_size < (256 << 10))
|
|
|
|
compressed_size = 0;
|
|
|
|
if (compressed_size > (4192 << 10))
|
|
|
|
compressed_size = (4192 << 10);
|
|
|
|
} else {
|
|
|
|
compressed_size = (option_image_memory_compressed << 10);
|
|
|
|
}
|
2005-09-08 00:22:33 +04:00
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
/* set our values. No fixed buffers here, ho hum. */
|
|
|
|
bitmap_direct_size = direct_size;
|
|
|
|
bitmap_compressed_size = compressed_size;
|
2006-01-02 05:52:53 +03:00
|
|
|
bitmap_maintenance = bitmap_maintenance_priority = true;
|
2005-06-23 21:22:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepare for the end of a session.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void bitmap_quit(void)
|
|
|
|
{
|
|
|
|
struct bitmap *bitmap;
|
2005-09-08 00:22:33 +04:00
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
for (bitmap = bitmap_head; bitmap; bitmap = bitmap->next)
|
2006-02-22 04:58:19 +03:00
|
|
|
if ((bitmap->state & BITMAP_PERSISTENT) &&
|
|
|
|
((bitmap->state & BITMAP_MODIFIED) ||
|
2006-02-21 23:49:12 +03:00
|
|
|
(bitmap->filename[0] == '\0')))
|
2005-09-08 00:22:33 +04:00
|
|
|
bitmap_save_file(bitmap);
|
2005-06-23 21:22:28 +04:00
|
|
|
}
|
|
|
|
|
2004-12-25 14:37:35 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a bitmap.
|
|
|
|
*
|
|
|
|
* \param width width of image in pixels
|
|
|
|
* \param height width of image in pixels
|
2005-04-29 05:35:52 +04:00
|
|
|
* \param clear whether to clear the image ready for use
|
2004-12-25 14:37:35 +03:00
|
|
|
* \return an opaque struct bitmap, or NULL on memory exhaustion
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
void *bitmap_create(int width, int height, unsigned int state)
|
2004-12-25 14:37:35 +03:00
|
|
|
{
|
|
|
|
struct bitmap *bitmap;
|
|
|
|
|
|
|
|
if (width == 0 || height == 0)
|
|
|
|
return NULL;
|
|
|
|
|
2005-10-02 03:28:46 +04:00
|
|
|
bitmap = calloc(1, sizeof(struct bitmap));
|
2004-12-25 14:37:35 +03:00
|
|
|
if (!bitmap)
|
|
|
|
return NULL;
|
|
|
|
bitmap->width = width;
|
|
|
|
bitmap->height = height;
|
2006-02-22 04:58:19 +03:00
|
|
|
bitmap->state = state;
|
2005-06-23 21:22:28 +04:00
|
|
|
|
|
|
|
/* link into our list of bitmaps at the head */
|
|
|
|
if (bitmap_head) {
|
|
|
|
bitmap->next = bitmap_head;
|
|
|
|
bitmap_head->previous = bitmap;
|
|
|
|
}
|
|
|
|
bitmap_head = bitmap;
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a persistent, opaque bitmap from a file reference.
|
|
|
|
*
|
2006-01-03 01:04:35 +03:00
|
|
|
* \param file the file containing the image data
|
2005-06-23 21:22:28 +04:00
|
|
|
* \return an opaque struct bitmap, or NULL on memory exhaustion
|
|
|
|
*/
|
|
|
|
|
2005-12-31 07:29:00 +03:00
|
|
|
struct bitmap *bitmap_create_file(char *file)
|
2005-06-23 21:22:28 +04:00
|
|
|
{
|
|
|
|
struct bitmap *bitmap;
|
2008-06-15 04:27:22 +04:00
|
|
|
char *r;
|
|
|
|
fileswitch_object_type obj_type;
|
|
|
|
os_error *error;
|
|
|
|
|
2005-12-31 07:29:00 +03:00
|
|
|
if (file[0] == '\0')
|
2005-06-23 21:22:28 +04:00
|
|
|
return NULL;
|
|
|
|
|
2008-06-15 04:27:22 +04:00
|
|
|
/* check the file exists */
|
|
|
|
sprintf(bitmap_unixname, "%s/%s", TEMP_FILENAME_PREFIX, file);
|
|
|
|
r = __riscosify(bitmap_unixname, 0, __RISCOSIFY_NO_SUFFIX,
|
|
|
|
bitmap_filename, 256, 0);
|
|
|
|
if (r == 0) {
|
|
|
|
LOG(("__riscosify failed"));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
error = xosfile_read_stamped_no_path(bitmap_filename,
|
|
|
|
&obj_type, 0, 0, 0, 0, 0);
|
|
|
|
if ((error) || (obj_type != fileswitch_IS_FILE))
|
|
|
|
return NULL;
|
|
|
|
|
2006-04-22 03:49:52 +04:00
|
|
|
if (!filename_claim(file))
|
2005-06-23 21:22:28 +04:00
|
|
|
return NULL;
|
2005-10-02 03:28:46 +04:00
|
|
|
bitmap = calloc(1, sizeof(struct bitmap));
|
2005-06-23 21:22:28 +04:00
|
|
|
if (!bitmap)
|
|
|
|
return NULL;
|
2006-02-22 04:58:19 +03:00
|
|
|
bitmap->state = BITMAP_OPAQUE | BITMAP_PERSISTENT | BITMAP_READY;
|
2005-10-02 03:28:46 +04:00
|
|
|
strcpy(bitmap->filename, file);
|
2005-06-23 21:22:28 +04:00
|
|
|
|
2005-12-31 07:29:00 +03:00
|
|
|
/* link in at the head */
|
2005-06-23 21:22:28 +04:00
|
|
|
if (bitmap_head) {
|
2005-12-31 07:29:00 +03:00
|
|
|
bitmap->next = bitmap_head;
|
|
|
|
bitmap_head->previous = bitmap;
|
2005-06-23 21:22:28 +04:00
|
|
|
}
|
2005-12-31 07:29:00 +03:00
|
|
|
bitmap_head = bitmap;
|
2005-06-23 21:22:28 +04:00
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-24 06:44:37 +03:00
|
|
|
/**
|
|
|
|
* 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)
|
2006-06-21 02:58:36 +04:00
|
|
|
alpha = true;
|
2006-03-24 06:44:37 +03:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2006-08-04 23:18:27 +04:00
|
|
|
if (w > bitmap->width)
|
|
|
|
w = bitmap->width;
|
|
|
|
if (h > bitmap->height)
|
|
|
|
h = bitmap->height;
|
2006-03-24 06:44:37 +03:00
|
|
|
|
2006-08-04 23:18:27 +04:00
|
|
|
dp_offset = bitmap_get_rowstride(bitmap) / 4;
|
2006-03-24 06:44:37 +03:00
|
|
|
|
2008-09-17 02:14:39 +04:00
|
|
|
dp = (void*)bitmap_get_buffer(bitmap);
|
2006-08-04 23:18:27 +04:00
|
|
|
if (!dp)
|
|
|
|
return;
|
2006-03-24 06:44:37 +03:00
|
|
|
sp = (byte*)s + s->image;
|
|
|
|
mp = (byte*)s + s->mask;
|
|
|
|
|
|
|
|
sp += s->left_bit / 8;
|
|
|
|
mp += s->left_bit / 8;
|
|
|
|
|
2006-08-04 23:18:27 +04:00
|
|
|
if (s->image > (int)sizeof(*s))
|
2006-03-24 06:44:37 +03:00
|
|
|
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
|
2008-09-17 02:14:39 +04:00
|
|
|
* their transparency in the output bitmap; opaque sprite pixels
|
|
|
|
* are also propagated to the bitmap, except those which are the
|
|
|
|
* OVERLAY_INDEX colour which allow the original bitmap contents to
|
|
|
|
* show through */
|
2006-08-04 23:18:27 +04:00
|
|
|
for (y = 0; y < h; y++) {
|
2006-03-24 06:44:37 +03:00
|
|
|
unsigned *sdp = dp;
|
|
|
|
for(x = 0; x < w; x++) {
|
2006-08-04 23:18:27 +04:00
|
|
|
os_colour d = ((unsigned)palette[(*sp) << 1]) >> 8;
|
|
|
|
if (*sp++ == OVERLAY_INDEX)
|
|
|
|
d = *dp;
|
2006-03-24 06:44:37 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
/**
|
|
|
|
* Initialise a bitmaps sprite area.
|
|
|
|
*
|
|
|
|
* \param bitmap the bitmap to initialise
|
|
|
|
* \param clear whether to clear the image ready for use
|
|
|
|
*/
|
|
|
|
|
2006-02-21 23:49:12 +03:00
|
|
|
bool bitmap_initialise(struct bitmap *bitmap)
|
2005-06-23 21:22:28 +04:00
|
|
|
{
|
|
|
|
unsigned int area_size;
|
|
|
|
osspriteop_area *sprite_area;
|
|
|
|
osspriteop_header *sprite;
|
|
|
|
|
2006-02-22 01:29:17 +03:00
|
|
|
assert(!bitmap->sprite_area);
|
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
area_size = 16 + 44 + bitmap->width * bitmap->height * 4;
|
2006-02-22 04:58:19 +03:00
|
|
|
if (bitmap->state & BITMAP_CLEAR_MEMORY)
|
|
|
|
bitmap->sprite_area = calloc(1, area_size);
|
|
|
|
else
|
|
|
|
bitmap->sprite_area = malloc(area_size);
|
|
|
|
|
2006-02-22 01:29:17 +03:00
|
|
|
if (!bitmap->sprite_area)
|
|
|
|
return false;
|
2006-02-22 04:58:19 +03:00
|
|
|
bitmap->state |= BITMAP_READY;
|
2005-06-23 21:22:28 +04:00
|
|
|
bitmap_direct_used += area_size;
|
2004-12-25 14:37:35 +03:00
|
|
|
|
|
|
|
/* area control block */
|
2005-06-23 21:22:28 +04:00
|
|
|
sprite_area = bitmap->sprite_area;
|
2004-12-25 14:37:35 +03:00
|
|
|
sprite_area->size = area_size;
|
|
|
|
sprite_area->sprite_count = 1;
|
|
|
|
sprite_area->first = 16;
|
|
|
|
sprite_area->used = area_size;
|
|
|
|
|
|
|
|
/* sprite control block */
|
|
|
|
sprite = (osspriteop_header *) (sprite_area + 1);
|
|
|
|
sprite->size = area_size - 16;
|
2006-02-21 23:49:12 +03:00
|
|
|
memset(sprite->name, 0x00, 12);
|
2004-12-25 14:37:35 +03:00
|
|
|
strncpy(sprite->name, "bitmap", 12);
|
2005-06-23 21:22:28 +04:00
|
|
|
sprite->width = bitmap->width - 1;
|
|
|
|
sprite->height = bitmap->height - 1;
|
2004-12-25 14:37:35 +03:00
|
|
|
sprite->left_bit = 0;
|
|
|
|
sprite->right_bit = 31;
|
|
|
|
sprite->image = sprite->mask = 44;
|
2005-06-23 21:22:28 +04:00
|
|
|
sprite->mode = tinct_SPRITE_MODE;
|
2006-01-25 02:05:22 +03:00
|
|
|
|
|
|
|
bitmap_maintenance = true;
|
|
|
|
bitmap_maintenance_priority |=
|
|
|
|
(bitmap_direct_used > bitmap_direct_size * 0.9);
|
2005-06-23 21:22:28 +04:00
|
|
|
return true;
|
2004-12-25 14:37:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets whether a bitmap should be plotted opaque
|
|
|
|
*
|
|
|
|
* \param bitmap a bitmap, as returned by bitmap_create()
|
|
|
|
* \param opaque whether the bitmap should be plotted opaque
|
|
|
|
*/
|
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
|
|
|
void bitmap_set_opaque(void *vbitmap, bool opaque)
|
2004-12-25 14:37:35 +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
|
|
|
struct bitmap *bitmap = (struct bitmap *) vbitmap;
|
2004-12-25 14:37:35 +03:00
|
|
|
assert(bitmap);
|
2006-06-21 02:58:36 +04:00
|
|
|
|
2006-02-22 04:58:19 +03:00
|
|
|
if (opaque)
|
|
|
|
bitmap->state |= BITMAP_OPAQUE;
|
|
|
|
else
|
|
|
|
bitmap->state &= ~BITMAP_OPAQUE;
|
2004-12-25 14:37:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests whether a bitmap has an opaque alpha channel
|
|
|
|
*
|
|
|
|
* \param bitmap a bitmap, as returned by bitmap_create()
|
|
|
|
* \return whether the bitmap is opaque
|
|
|
|
*/
|
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
|
|
|
bool bitmap_test_opaque(void *vbitmap)
|
2004-12-25 14:37:35 +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
|
|
|
struct bitmap *bitmap = (struct bitmap *) vbitmap;
|
2009-03-27 05:46:30 +03:00
|
|
|
unsigned char *sprite;
|
|
|
|
unsigned int width, height, size;
|
|
|
|
osspriteop_header *sprite_header;
|
|
|
|
unsigned *p, *ep;
|
|
|
|
|
2004-12-25 14:37:35 +03:00
|
|
|
assert(bitmap);
|
2009-03-27 05:46:30 +03:00
|
|
|
|
|
|
|
sprite = bitmap_get_buffer(bitmap);
|
2005-06-23 21:22:28 +04:00
|
|
|
if (!sprite)
|
|
|
|
return false;
|
2009-03-27 05:46:30 +03:00
|
|
|
|
|
|
|
width = bitmap_get_rowstride(bitmap);
|
|
|
|
|
|
|
|
sprite_header = (osspriteop_header *) (bitmap->sprite_area + 1);
|
|
|
|
|
|
|
|
height = (sprite_header->height + 1);
|
|
|
|
|
|
|
|
size = width * height;
|
|
|
|
|
|
|
|
p = (void *) sprite;
|
|
|
|
|
|
|
|
ep = (void *) (sprite + (size & ~31));
|
2005-04-15 09:54:44 +04:00
|
|
|
while (p < ep) {
|
|
|
|
/* \todo prefetch(p, 128)? */
|
|
|
|
if (((p[0] & p[1] & p[2] & p[3] & p[4] & p[5] & p[6] & p[7])
|
|
|
|
& 0xff000000U) != 0xff000000U)
|
2004-12-25 14:37:35 +03:00
|
|
|
return false;
|
2005-04-15 09:54:44 +04:00
|
|
|
p += 8;
|
|
|
|
}
|
2009-03-27 05:46:30 +03:00
|
|
|
|
|
|
|
ep = (void *) (sprite + size);
|
2005-04-15 09:54:44 +04:00
|
|
|
while (p < ep) {
|
|
|
|
if ((*p & 0xff000000U) != 0xff000000U) return false;
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
2004-12-25 14:37:35 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets whether a bitmap should be plotted opaque
|
|
|
|
*
|
|
|
|
* \param bitmap a bitmap, as returned by bitmap_create()
|
|
|
|
*/
|
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
|
|
|
bool bitmap_get_opaque(void *vbitmap)
|
2004-12-25 14:37:35 +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
|
|
|
struct bitmap *bitmap = (struct bitmap *) vbitmap;
|
2004-12-25 14:37:35 +03:00
|
|
|
assert(bitmap);
|
2006-02-22 04:58:19 +03:00
|
|
|
return (bitmap->state & BITMAP_OPAQUE);
|
2004-12-25 14:37:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a pointer to the pixel data in a bitmap.
|
|
|
|
*
|
|
|
|
* \param bitmap a bitmap, as returned by bitmap_create()
|
|
|
|
* \return pointer to the pixel buffer
|
|
|
|
*
|
|
|
|
* The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
|
|
|
|
* of rows. The width of a row in bytes is given by bitmap_get_rowstride().
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
unsigned char *bitmap_get_buffer(void *vbitmap)
|
2004-12-25 14:37:35 +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
|
|
|
struct bitmap *bitmap = (struct bitmap *) vbitmap;
|
2004-12-25 14:37:35 +03:00
|
|
|
assert(bitmap);
|
2005-06-23 21:22:28 +04:00
|
|
|
|
|
|
|
/* move to the head of the list */
|
|
|
|
if (bitmap_head != bitmap) {
|
|
|
|
if (bitmap->previous)
|
|
|
|
bitmap->previous->next = bitmap->next;
|
|
|
|
if (bitmap->next)
|
|
|
|
bitmap->next->previous = bitmap->previous;
|
|
|
|
bitmap->next = bitmap_head;
|
|
|
|
bitmap_head->previous = bitmap;
|
|
|
|
bitmap->previous = NULL;
|
|
|
|
bitmap_head = bitmap;
|
|
|
|
}
|
2006-06-21 02:58:36 +04:00
|
|
|
|
2006-01-25 02:05:22 +03:00
|
|
|
/* dynamically create the buffer */
|
2006-02-22 04:58:19 +03:00
|
|
|
if (!(bitmap->state & BITMAP_READY)) {
|
|
|
|
if (!bitmap_initialise(bitmap))
|
|
|
|
return NULL;
|
2006-01-25 02:05:22 +03:00
|
|
|
}
|
|
|
|
|
2006-02-22 04:58:19 +03:00
|
|
|
/* reset our suspended flag */
|
|
|
|
if (bitmap->state & BITMAP_SUSPENDED)
|
|
|
|
bitmap->state &= ~BITMAP_SUSPENDED;
|
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
/* image is already decompressed, no change to image states */
|
|
|
|
if (bitmap->sprite_area)
|
2009-03-27 05:46:30 +03:00
|
|
|
return ((unsigned char *) (bitmap->sprite_area)) + 16 + 44;
|
2005-06-23 21:22:28 +04:00
|
|
|
|
|
|
|
/* load and/or decompress the image */
|
2005-10-02 03:28:46 +04:00
|
|
|
if (bitmap->filename[0])
|
2005-06-23 21:22:28 +04:00
|
|
|
bitmap_load_file(bitmap);
|
|
|
|
if (bitmap->compressed)
|
|
|
|
bitmap_decompress(bitmap);
|
|
|
|
|
|
|
|
bitmap_maintenance = true;
|
|
|
|
bitmap_maintenance_priority |=
|
2006-01-03 01:04:35 +03:00
|
|
|
(bitmap_direct_used > bitmap_direct_size * 0.9);
|
2005-06-23 21:22:28 +04:00
|
|
|
|
|
|
|
if (bitmap->sprite_area)
|
2009-03-27 05:46:30 +03:00
|
|
|
return ((unsigned char *) (bitmap->sprite_area)) + 16 + 44;
|
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
return NULL;
|
2004-12-25 14:37:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find the width of a pixel row in bytes.
|
|
|
|
*
|
|
|
|
* \param bitmap a bitmap, as returned by bitmap_create()
|
|
|
|
* \return width of a pixel row in the bitmap
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
size_t bitmap_get_rowstride(void *vbitmap)
|
2004-12-25 14:37:35 +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
|
|
|
struct bitmap *bitmap = (struct bitmap *) vbitmap;
|
2005-06-23 21:22:28 +04:00
|
|
|
return bitmap->width * 4;
|
2004-12-25 14:37:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Free a bitmap.
|
|
|
|
*
|
|
|
|
* \param bitmap a bitmap, as returned by bitmap_create()
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
void bitmap_destroy(void *vbitmap)
|
2004-12-25 14:37:35 +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
|
|
|
struct bitmap *bitmap = (struct bitmap *) vbitmap;
|
2006-01-25 02:05:22 +03:00
|
|
|
struct bitmap_compressed_header *header;
|
2006-01-03 01:04:35 +03:00
|
|
|
unsigned int area_size;
|
2005-09-08 00:22:33 +04:00
|
|
|
|
2004-12-25 14:37:35 +03:00
|
|
|
assert(bitmap);
|
2005-09-08 00:22:33 +04:00
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
/* delink from list */
|
|
|
|
bitmap_maintenance = true;
|
|
|
|
if (bitmap_head == bitmap)
|
|
|
|
bitmap_head = bitmap->next;
|
|
|
|
if (bitmap->previous)
|
|
|
|
bitmap->previous->next = bitmap->next;
|
|
|
|
if (bitmap->next)
|
|
|
|
bitmap->next->previous = bitmap->previous;
|
|
|
|
|
|
|
|
/* destroy bitmap */
|
|
|
|
if (bitmap->sprite_area) {
|
|
|
|
area_size = 16 + 44 + bitmap->width * bitmap->height * 4;
|
2005-09-08 00:22:33 +04:00
|
|
|
bitmap_direct_used -= area_size;
|
2005-06-23 21:22:28 +04:00
|
|
|
free(bitmap->sprite_area);
|
|
|
|
}
|
2006-01-25 02:05:22 +03:00
|
|
|
if (bitmap->compressed) {
|
2009-03-27 05:46:30 +03:00
|
|
|
header = (void *) bitmap->compressed;
|
2006-01-25 02:05:22 +03:00
|
|
|
bitmap_compressed_used -= header->input_size +
|
|
|
|
sizeof(struct bitmap_compressed_header);
|
2005-06-23 21:22:28 +04:00
|
|
|
free(bitmap->compressed);
|
2006-01-25 02:05:22 +03:00
|
|
|
}
|
2005-10-02 03:28:46 +04:00
|
|
|
if (bitmap->filename[0])
|
2005-06-23 21:22:28 +04:00
|
|
|
bitmap_delete_file(bitmap);
|
2004-12-25 14:37:35 +03:00
|
|
|
free(bitmap);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save a bitmap in the platform's native format.
|
|
|
|
*
|
|
|
|
* \param bitmap a bitmap, as returned by bitmap_create()
|
2005-06-23 21:22:28 +04:00
|
|
|
* \param path pathname for file
|
2008-03-24 04:35:13 +03:00
|
|
|
* \param flags modify the behaviour of the save
|
2004-12-25 14:37:35 +03:00
|
|
|
* \return true on success, false on error and error reported
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
|
2004-12-25 14:37:35 +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
|
|
|
struct bitmap *bitmap = (struct bitmap *) vbitmap;
|
2004-12-25 14:37:35 +03:00
|
|
|
os_error *error;
|
2008-03-24 04:35:13 +03:00
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
if (!bitmap->sprite_area)
|
|
|
|
bitmap_get_buffer(bitmap);
|
|
|
|
if (!bitmap->sprite_area)
|
|
|
|
return false;
|
2008-03-24 04:35:13 +03:00
|
|
|
|
|
|
|
if (bitmap_get_opaque(bitmap)) {
|
|
|
|
error = xosspriteop_save_sprite_file(osspriteop_USER_AREA,
|
2008-09-17 02:14:39 +04:00
|
|
|
(bitmap->sprite_area), path);
|
2008-03-24 04:35:13 +03:00
|
|
|
if (error) {
|
|
|
|
LOG(("xosspriteop_save_sprite_file: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("SaveError", error->errmess);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
/* to make the saved sprite useful we must convert from 'Tinct'
|
2008-09-17 02:14:39 +04:00
|
|
|
* format to either a bi-level mask or a Select-style full
|
|
|
|
* alpha channel */
|
2008-03-24 04:35:13 +03:00
|
|
|
osspriteop_area *area = bitmap->sprite_area;
|
2009-03-27 05:46:30 +03:00
|
|
|
osspriteop_header *hdr = (void *) ((char *) area + area->first);
|
2008-03-24 04:35:13 +03:00
|
|
|
unsigned width = hdr->width + 1, height = hdr->height + 1;
|
|
|
|
unsigned image_size = height * width * 4;
|
|
|
|
unsigned char *chunk_buf;
|
|
|
|
unsigned *p, *elp, *eip;
|
|
|
|
unsigned mask_size;
|
|
|
|
size_t chunk_pix;
|
|
|
|
struct {
|
|
|
|
osspriteop_area area;
|
|
|
|
osspriteop_header hdr;
|
|
|
|
} file_hdr;
|
|
|
|
os_fw fw;
|
|
|
|
|
|
|
|
/* we only support 32bpp sprites */
|
|
|
|
if ((((unsigned)hdr->mode >> 27)&15) != 6) {
|
|
|
|
assert(!"Unsupported sprite format in bitmap_save");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
chunk_buf = malloc(SAVE_CHUNK_SIZE);
|
|
|
|
if (!chunk_buf) {
|
|
|
|
warn_user("NoMemory", NULL);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
file_hdr.area = *area;
|
|
|
|
file_hdr.hdr = *hdr;
|
|
|
|
|
|
|
|
if (flags & BITMAP_SAVE_FULL_ALPHA) {
|
|
|
|
mask_size = ((width + 3) & ~3) * height;
|
|
|
|
chunk_pix = SAVE_CHUNK_SIZE;
|
|
|
|
file_hdr.hdr.mode = (os_mode)((unsigned)file_hdr.hdr.mode
|
|
|
|
| (1U<<31));
|
|
|
|
} else {
|
|
|
|
mask_size = (((width + 31) & ~31)/8) * height;
|
|
|
|
chunk_pix = SAVE_CHUNK_SIZE<<3;
|
|
|
|
file_hdr.hdr.mode = (os_mode)((unsigned)file_hdr.hdr.mode
|
|
|
|
& ~(1U<<31));
|
|
|
|
}
|
|
|
|
|
|
|
|
file_hdr.area.sprite_count = 1;
|
|
|
|
file_hdr.area.first = sizeof(file_hdr.area);
|
|
|
|
file_hdr.area.used = sizeof(file_hdr) + image_size + mask_size;
|
|
|
|
|
|
|
|
file_hdr.hdr.image = sizeof(file_hdr.hdr);
|
|
|
|
file_hdr.hdr.mask = file_hdr.hdr.image + image_size;
|
|
|
|
file_hdr.hdr.size = file_hdr.hdr.mask + mask_size;
|
|
|
|
|
|
|
|
error = xosfind_openoutw(0, path, NULL, &fw);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xosfind_openoutw: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
free(chunk_buf);
|
|
|
|
warn_user("SaveError", error->errmess);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-03-27 05:46:30 +03:00
|
|
|
p = (void *) ((char *) hdr + hdr->image);
|
2008-03-24 04:35:13 +03:00
|
|
|
|
|
|
|
/* write out the area header, sprite header and image data */
|
|
|
|
error = xosgbpb_writew(fw, (byte*)&file_hdr + 4,
|
|
|
|
sizeof(file_hdr)-4, NULL);
|
|
|
|
if (!error)
|
|
|
|
error = xosgbpb_writew(fw, (byte*)p, image_size, NULL);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xosgbpb_writew: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
free(chunk_buf);
|
|
|
|
xosfind_closew(fw);
|
|
|
|
warn_user("SaveError", error->errmess);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* then write out the mask data in chunks */
|
|
|
|
eip = p + (width * height); /* end of image */
|
|
|
|
elp = p + width; /* end of line */
|
|
|
|
|
|
|
|
while (p < eip) {
|
|
|
|
unsigned char *dp = chunk_buf;
|
|
|
|
unsigned *ep = p + chunk_pix;
|
|
|
|
if (ep > elp) ep = elp;
|
|
|
|
|
|
|
|
if (flags & BITMAP_SAVE_FULL_ALPHA) {
|
|
|
|
while (p < ep) {
|
|
|
|
*dp++ = ((unsigned char*)p)[3];
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
unsigned char mb = 0;
|
|
|
|
int msh = 0;
|
|
|
|
while (p < ep) {
|
|
|
|
if (((unsigned char*)p)[3]) mb |= (1 << msh);
|
|
|
|
if (++msh >= 8) {
|
|
|
|
*dp++ = mb;
|
|
|
|
msh = 0;
|
|
|
|
mb = 0;
|
|
|
|
}
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
if (msh > 0) *dp++ = mb;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p >= elp) { /* end of line yet? */
|
|
|
|
/* align to word boundary */
|
|
|
|
while ((int)dp & 3) *dp++ = 0;
|
|
|
|
/* advance end of line pointer */
|
|
|
|
elp += width;
|
|
|
|
}
|
|
|
|
error = xosgbpb_writew(fw, (byte*)chunk_buf, dp-chunk_buf, NULL);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xosgbpb_writew: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
free(chunk_buf);
|
|
|
|
xosfind_closew(fw);
|
|
|
|
warn_user("SaveError", error->errmess);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
error = xosfind_closew(fw);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xosfind_closew: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("SaveError", error->errmess);
|
|
|
|
}
|
|
|
|
|
|
|
|
error = xosfile_set_type(path, osfile_TYPE_SPRITE);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xosfile_set_type: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("SaveError", error->errmess);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(chunk_buf);
|
|
|
|
return true;
|
2004-12-25 14:37:35 +03:00
|
|
|
}
|
|
|
|
}
|
2005-06-23 21:22:28 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2005-07-16 09:54:45 +04:00
|
|
|
* The bitmap image has changed, so flush any persistent cache.
|
2005-06-23 21:22:28 +04:00
|
|
|
*
|
|
|
|
* \param bitmap a bitmap, as returned by bitmap_create()
|
|
|
|
*/
|
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
|
|
|
void bitmap_modified(void *vbitmap) {
|
|
|
|
struct bitmap *bitmap = (struct bitmap *) vbitmap;
|
2006-02-22 04:58:19 +03:00
|
|
|
bitmap->state |= BITMAP_MODIFIED;
|
2005-06-23 21:22:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-22 04:58:19 +03:00
|
|
|
/**
|
|
|
|
* 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 invalidate the function to be called upon suspension
|
|
|
|
*/
|
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
|
|
|
void bitmap_set_suspendable(void *vbitmap, void *private_word,
|
|
|
|
void (*invalidate)(void *bitmap, void *private_word)) {
|
|
|
|
struct bitmap *bitmap = (struct bitmap *) vbitmap;
|
2009-03-27 05:46:30 +03:00
|
|
|
|
2006-02-22 04:58:19 +03:00
|
|
|
bitmap->private_word = private_word;
|
|
|
|
bitmap->invalidate = invalidate;
|
2006-06-21 02:58:36 +04:00
|
|
|
bitmap_suspendable++;
|
|
|
|
}
|
2006-02-22 04:58:19 +03:00
|
|
|
|
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
/**
|
|
|
|
* Performs routine maintenance.
|
|
|
|
*/
|
|
|
|
void bitmap_maintain(void)
|
|
|
|
{
|
2006-01-03 01:04:35 +03:00
|
|
|
unsigned int memory = 0;
|
|
|
|
unsigned int compressed_memory = 0;
|
2006-02-22 04:58:19 +03:00
|
|
|
unsigned int suspended = 0;
|
2005-06-23 21:22:28 +04:00
|
|
|
struct bitmap *bitmap = bitmap_head;
|
|
|
|
struct bitmap_compressed_header *header;
|
|
|
|
unsigned int maintain_direct_size;
|
|
|
|
|
2005-12-31 07:29:00 +03:00
|
|
|
LOG(("Performing maintenance."));
|
2005-06-23 21:22:28 +04:00
|
|
|
|
2006-01-03 01:04:35 +03:00
|
|
|
/* under heavy loads allow an extra 30% to work with */
|
|
|
|
maintain_direct_size = bitmap_direct_size;
|
|
|
|
if (!bitmap_maintenance_priority)
|
|
|
|
maintain_direct_size = maintain_direct_size * 0.7;
|
|
|
|
|
|
|
|
if ((!bitmap) || ((bitmap_direct_used < maintain_direct_size) &&
|
2005-12-31 07:29:00 +03:00
|
|
|
(bitmap_compressed_used < bitmap_compressed_size))) {
|
2006-01-03 01:04:35 +03:00
|
|
|
bitmap_maintenance = bitmap_maintenance_priority;
|
2005-06-23 21:22:28 +04:00
|
|
|
bitmap_maintenance_priority = false;
|
|
|
|
return;
|
|
|
|
}
|
2005-12-31 07:29:00 +03:00
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
/* we don't change the first bitmap_MEMORY entries as they
|
|
|
|
* will automatically be loaded/decompressed from whatever state
|
|
|
|
* they are in when neeeded. */
|
2006-01-03 01:04:35 +03:00
|
|
|
for (; bitmap && (memory < maintain_direct_size);
|
|
|
|
bitmap = bitmap->next) {
|
2005-06-23 21:22:28 +04:00
|
|
|
if (bitmap->sprite_area)
|
|
|
|
memory += bitmap->width * bitmap->height * 4;
|
2006-01-03 01:04:35 +03:00
|
|
|
else if ((bitmap->compressed) &&
|
|
|
|
(!bitmap_maintenance_priority)) {
|
2009-03-27 05:46:30 +03:00
|
|
|
header = (void *) bitmap->compressed;
|
2006-01-03 01:04:35 +03:00
|
|
|
compressed_memory += header->input_size +
|
|
|
|
sizeof(struct bitmap_compressed_header);
|
2006-02-22 04:58:19 +03:00
|
|
|
} else if (bitmap->state & BITMAP_SUSPENDED)
|
|
|
|
suspended++;
|
2006-01-03 01:04:35 +03:00
|
|
|
}
|
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
if (!bitmap) {
|
|
|
|
bitmap_maintenance = bitmap_maintenance_priority;
|
|
|
|
bitmap_maintenance_priority = false;
|
|
|
|
return;
|
|
|
|
}
|
2006-06-21 02:58:36 +04:00
|
|
|
|
2006-02-22 04:58:19 +03:00
|
|
|
/* the fastest and easiest way to release memory is by suspending
|
|
|
|
* images. as such, we try to do this first for as many images as
|
|
|
|
* possible, potentially freeing up large amounts of memory */
|
|
|
|
if (suspended <= (bitmap_suspendable - bitmap_suspended)) {
|
|
|
|
for (; bitmap; bitmap = bitmap->next) {
|
|
|
|
if (bitmap->invalidate) {
|
|
|
|
bitmap->invalidate(bitmap, bitmap->private_word);
|
|
|
|
free(bitmap->sprite_area);
|
|
|
|
bitmap->sprite_area = NULL;
|
|
|
|
bitmap->state |= BITMAP_SUSPENDED;
|
|
|
|
bitmap->state &= ~BITMAP_READY;
|
|
|
|
bitmap_direct_used -= 16 + 44 +
|
|
|
|
bitmap->width * bitmap->height * 4;
|
|
|
|
bitmap_suspended++;
|
2006-06-21 02:58:36 +04:00
|
|
|
}
|
2006-02-22 04:58:19 +03:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2005-06-23 21:22:28 +04:00
|
|
|
|
|
|
|
/* under heavy loads, we ignore compression */
|
|
|
|
if (!bitmap_maintenance_priority) {
|
|
|
|
/* for the next section, up until bitmap_COMPRESSED we
|
|
|
|
* forcibly compress the data if it's currently held directly
|
|
|
|
* in memory */
|
2006-01-03 01:04:35 +03:00
|
|
|
for (; bitmap && (compressed_memory < bitmap_compressed_size);
|
2005-06-23 21:22:28 +04:00
|
|
|
bitmap = bitmap->next) {
|
|
|
|
if (bitmap->sprite_area) {
|
2006-01-03 01:04:35 +03:00
|
|
|
if ((bitmap->width * bitmap->height) <=
|
|
|
|
(512 * 512))
|
|
|
|
bitmap_compress(bitmap);
|
|
|
|
else
|
|
|
|
bitmap_save_file(bitmap);
|
2005-06-23 21:22:28 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (bitmap->compressed) {
|
2009-03-27 05:46:30 +03:00
|
|
|
header = (void *) bitmap->compressed;
|
2006-01-03 01:04:35 +03:00
|
|
|
compressed_memory += header->input_size +
|
2005-06-23 21:22:28 +04:00
|
|
|
sizeof(struct bitmap_compressed_header);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!bitmap) {
|
|
|
|
bitmap_maintenance = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2006-01-03 01:04:35 +03:00
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
/* for the remaining entries we dump to disk */
|
|
|
|
for (; bitmap; bitmap = bitmap->next) {
|
|
|
|
if ((bitmap->sprite_area) || (bitmap->compressed)) {
|
2006-01-03 01:04:35 +03:00
|
|
|
if (bitmap_maintenance_priority) {
|
|
|
|
if (bitmap->sprite_area)
|
2005-06-23 21:22:28 +04:00
|
|
|
bitmap_save_file(bitmap);
|
2005-09-08 00:22:33 +04:00
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
} else {
|
|
|
|
bitmap_save_file(bitmap);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bitmap_maintenance = bitmap_maintenance_priority;
|
|
|
|
bitmap_maintenance_priority = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void bitmap_decompress(struct bitmap *bitmap)
|
|
|
|
{
|
2006-01-03 01:04:35 +03:00
|
|
|
unsigned int area_size;
|
2005-06-23 21:22:28 +04:00
|
|
|
_kernel_oserror *error;
|
|
|
|
int output_size;
|
|
|
|
struct bitmap_compressed_header *header;
|
|
|
|
|
|
|
|
assert(bitmap->compressed);
|
|
|
|
|
2005-12-18 18:53:47 +03:00
|
|
|
/* ensure the width/height is correct */
|
2009-03-27 05:46:30 +03:00
|
|
|
header = (void *)bitmap->compressed;
|
2005-12-18 18:53:47 +03:00
|
|
|
if ((header->width != bitmap->width) ||
|
|
|
|
(header->height != bitmap->height)) {
|
|
|
|
LOG(("Warning: Mismatch between bitmap and compressed sizes"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
/* create the image memory/header to decompress to */
|
2006-02-21 23:49:12 +03:00
|
|
|
if (!bitmap_initialise(bitmap))
|
2005-06-23 21:22:28 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* decompress the data */
|
|
|
|
output_size = bitmap->width * bitmap->height * 4 +
|
|
|
|
sizeof(struct osspriteop_header);
|
|
|
|
error = _swix(Tinct_Decompress, _IN(0) | _IN(2) | _IN(3) | _IN(7),
|
|
|
|
bitmap->compressed,
|
|
|
|
(char *)(bitmap->sprite_area + 1),
|
|
|
|
output_size,
|
|
|
|
0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("Decompression error"));
|
|
|
|
free(bitmap->sprite_area);
|
|
|
|
bitmap->sprite_area = NULL;
|
|
|
|
} else {
|
2005-12-31 07:29:00 +03:00
|
|
|
LOG(("Decompressed"));
|
2005-06-23 21:22:28 +04:00
|
|
|
area_size = header->input_size +
|
|
|
|
sizeof(struct bitmap_compressed_header);
|
|
|
|
bitmap_compressed_used -= area_size;
|
|
|
|
free(bitmap->compressed);
|
|
|
|
bitmap->compressed = NULL;
|
|
|
|
area_size = 16 + 44 + bitmap->width * bitmap->height * 4;
|
2005-09-08 00:22:33 +04:00
|
|
|
bitmap_direct_used += area_size;
|
2005-06-23 21:22:28 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void bitmap_compress(struct bitmap *bitmap)
|
|
|
|
{
|
2005-09-08 00:22:33 +04:00
|
|
|
unsigned int area_size;
|
2005-06-23 21:22:28 +04:00
|
|
|
_kernel_oserror *error;
|
|
|
|
char *output;
|
|
|
|
unsigned int output_size, new_size;
|
|
|
|
unsigned int flags = 0;
|
|
|
|
float calc;
|
|
|
|
|
|
|
|
/* get the maximum output size (33/32 * size) */
|
|
|
|
output_size = ((bitmap->width * bitmap->height * 4 * 33) >> 5) +
|
|
|
|
sizeof(struct bitmap_compressed_header);
|
|
|
|
output = malloc(output_size);
|
|
|
|
if (!output)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* compress the data */
|
2006-02-22 04:58:19 +03:00
|
|
|
if (bitmap->state & BITMAP_OPAQUE)
|
2005-06-23 21:22:28 +04:00
|
|
|
flags |= tinct_OPAQUE_IMAGE;
|
|
|
|
error = _swix(Tinct_Compress, _IN(0) | _IN(2) | _IN(7) | _OUT(0),
|
|
|
|
(char *)(bitmap->sprite_area + 1),
|
|
|
|
output,
|
|
|
|
flags,
|
|
|
|
&new_size);
|
|
|
|
if (error) {
|
|
|
|
LOG(("Compression error"));
|
|
|
|
free(output);
|
|
|
|
} else {
|
|
|
|
bitmap->compressed = realloc(output, new_size);
|
|
|
|
if (!bitmap->compressed) {
|
|
|
|
free(output);
|
|
|
|
} else {
|
2005-09-08 00:22:33 +04:00
|
|
|
bitmap_compressed_used += new_size;
|
|
|
|
if (bitmap->sprite_area) {
|
2005-06-23 21:22:28 +04:00
|
|
|
area_size = 16 + 44 + bitmap->width *
|
|
|
|
bitmap->height * 4;
|
2005-09-08 00:22:33 +04:00
|
|
|
bitmap_direct_used -= area_size;
|
2005-06-23 21:22:28 +04:00
|
|
|
free(bitmap->sprite_area);
|
|
|
|
}
|
|
|
|
bitmap->sprite_area = NULL;
|
|
|
|
calc = (100 / (float)output_size) * new_size;
|
2005-12-31 07:29:00 +03:00
|
|
|
LOG(("Compression: %i->%i, %.3f%%",
|
|
|
|
output_size, new_size, calc));
|
2005-06-23 21:22:28 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void bitmap_load_file(struct bitmap *bitmap)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
fileswitch_object_type obj_type;
|
|
|
|
os_error *error;
|
2006-04-22 03:49:52 +04:00
|
|
|
char *r;
|
2005-12-31 07:29:00 +03:00
|
|
|
struct bitmap_compressed_header *bitmap_compressed;
|
|
|
|
osspriteop_header *bitmap_direct;
|
2009-03-27 05:46:30 +03:00
|
|
|
int *data;
|
2005-06-23 21:22:28 +04:00
|
|
|
|
|
|
|
assert(bitmap->filename);
|
|
|
|
|
2006-04-22 03:49:52 +04:00
|
|
|
sprintf(bitmap_unixname, "%s/%s", TEMP_FILENAME_PREFIX,
|
2005-06-23 21:22:28 +04:00
|
|
|
bitmap->filename);
|
2006-04-22 03:49:52 +04:00
|
|
|
r = __riscosify(bitmap_unixname, 0, __RISCOSIFY_NO_SUFFIX,
|
|
|
|
bitmap_filename, 256, 0);
|
|
|
|
if (r == 0) {
|
|
|
|
LOG(("__riscosify failed"));
|
|
|
|
return;
|
|
|
|
}
|
2005-06-23 21:22:28 +04:00
|
|
|
error = xosfile_read_stamped_no_path(bitmap_filename,
|
|
|
|
&obj_type, 0, 0, &len, 0, 0);
|
|
|
|
if ((error) || (obj_type != fileswitch_IS_FILE))
|
|
|
|
return;
|
2005-09-08 00:22:33 +04:00
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
bitmap->compressed = malloc(len);
|
|
|
|
if (!bitmap->compressed)
|
|
|
|
return;
|
2005-09-08 00:22:33 +04:00
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
error = xosfile_load_stamped_no_path(bitmap_filename,
|
2009-03-27 05:46:30 +03:00
|
|
|
(byte *) bitmap->compressed, 0, 0, 0, 0, 0);
|
2005-06-23 21:22:28 +04:00
|
|
|
if (error) {
|
|
|
|
free(bitmap->compressed);
|
|
|
|
bitmap->compressed = NULL;
|
|
|
|
return;
|
2005-09-08 00:22:33 +04:00
|
|
|
}
|
|
|
|
|
2009-03-27 05:46:30 +03:00
|
|
|
data = (void *) bitmap->compressed;
|
|
|
|
|
2005-12-31 07:29:00 +03:00
|
|
|
LOG(("Loaded file from disk"));
|
2005-09-08 00:22:33 +04:00
|
|
|
/* Sanity check the file we've just loaded:
|
|
|
|
* If it's an uncompressed buffer, then it's a raw sprite area,
|
|
|
|
* including the total size word at the start. Therefore, we check
|
|
|
|
* that:
|
|
|
|
* a) The declared total area size == file length
|
|
|
|
* b) The offset to the first free word == file length
|
|
|
|
* c) There is only 1 sprite in the area
|
|
|
|
* d) The name of the sprite in the area is "bitmap"
|
|
|
|
*
|
|
|
|
* If it's a compressed buffer, then we check that:
|
|
|
|
* a) The declared input size + header size == file length
|
|
|
|
* b) The name of the buffer is "bitmap"
|
|
|
|
*
|
|
|
|
* If it's neither of these, we fail.
|
|
|
|
*/
|
2009-03-27 05:46:30 +03:00
|
|
|
if (*data == len && *(data + 3) == len && *(data + 1) == 1 &&
|
2005-09-08 00:22:33 +04:00
|
|
|
strncmp(bitmap->compressed + 20, "bitmap", 6) == 0) {
|
2009-03-27 05:46:30 +03:00
|
|
|
bitmap->sprite_area = (void *) bitmap->compressed;
|
2005-09-08 00:22:33 +04:00
|
|
|
bitmap->compressed = NULL;
|
2005-12-31 07:29:00 +03:00
|
|
|
bitmap_direct = (osspriteop_header *)(bitmap->sprite_area + 1);
|
|
|
|
bitmap->width = bitmap_direct->width + 1;
|
|
|
|
bitmap->height = bitmap_direct->height + 1;
|
|
|
|
bitmap_direct_used += 16 + 44 +
|
|
|
|
bitmap->width * bitmap->height * 4;
|
2009-03-27 05:46:30 +03:00
|
|
|
} else if ((int) (*(data + 6) +
|
2005-09-08 00:22:33 +04:00
|
|
|
sizeof(struct bitmap_compressed_header)) == len &&
|
|
|
|
strncmp(bitmap->compressed + 8, "bitmap", 6) == 0) {
|
2009-03-27 05:46:30 +03:00
|
|
|
bitmap_compressed = (void *) bitmap->compressed;
|
2006-01-25 02:05:22 +03:00
|
|
|
bitmap_compressed_used -= bitmap_compressed->input_size +
|
|
|
|
sizeof(struct bitmap_compressed_header);
|
2005-12-31 07:29:00 +03:00
|
|
|
bitmap->width = bitmap_compressed->width;
|
|
|
|
bitmap->height = bitmap_compressed->height;
|
2005-06-23 21:22:28 +04:00
|
|
|
} else {
|
2005-09-08 00:22:33 +04:00
|
|
|
free(bitmap->compressed);
|
|
|
|
bitmap->compressed = NULL;
|
|
|
|
return;
|
2005-06-23 21:22:28 +04:00
|
|
|
}
|
2006-02-22 04:58:19 +03:00
|
|
|
if (bitmap->state & BITMAP_MODIFIED)
|
2005-09-08 00:22:33 +04:00
|
|
|
bitmap_delete_file(bitmap);
|
2005-06-23 21:22:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void bitmap_save_file(struct bitmap *bitmap)
|
|
|
|
{
|
2005-09-08 00:22:33 +04:00
|
|
|
unsigned int area_size;
|
2009-03-27 05:46:30 +03:00
|
|
|
const char *filename;
|
|
|
|
char *r;
|
2005-06-23 21:22:28 +04:00
|
|
|
os_error *error;
|
|
|
|
struct bitmap_compressed_header *header;
|
|
|
|
|
2008-06-15 03:13:19 +04:00
|
|
|
assert(bitmap);
|
|
|
|
|
|
|
|
if (!bitmap->compressed && !bitmap->sprite_area) {
|
|
|
|
LOG(("bitmap has no data"));
|
|
|
|
return;
|
|
|
|
}
|
2005-06-23 21:22:28 +04:00
|
|
|
|
|
|
|
/* unmodified bitmaps will still have their file available */
|
2006-02-22 04:58:19 +03:00
|
|
|
if ((!(bitmap->state & BITMAP_MODIFIED)) && bitmap->filename[0]) {
|
2005-06-23 21:22:28 +04:00
|
|
|
if (bitmap->sprite_area)
|
|
|
|
free(bitmap->sprite_area);
|
|
|
|
bitmap->sprite_area = NULL;
|
|
|
|
if (bitmap->compressed)
|
|
|
|
free(bitmap->compressed);
|
|
|
|
bitmap->compressed = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dump the data (compressed or otherwise) to disk */
|
2006-04-22 03:49:52 +04:00
|
|
|
filename = filename_request();
|
2006-06-21 02:58:36 +04:00
|
|
|
if (!filename) {
|
|
|
|
LOG(("filename_request failed"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
strcpy(bitmap->filename, filename);
|
2006-04-22 03:49:52 +04:00
|
|
|
sprintf(bitmap_unixname, "%s/%s", TEMP_FILENAME_PREFIX,
|
2005-06-23 21:22:28 +04:00
|
|
|
bitmap->filename);
|
2006-04-22 03:49:52 +04:00
|
|
|
r = __riscosify(bitmap_unixname, 0, __RISCOSIFY_NO_SUFFIX,
|
|
|
|
bitmap_filename, 256, 0);
|
|
|
|
if (r == 0) {
|
|
|
|
LOG(("__riscosify failed"));
|
|
|
|
return;
|
|
|
|
}
|
2005-06-23 21:22:28 +04:00
|
|
|
if (bitmap->compressed) {
|
2009-03-27 05:46:30 +03:00
|
|
|
header = (void *) bitmap->compressed;
|
2005-06-23 21:22:28 +04:00
|
|
|
area_size = header->input_size +
|
|
|
|
sizeof(struct bitmap_compressed_header);
|
|
|
|
error = xosfile_save_stamped(bitmap_filename, 0xffd,
|
2009-03-27 05:46:30 +03:00
|
|
|
(byte *) bitmap->compressed,
|
|
|
|
(byte *) bitmap->compressed + area_size);
|
2005-06-23 21:22:28 +04:00
|
|
|
} else {
|
|
|
|
area_size = bitmap->width * bitmap->height * 4 +
|
|
|
|
sizeof(osspriteop_header) +
|
|
|
|
sizeof(osspriteop_area);
|
|
|
|
error = xosfile_save_stamped(bitmap_filename, 0xffd,
|
2009-03-27 05:46:30 +03:00
|
|
|
(byte *) bitmap->sprite_area,
|
|
|
|
((byte *) bitmap->sprite_area) + area_size);
|
2005-06-23 21:22:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (error) {
|
2006-08-31 00:09:02 +04:00
|
|
|
LOG(("xosfile_save_stamped: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
2005-06-23 21:22:28 +04:00
|
|
|
bitmap->filename[0] = 0;
|
|
|
|
} else {
|
|
|
|
if (bitmap->sprite_area) {
|
2005-09-08 00:22:33 +04:00
|
|
|
bitmap_direct_used -= area_size;
|
2005-06-23 21:22:28 +04:00
|
|
|
free(bitmap->sprite_area);
|
|
|
|
}
|
|
|
|
bitmap->sprite_area = NULL;
|
|
|
|
if (bitmap->compressed) {
|
2005-09-08 00:22:33 +04:00
|
|
|
bitmap_compressed_used -= area_size;
|
2005-06-23 21:22:28 +04:00
|
|
|
free(bitmap->compressed);
|
|
|
|
}
|
|
|
|
bitmap->compressed = NULL;
|
2006-02-22 04:58:19 +03:00
|
|
|
bitmap->state &= ~BITMAP_MODIFIED;
|
2005-12-31 07:29:00 +03:00
|
|
|
LOG(("Saved file to disk"));
|
2005-06-23 21:22:28 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void bitmap_delete_file(struct bitmap *bitmap)
|
|
|
|
{
|
|
|
|
assert(bitmap->filename[0]);
|
2006-04-22 03:49:52 +04:00
|
|
|
filename_release(bitmap->filename);
|
2005-06-23 21:22:28 +04:00
|
|
|
bitmap->filename[0] = 0;
|
|
|
|
}
|
2006-03-24 06:44:37 +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
|
|
|
int bitmap_get_width(void *vbitmap)
|
2006-03-24 06:44:37 +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
|
|
|
struct bitmap *bitmap = (struct bitmap *) vbitmap;
|
2006-03-24 06:44:37 +03:00
|
|
|
return bitmap->width;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
int bitmap_get_height(void *vbitmap)
|
2006-03-24 06:44:37 +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
|
|
|
struct bitmap *bitmap = (struct bitmap *) vbitmap;
|
2006-03-24 06:44:37 +03:00
|
|
|
return bitmap->height;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find the bytes per pixel of a bitmap
|
|
|
|
*
|
2008-09-07 23:08:57 +04:00
|
|
|
* \param vbitmap a bitmap, as returned by bitmap_create()
|
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 bytes per pixel
|
|
|
|
*/
|
|
|
|
|
|
|
|
size_t bitmap_get_bpp(void *vbitmap)
|
|
|
|
{
|
|
|
|
struct bitmap *bitmap = (struct bitmap *)vbitmap;
|
|
|
|
assert(bitmap);
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|