libxputty 0.1
Loading...
Searching...
No Matches
xpngloader.h
Go to the documentation of this file.
1/*
2 * 0BSD
3 *
4 * BSD Zero Clause License
5 *
6 * Copyright (c) 2019 Hermann Meyer
7 *
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted.
10
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
18 *
19 */
20
21#pragma once
22
23#ifndef XPNGLOADER_H_
24#define XPNGLOADER_H_
25
26#include "xputty.h"
27#include "config.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33
40#ifdef USE_LD
41
42#ifdef __APPLE__
43
44#ifdef __cplusplus
45}
46#endif
47
48#include <mach-o/getsect.h>
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54#define EXTLD(NAME) \
55 extern const unsigned char _section$__DATA__ ## NAME [];
56#define LDVAR(NAME) _section$__DATA__ ## NAME
57#define LDLEN(NAME) (getsectbyname("__DATA", "__" #NAME)->size)
58
59#elif (defined __WIN32__) /* mingw */
60
61
62#define EXTLD(NAME) \
63 extern const unsigned char _binary_ ## NAME ## _start[]; \
64 extern const unsigned char _binary_ ## NAME ## _end[];
65#define LDVAR(NAME) \
66 _binary_ ## NAME ## _start
67#define LDLEN(NAME) \
68 ((_binary_ ## NAME ## _end) - (_binary_ ## NAME ## _start))
69
70#else /* gnu/linux ld */
71
72#define EXTLD(NAME) \
73 extern const unsigned char _binary_ ## NAME ## _start[]; \
74 extern const unsigned char _binary_ ## NAME ## _end[];
75#define LDVAR(NAME) \
76 _binary_ ## NAME ## _start
77#define LDLEN(NAME) \
78 ((_binary_ ## NAME ## _end) - (_binary_ ## NAME ## _start))
79#endif
80
81#else /* xxd -i NAME */
82
83#define EXTLD(NAME) \
84 extern const unsigned char NAME;
85#define LDVAR(NAME) \
86 (const unsigned char*)&NAME
87
88#endif
89
90
91/*---------------------------------------------------------------------
92-----------------------------------------------------------------------
93 define needed structs
94-----------------------------------------------------------------------
95----------------------------------------------------------------------*/
96
104typedef struct {
105 const unsigned char * data;
106 long int position;
108
109#include "xresources.h"
110
118cairo_surface_t *cairo_image_surface_create_from_stream ( const unsigned char* name);
119
126void widget_get_png(Widget_t *w, const unsigned char* name);
127
135void widget_get_scaled_png(Widget_t *w, const unsigned char* name);
136
143void widget_get_png_from_file(Widget_t *w, const char* filename);
144
151void widget_get_scaled_png_from_file(Widget_t *w, const char* filename);
152
160
169cairo_surface_t * surface_get_png(Widget_t *w, cairo_surface_t *sf, const unsigned char* name);
170
178void widget_set_icon_from_surface(Widget_t *w, cairo_surface_t *image);
179
187void widget_set_icon_from_png(Widget_t *w, const unsigned char* name);
188
189#ifdef __cplusplus
190}
191#endif
192
193#endif //XPNGLOADER_H_
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457
binary_stream - struct definition to read binary data into cairo surface
Definition xpngloader.h:104
long int position
Definition xpngloader.h:106
const unsigned char * data
Definition xpngloader.h:105
void widget_get_png_from_file(Widget_t *w, const char *filename)
widget_get_png_from_file - read png from file into Widget_t xlib surface
Definition xpngloader.c:87
void widget_get_scaled_png_from_file(Widget_t *w, const char *filename)
widget_get_scaled_png_from_file - read scaled png into Widget_t xlib surface
Definition xpngloader.c:93
void widget_get_scaled_png(Widget_t *w, const unsigned char *name)
widget_get_scaled_png - read scaled png into Widget_t xlib surface
Definition xpngloader.c:81
void widget_get_png(Widget_t *w, const unsigned char *name)
widget_get_png - read png into Widget_t xlib surface
Definition xpngloader.c:75
cairo_surface_t * surface_get_png(Widget_t *w, cairo_surface_t *sf, const unsigned char *name)
surface_get_png - read png into Widget_t xlib surface
Definition xpngloader.c:104
void widget_set_icon_from_png(Widget_t *w, const unsigned char *name)
widget_set_icon_from_png - set icon image from png binary to Widget_t those icon will be used in the ...
Definition xpngloader.c:159
void widget_set_icon_from_surface(Widget_t *w, cairo_surface_t *image)
widget_set_icon_from_surface - set icon image from cairo surface for Widget_t those icon will be used...
Definition xpngloader.c:119
cairo_surface_t * cairo_image_surface_create_from_stream(const unsigned char *name)
cairo_image_surface_create_from_stream - read binary data into cairo surface from stream
Definition xpngloader.c:35
void widget_get_surface_ptr(Widget_t *w, Widget_t *wid)
widget_get_surface_ptr - set pointer to a 2. Widget_t xlib surface
Definition xpngloader.c:99
This file contains definitions and structs used on all platforms. Platform specific definitions are l...