NetSurf
Data Structures | Typedefs | Functions | Variables
bmp.c File Reference

implementation of content handler for BMP images. More...

#include <stdbool.h>
#include <stdlib.h>
#include <libnsbmp.h>
#include "utils/utils.h"
#include "utils/messages.h"
#include "netsurf/plotters.h"
#include "netsurf/bitmap.h"
#include "netsurf/content.h"
#include "content/llcache.h"
#include "content/content_protected.h"
#include "content/content_factory.h"
#include "desktop/gui_internal.h"
#include "desktop/bitmap.h"
#include "image/bmp.h"
Include dependency graph for bmp.c:

Go to the source code of this file.

Data Structures

struct  nsbmp_content
 bmp context. More...
 

Typedefs

typedef struct nsbmp_content nsbmp_content
 bmp context. More...
 

Functions

static void * nsbmp_bitmap_create (int width, int height, unsigned int bmp_state)
 Callback for libnsbmp; forwards the call to bitmap_create() More...
 
static nserror nsbmp_create_bmp_data (nsbmp_content *bmp)
 
static nserror nsbmp_create (const struct content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c)
 
static bool nsbmp_convert (struct content *c)
 
static bool nsbmp_redraw (struct content *c, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx)
 
static void nsbmp_destroy (struct content *c)
 
static nserror nsbmp_clone (const struct content *old, struct content **newc)
 
static void * nsbmp_get_internal (const struct content *c, void *context)
 
static content_type nsbmp_content_type (void)
 
static bool nsbmp_content_is_opaque (struct content *c)
 
 CONTENT_FACTORY_REGISTER_TYPES (nsbmp, nsbmp_types, nsbmp_content_handler)
 

Variables

static const content_handler nsbmp_content_handler
 
static const char * nsbmp_types []
 

Detailed Description

implementation of content handler for BMP images.

Definition in file bmp.c.

Typedef Documentation

◆ nsbmp_content

typedef struct nsbmp_content nsbmp_content

bmp context.

Function Documentation

◆ CONTENT_FACTORY_REGISTER_TYPES()

CONTENT_FACTORY_REGISTER_TYPES ( nsbmp  ,
nsbmp_types  ,
nsbmp_content_handler   
)

◆ nsbmp_bitmap_create()

static void * nsbmp_bitmap_create ( int  width,
int  height,
unsigned int  bmp_state 
)
static

Callback for libnsbmp; forwards the call to bitmap_create()

Parameters
widthwidth of image in pixels
heightwidth of image in pixels
bmp_stateA flag word indicating the initial state
Returns
An opaque struct bitmap, or NULL on memory exhaustion

Definition at line 59 of file bmp.c.

References netsurf_table::bitmap, BITMAP_CLEAR, BITMAP_NONE, BITMAP_OPAQUE, gui_bitmap_table::create, guit, height, and width.

Referenced by nsbmp_create_bmp_data().

Here is the caller graph for this function:

◆ nsbmp_clone()

static nserror nsbmp_clone ( const struct content old,
struct content **  newc 
)
static

Definition at line 222 of file bmp.c.

References nsbmp_content::base, content__clone(), content_destroy(), CONTENT_STATUS_DONE, CONTENT_STATUS_READY, nsbmp_convert(), nsbmp_create_bmp_data(), NSERROR_CLONE_FAILED, NSERROR_NOMEM, NSERROR_OK, and content::status.

Here is the call graph for this function:

◆ nsbmp_content_is_opaque()

static bool nsbmp_content_is_opaque ( struct content c)
static

◆ nsbmp_content_type()

static content_type nsbmp_content_type ( void  )
static

Definition at line 264 of file bmp.c.

References CONTENT_IMAGE.

◆ nsbmp_convert()

static bool nsbmp_convert ( struct content c)
static

Definition at line 125 of file bmp.c.

References nsbmp_content::bitmap, nsbmp_content::bmp, content__get_source_data(), content__set_title(), content_broadcast_error(), content_set_done(), content_set_ready(), content_set_status(), content::height, content::llcache, llcache_handle_get_url(), messages_get_buff(), NSERROR_BMP_ERROR, NSERROR_NOMEM, nsurl_access_leaf(), content::size, content::title, and content::width.

Referenced by nsbmp_clone().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsbmp_create()

static nserror nsbmp_create ( const struct content_handler handler,
lwc_string *  imime_type,
const struct http_parameter params,
llcache_handle llcache,
const char *  fallback_charset,
bool  quirks,
struct content **  c 
)
static

Definition at line 92 of file bmp.c.

References nsbmp_content::base, content__init(), llcache, nsbmp_create_bmp_data(), NSERROR_NOMEM, and NSERROR_OK.

Here is the call graph for this function:

◆ nsbmp_create_bmp_data()

static nserror nsbmp_create_bmp_data ( nsbmp_content bmp)
static

Definition at line 72 of file bmp.c.

References nsbmp_content::base, netsurf_table::bitmap, nsbmp_content::bmp, content_broadcast_error(), gui_bitmap_table::destroy, gui_bitmap_table::get_buffer, guit, nsbmp_bitmap_create(), NSERROR_NOMEM, and NSERROR_OK.

Referenced by nsbmp_clone(), and nsbmp_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsbmp_destroy()

static void nsbmp_destroy ( struct content c)
static

Definition at line 213 of file bmp.c.

References nsbmp_content::bmp.

◆ nsbmp_get_internal()

static void * nsbmp_get_internal ( const struct content c,
void *  context 
)
static

Definition at line 257 of file bmp.c.

References nsbmp_content::bitmap.

◆ nsbmp_redraw()

static bool nsbmp_redraw ( struct content c,
struct content_redraw_data data,
const struct rect clip,
const struct redraw_context ctx 
)
static

Variable Documentation

◆ nsbmp_content_handler

const content_handler nsbmp_content_handler
static
Initial value:
= {
.create = nsbmp_create,
.data_complete = nsbmp_convert,
.destroy = nsbmp_destroy,
.redraw = nsbmp_redraw,
.clone = nsbmp_clone,
.get_internal = nsbmp_get_internal,
.no_share = false,
}
static void * nsbmp_get_internal(const struct content *c, void *context)
Definition: bmp.c:257
static bool nsbmp_convert(struct content *c)
Definition: bmp.c:125
static bool nsbmp_content_is_opaque(struct content *c)
Definition: bmp.c:269
static void nsbmp_destroy(struct content *c)
Definition: bmp.c:213
static bool nsbmp_redraw(struct content *c, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx)
Definition: bmp.c:177
static nserror nsbmp_create(const struct content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c)
Definition: bmp.c:92
static content_type nsbmp_content_type(void)
Definition: bmp.c:264
static nserror nsbmp_clone(const struct content *old, struct content **newc)
Definition: bmp.c:222

Definition at line 280 of file bmp.c.

◆ nsbmp_types

const char* nsbmp_types[]
static
Initial value:
= {
"application/bmp",
"application/preview",
"application/x-bmp",
"application/x-win-bitmap",
"image/bmp",
"image/ms-bmp",
"image/x-bitmap",
"image/x-bmp",
"image/x-ms-bmp",
"image/x-win-bitmap",
"image/x-windows-bmp",
"image/x-xbitmap"
}

Definition at line 292 of file bmp.c.