summaryrefslogtreecommitdiff
path: root/legacy/evas/src/lib/imaging/evas_imaging.c
blob: 25a4ad50f269a9ce269c9f8b735afed3f3fb37e0 (plain)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#include "evas_common.h"
#include "evas_private.h"

#ifdef BUILD_FONT_LOADER_EET
#include <Eet.h>
#endif

Evas_Imaging_Image *
evas_imaging_image_load(const char *file, const char *key)
{
   Evas_Imaging_Image *im;
   RGBA_Image *image;

   if (!file) file = "";
   if (!key) key = "";
   evas_common_cpu_init();
   evas_common_image_init();
   image = evas_common_load_image_from_file(file, key);
   if (!image) return NULL;
   im = calloc(1, sizeof(Evas_Imaging_Image));
   if (!im)
     {
	evas_common_image_free(image);
	return NULL;
     }
   im->image = image;
   return im;
}

void
evas_imaging_image_free(Evas_Imaging_Image *im)
{
   if (!im) return;
   evas_common_image_unref(im->image);
   free(im);
}

void
evas_imaging_image_size_get(Evas_Imaging_Image *im, int *w, int *h)
{
   if (!im) return;
   if (w) *w = im->image->image->w;
   if (h) *h = im->image->image->h;
}

Evas_Bool
evas_imaging_image_alpha_get(Evas_Imaging_Image *im)
{
   if (!im) return 0;
   if (im->image->flags & RGBA_IMAGE_HAS_ALPHA) return 1;
   return 0;
}

void
evas_imaging_image_cache_set(int bytes)
{
   evas_common_image_set_cache(bytes);
}

int
evas_imaging_image_cache_get(void)
{
   return evas_common_image_get_cache();
}

Evas_Imaging_Font *
evas_imaging_font_load(const char *file, const char *key, int size)
{
   Evas_Imaging_Font *fn;
   RGBA_Font *font;

   evas_common_cpu_init();
   evas_common_font_init();
   if (!file) file = "";
   if ((key) && (key[0] == 0)) key = NULL;
#ifdef BUILD_FONT_LOADER_EET
   if (key)
     {
	char *tmp;

	tmp = evas_file_path_join(file, key);
	if (tmp)
	  {
	     font = evas_common_font_load(tmp, size);
	     if (!font)
	       {
		  Eet_File *ef;

		  ef = eet_open((char *)file, EET_FILE_MODE_READ);
		  if (ef)
		    {
		       void *fdata;
		       int fsize = 0;

		       fdata = eet_read(ef, (char *)key, &fsize);
		       if ((fdata) && (fsize > 0))
			 {
			    font = evas_common_font_memory_load(tmp, size, fdata, fsize);
			    free(fdata);
			 }
		       eet_close(ef);
		    }
	       }
	     free(tmp);
	  }
     }
   else
#endif
     {
	font = evas_common_font_load((char *)file, size);
     }
   fn = calloc(1, sizeof(RGBA_Font));
   if (!fn) return NULL;
   fn->font = font;
   return fn;
}

void
evas_imaging_font_free(Evas_Imaging_Font *fn)
{
   evas_common_font_free(fn->font);
   free(fn);
}

int
evas_imaging_font_ascent_get(Evas_Imaging_Font *fn)
{
   return evas_common_font_ascent_get(fn->font);
}

int
evas_imaging_font_descent_get(Evas_Imaging_Font *fn)
{
   return evas_common_font_descent_get(fn->font);
}

int
evas_imaging_font_max_ascent_get(Evas_Imaging_Font *fn)
{
   return evas_common_font_max_ascent_get(fn->font);
}

int
evas_imaging_font_max_descent_get(Evas_Imaging_Font *fn)
{
   return evas_common_font_max_descent_get(fn->font);
}

int
evas_imaging_font_line_advance_get(Evas_Imaging_Font *fn)
{
   return evas_common_font_get_line_advance(fn->font);
}

void
evas_imaging_font_string_advance_get(Evas_Imaging_Font *fn, char *str, int *x, int *y)
{
   evas_common_font_query_advance(fn->font, str, x, y);
}

void
evas_imaging_font_string_size_query(Evas_Imaging_Font *fn, char *str, int *w, int *h)
{
   evas_common_font_query_size(fn->font, str, w, h);
}

int
evas_imaging_font_string_inset_get(Evas_Imaging_Font *fn, char *str)
{
   return evas_common_font_query_inset(fn->font, str);
}

int
evas_imaging_font_string_char_coords_get(Evas_Imaging_Font *fn, char *str, int pos, int *cx, int *cy, int *cw, int *ch)
{
   return evas_common_font_query_char_coords(fn->font, str, pos, cx, cy, cw, ch);
}

int
evas_imaging_font_string_char_at_coords_get(Evas_Imaging_Font *fn, char *str, int x, int y, int *cx, int *cy, int *cw, int *ch)
{
   return evas_common_font_query_text_at_pos(fn->font, str, x, y, cx, cy, cw, ch);
}

void
evas_imaging_font_cache_set(int bytes)
{
   evas_common_font_cache_set(bytes);
}

int
evas_imaging_font_cache_get(void)
{
   return evas_common_font_cache_get();
}