File: image.h

package info (click to toggle)
gambas3 3.20.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 76,984 kB
  • sloc: ansic: 197,178; cpp: 124,076; sh: 18,999; javascript: 7,761; sql: 5,399; makefile: 2,354; perl: 1,397; xml: 490; python: 335
file content (89 lines) | stat: -rw-r--r-- 3,795 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/***************************************************************************

  image.h

  (c) 2000-2017 BenoƮt Minisini <benoit.minisini@gambas-basic.org>

  This program 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; either version 2, or (at your option)
  any later version.

  This program 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, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  MA 02110-1301, USA.

***************************************************************************/

#ifndef __IMAGE_H
#define __IMAGE_H

#include "main.h"

#ifndef __IMAGE_C
extern bool IMAGE_debug;
#endif

static inline int RED(uint rgba) { return ((rgba >> 16) & 0xff); }
static inline int GREEN(uint rgba) { return ((rgba >> 8) & 0xff); }
static inline int BLUE(uint rgba) { return (rgba & 0xff); }
static inline int ALPHA(uint rgba) { return ((rgba >> 24) & 0xff); }

static inline uint RGB(int r, int g, int b) { return (0xff << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); }
static inline uint RGBA(int r, int g, int b, int a) { return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); }
static inline int GRAY(uint rgba) { return (RED(rgba) * 11 + GREEN(rgba) * 16 + BLUE(rgba) * 5) / 32; }

int IMAGE_size(GB_IMG *img);

void IMAGE_create(GB_IMG *img, int width, int height, int format, GB_COLOR fill);
void IMAGE_create_with_data(GB_IMG *img, int width, int height, int format, unsigned char *data);

void IMAGE_take(GB_IMG *img, GB_IMG_OWNER *owner, void *owner_handle, int width, int height, unsigned char *data);
void *IMAGE_check(GB_IMG *img, GB_IMG_OWNER *temp_owner);
void IMAGE_synchronize(GB_IMG *img);

void IMAGE_delete(GB_IMG *img);

void IMAGE_convert(GB_IMG *img, int format);

void IMAGE_fill(GB_IMG *img, GB_COLOR col);
void IMAGE_fill_rect(GB_IMG *img, int x, int y, int w, int h, GB_COLOR col, bool opaque);

void IMAGE_make_gray(GB_IMG *img);
void IMAGE_make_transparent(GB_IMG *img, GB_COLOR color);

GB_COLOR IMAGE_get_pixel(GB_IMG *img, int x, int y);
void IMAGE_set_pixel(GB_IMG *img, int x, int y, GB_COLOR col);

void IMAGE_get_pixels(GB_IMG *img, int *data);
void IMAGE_set_pixels(GB_IMG *img, int *data);

void IMAGE_replace(GB_IMG *img, GB_COLOR src, GB_COLOR dst, bool noteq);

void IMAGE_set_default_format(int format);
int IMAGE_get_default_format();
const char *IMAGE_format_to_string(int fmt);
int IMAGE_format_from_string(char *fmt);

void IMAGE_bitblt(GB_IMG *dst, int dx, int dy, int dw, int dh, GB_IMG *src, int sx, int sy, int sw, int sh);
void IMAGE_draw_alpha(GB_IMG *dst, int dx, int dy, GB_IMG *src, int sx, int sy, int sw, int sh);
void IMAGE_compose(GB_IMG *dst, int dx, int dy, int dw, int dh, GB_IMG *src, int sx, int sy, int sw, int sh);
void IMAGE_colorize(GB_IMG *img, GB_COLOR color);
void IMAGE_mask(GB_IMG *img, GB_COLOR color);
void IMAGE_mirror(GB_IMG *src, GB_IMG *dst, bool horizontal, bool vertical);
void IMAGE_rotate(GB_IMG *src, GB_IMG *dst, bool left);
void IMAGE_transform(GB_IMG *dst, GB_IMG *src, double sx, double sy, double sdx, double sdy);
void IMAGE_set_opacity(GB_IMG *dst, uchar opacity);
void IMAGE_blur(GB_IMG *img, int radius);
void IMAGE_balance(GB_IMG *img, int brightness, int contrast, int gamma, int hue, int saturation, int lightness);
void IMAGE_invert(GB_IMG *img, bool keep_hue);

#define IMAGE_is_void(_image) ((_image)->is_void)

#endif