NetSurf
bitmap.h
Go to the documentation of this file.
1/*
2 * Copyright 2008,2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef AMIGA_BITMAP_H
20#define AMIGA_BITMAP_H
21
22#include <stdbool.h>
23#include <exec/types.h>
24#include <proto/graphics.h>
25#include <intuition/classusr.h>
26#include <libraries/Picasso96.h>
27
28#include "netsurf/bitmap.h"
29
30#define AMI_BITMAP_FORMAT RGBFB_A8R8G8B8
31#define AMI_BITMAP_SCALE_ICON 0xFF
32
34struct bitmap;
35struct nsurl;
36struct gui_globals;
37
38struct BitMap *ami_bitmap_get_native(struct bitmap *bitmap,
39 int width, int height, bool palette_mapped, struct BitMap *friendbm);
40PLANEPTR ami_bitmap_get_mask(struct bitmap *bitmap, int width,
41 int height, struct BitMap *n_bm);
42
44struct bitmap *ami_bitmap_from_datatype(char *filename);
45
46/**
47 * Set bitmap URL
48 *
49 * \param bm a bitmap, as returned by bitmap_create()
50 * \param url the url for the bitmap
51 *
52 * A reference will be kept by the bitmap object.
53 * The URL can only ever be set once for a bitmap.
54 */
55void ami_bitmap_set_url(struct bitmap *bm, struct nsurl *url);
56
57/**
58 * Set bitmap title
59 *
60 * \param bm a bitmap, as returned by bitmap_create()
61 * \param title a pointer to a title string
62 *
63 * This is copied by the bitmap object.
64 * The title can only ever be set once for a bitmap.
65 */
66void ami_bitmap_set_title(struct bitmap *bm, const char *title);
67
68/**
69 * Set an icondata pointer
70 *
71 * \param bm a bitmap, as returned by bitmap_create()
72 * \param icondata a pointer to memory
73 *
74 * This function probably shouldn't be here!
75 */
76void ami_bitmap_set_icondata(struct bitmap *bm, ULONG *icondata);
77
78/**
79 * Free an icondata pointer
80 *
81 * \param bm a bitmap, as returned by bitmap_create()
82 *
83 * This function probably shouldn't be here!
84 */
85void ami_bitmap_free_icondata(struct bitmap *bm);
86
87/**
88 * Test if a BitMap is owned by a bitmap.
89 *
90 * \param bm a bitmap, as returned by bitmap_create()
91 * \param nbm a BitMap, as created by AllocBitMap()
92 * \return true if the BitMap is owned by the bitmap
93 */
94bool ami_bitmap_is_nativebm(struct bitmap *bm, struct BitMap *nbm);
95
96/**
97 * Cleanup bitmap allocations
98 */
99void ami_bitmap_fini(void);
100
101/**
102 * Create a bitmap.
103 *
104 * \param width width of image in pixels
105 * \param height width of image in pixels
106 * \param flags flags for bitmap creation
107 * \return an opaque struct bitmap, or NULL on memory exhaustion
108 */
109void *amiga_bitmap_create(int width, int height, enum gui_bitmap_flags flags);
110
111/**
112 * Return a pointer to the pixel data in a bitmap.
113 *
114 * \param bitmap a bitmap, as returned by bitmap_create()
115 * \return pointer to the pixel buffer
116 *
117 * The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end
118 * of rows. The width of a row in bytes is given by bitmap_get_rowstride().
119 */
120unsigned char *amiga_bitmap_get_buffer(void *bitmap);
121
122/**
123 * Find the width of a pixel row in bytes.
124 *
125 * \param bitmap a bitmap, as returned by bitmap_create()
126 * \return width of a pixel row in the bitmap
127 */
129
130/**
131 * Return the width of a bitmap.
132 *
133 * \param bitmap a bitmap, as returned by bitmap_create()
134 * \return width in pixels
135 */
136int bitmap_get_width(void *bitmap);
137
138/**
139 * Return the height of a bitmap.
140 *
141 * \param bitmap a bitmap, as returned by bitmap_create()
142 * \return height in pixels
143 */
144int bitmap_get_height(void *bitmap);
145
146/**
147 * Free a bitmap.
148 *
149 * \param bitmap a bitmap, as returned by bitmap_create()
150 */
151void amiga_bitmap_destroy(void *bitmap);
152
153/**
154 * Save a bitmap in the platform's native format.
155 *
156 * \param bitmap a bitmap, as returned by bitmap_create()
157 * \param path pathname for file
158 * \param flags flags controlling how the bitmap is saved.
159 * \return true on success, false on error and error reported
160 */
161bool amiga_bitmap_save(void *bitmap, const char *path, unsigned flags);
162
163/**
164 * The bitmap image has changed, so flush any persistant cache.
165 *
166 * \param bitmap a bitmap, as returned by bitmap_create()
167 */
168void amiga_bitmap_modified(void *bitmap);
169
170/**
171 * Sets whether a bitmap should be plotted opaque
172 *
173 * \param bitmap a bitmap, as returned by bitmap_create()
174 * \param opaque whether the bitmap should be plotted opaque
175 */
176void amiga_bitmap_set_opaque(void *bitmap, bool opaque);
177
178/**
179 * Gets whether a bitmap should be plotted opaque
180 *
181 * \param bitmap a bitmap, as returned by bitmap_create()
182 */
184
185
186#endif
static bool palette_mapped
Definition: plotters.c:98
size_t amiga_bitmap_get_rowstride(void *bitmap)
Find the width of a pixel row in bytes.
Definition: bitmap.c:197
void * amiga_bitmap_create(int width, int height, enum gui_bitmap_flags flags)
Create a bitmap.
Definition: bitmap.c:111
void ami_bitmap_set_url(struct bitmap *bm, struct nsurl *url)
Set bitmap URL.
Definition: bitmap.c:734
struct BitMap * ami_bitmap_get_native(struct bitmap *bitmap, int width, int height, bool palette_mapped, struct BitMap *friendbm)
Definition: bitmap.c:666
int bitmap_get_width(void *bitmap)
Return the width of a bitmap.
Definition: bitmap.c:319
void ami_bitmap_free_icondata(struct bitmap *bm)
Free an icondata pointer.
Definition: bitmap.c:751
void ami_bitmap_fini(void)
Cleanup bitmap allocations.
Definition: bitmap.c:678
int bitmap_get_height(void *bitmap)
Return the height of a bitmap.
Definition: bitmap.c:336
bool amiga_bitmap_save(void *bitmap, const char *path, unsigned flags)
Save a bitmap in the platform's native format.
Definition: bitmap.c:255
PLANEPTR ami_bitmap_get_mask(struct bitmap *bitmap, int width, int height, struct BitMap *n_bm)
Definition: bitmap.c:626
bool ami_bitmap_is_nativebm(struct bitmap *bm, struct BitMap *nbm)
Test if a BitMap is owned by a bitmap.
Definition: bitmap.c:757
struct bitmap * ami_bitmap_from_datatype(char *filename)
Definition: bitmap.c:407
struct gui_bitmap_table * amiga_bitmap_table
Definition: bitmap.c:777
void ami_bitmap_set_title(struct bitmap *bm, const char *title)
Set bitmap title.
Definition: bitmap.c:740
void amiga_bitmap_modified(void *bitmap)
The bitmap image has changed, so flush any persistant cache.
Definition: bitmap.c:280
void amiga_bitmap_set_opaque(void *bitmap, bool opaque)
Sets whether a bitmap should be plotted opaque.
Definition: bitmap.c:300
Object * ami_datatype_object_from_bitmap(struct bitmap *bitmap)
Definition: bitmap.c:369
void ami_bitmap_set_icondata(struct bitmap *bm, ULONG *icondata)
Set an icondata pointer.
Definition: bitmap.c:746
bool amiga_bitmap_get_opaque(void *bitmap)
Gets whether a bitmap should be plotted opaque.
Definition: bitmap.c:309
unsigned char * amiga_bitmap_get_buffer(void *bitmap)
Return a pointer to the pixel data in a bitmap.
Definition: bitmap.c:174
void amiga_bitmap_destroy(void *bitmap)
Free a bitmap.
Definition: bitmap.c:213
Generic bitmap handling interface.
gui_bitmap_flags
Bitmap creation flags.
Definition: bitmap.h:36
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
int width
Definition: gui.c:159
int height
Definition: gui.c:160
RISC OS wimp toolkit bitmap.
Definition: bitmap.c:68
char * title
Definition: bitmap.c:83
ULONG * icondata
Definition: bitmap.c:84
bool opaque
Whether the bitmap is opaque.
Definition: bitmap.c:74
struct nsurl * url
Definition: bitmap.c:82
Bitmap operations.
Definition: bitmap.h:125
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
Definition: plot.c:821