19 #include <sys/types.h> 41 int init_mfdb(
int bpp,
int w,
int h, uint32_t flags, MFDB * out )
45 int size =
MFDB_SIZE( bpp, dststride, h );
48 out->fd_addr = malloc( size );
49 if( out->fd_addr == NULL ){
53 memset( out->fd_addr, 0, size );
57 out->fd_nplanes = (short)bpp;
58 out->fd_r1 = out->fd_r2 = out->fd_r3 = 0;
60 memset( out, 0,
sizeof(MFDB) );
62 out->fd_w = dststride;
64 out->fd_wdwidth = dststride >> 4;
85 "width %d (rowstride: %d, bpp: %d), height %d, flags %u", w,
86 rowstride, bpp, h, (
unsigned)flags);
92 assert( rowstride >= (w * bpp) );
93 bitmap = calloc(1 ,
sizeof(
struct bitmap) );
95 if( pixdata == NULL) {
96 bitmap->
pixdata = calloc(1, (rowstride * h)+128);
112 NSLOG(netsurf, INFO,
"Out of memory!");
115 NSLOG(netsurf, INFO,
"bitmap %p", bitmap);
133 struct bitmap *bm =
bitmap;
140 free( bm->
native.fd_addr );
142 bm->
native.fd_addr = NULL;
152 int newsize = rowstride * h;
154 if( bitmap == NULL ) {
158 assert( bitmap->
pixdata != NULL );
160 bool doalloc = (state &
BITMAP_GROW) ? (newsize > oldsize) : (newsize != oldsize);
161 if( newsize > oldsize )
162 assert( doalloc ==
true );
172 memset( bitmap->
pixdata, 0x00, newsize + 128 );
196 struct bitmap *bm =
bitmap;
198 if (bitmap == NULL) {
199 NSLOG(netsurf, INFO,
"NULL bitmap!");
210 struct bitmap * bm =
bitmap;
220 struct bitmap *bm =
bitmap;
222 if (bitmap == NULL) {
223 NSLOG(netsurf, INFO,
"NULL bitmap!");
233 struct bitmap *bm =
bitmap;
235 if (bitmap == NULL) {
236 NSLOG(netsurf, INFO,
"NULL bitmap!");
244 free( bm->
native.fd_addr );
259 struct bitmap *bm =
bitmap;
261 if (bitmap == NULL) {
262 NSLOG(netsurf, INFO,
"NULL bitmap!");
266 NSLOG(netsurf, INFO,
"setting bitmap %p to %s", bm,
267 opaque ?
"opaque" :
"transparent");
281 struct bitmap *bm =
bitmap;
283 if (bitmap == NULL) {
284 NSLOG(netsurf, INFO,
"NULL bitmap!");
295 if (bm->
pixdata[(tst << 2) + 3] != 0xff) {
297 "bitmap %p has transparency", bm);
301 NSLOG(netsurf, INFO,
"bitmap %p is opaque", bm);
309 struct bitmap *bm =
bitmap;
311 if (bitmap == NULL) {
312 NSLOG(netsurf, INFO,
"NULL bitmap!");
323 struct bitmap *bm =
bitmap;
325 if (bitmap == NULL) {
326 NSLOG(netsurf, INFO,
"NULL bitmap!");
337 struct bitmap *bm =
bitmap;
339 if (bitmap == NULL) {
340 NSLOG(netsurf, INFO,
"NULL bitmap!");
348 HermesFormat *fmt,
int nw,
int nh)
366 if (img->
opaque ==
true) {
371 printf(
"W: %d, H: %d, bpp: %d\n", nw, nh, bpp);
377 err = Hermes_ConverterRequest( hermes_h,
385 err = Hermes_ConverterCopy( hermes_h,
size_t atari_bitmap_buffer_size(void *bitmap)
Interface to utility string handling.
static struct gui_bitmap_table bitmap_table
Functionality is not implemented.
void atari_bitmap_destroy(void *bitmap)
Free a bitmap.
int init_mfdb(int bpp, int w, int h, uint32_t flags, MFDB *out)
setup an MFDB struct and allocate memory for it when it is needed.
Core mouse and pointer states.
#define MFDB_FLAG_NOALLOC
static nserror bitmap(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
Plot a bitmap.
#define MFDB_FLAG_ZEROMEM
#define nsoption_int(OPTION)
Get the value of an integer option.
Option reading and saving interface.
static bool bitmap_test_opaque(void *bitmap)
Tests whether a bitmap has an opaque alpha channel.
nserror
Enumeration of error codes.
int height
height of bitmap
int atari_bitmap_get_width(void *bitmap)
Get bitmap width.
Content which corresponds to a single URL.
bool atari_bitmap_get_opaque(void *bitmap)
Gets whether a bitmap should be plotted opaque.
static void * atari_bitmap_create_ex(int w, int h, short bpp, int rowstride, enum gui_bitmap_flags flags, void *pixdata)
Create a bitmap.
static void bitmap_modified(void *bitmap)
The bitmap image has changed, so flush any persistant cache.
#define NSLOG(catname, level, logmsg, args...)
#define NS_BMP_DEFAULT_BPP
#define MFDB_STRIDE(w)
Calculates MFDB compatible rowstride (in number of bits)
RISC OS wimp toolkit bitmap.
int atari_bitmap_get_height(void *bitmap)
Get bitmap height.
static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *content)
size_t atari_bitmap_get_rowstride(void *bitmap)
Find the width of a pixel row in bytes.
gui_bitmap_flags
Bitmap creation flags.
memory should be wiped to 0
struct gui_bitmap_table * atari_bitmap_table
bool opaque
Whether the bitmap is opaque.
Netsurf additional integer type formatting macros.
#define MFDB_SIZE(bpp, stride, h)
Calculate size of an mfdb,.
Generic bitmap handling interface.
static unsigned char * bitmap_get_buffer(void *bitmap)
Return a pointer to the pixel data in a bitmap.
bool atari_bitmap_resize(struct bitmap *img, HermesHandle hermes_h, HermesFormat *fmt, int nw, int nh)
void * atari_bitmap_create(int w, int h, enum gui_bitmap_flags flags)
Create a bitmap.
void * atari_bitmap_realloc(int w, int h, short bpp, int rowstride, unsigned int state, void *bmp)
void *(* create)(int width, int height, enum gui_bitmap_flags flags)
Create a new bitmap.
Atari bitmap handling implementation.
static void bitmap_set_opaque(void *bitmap, bool opaque)
Sets whether a bitmap should be plotted opaque.