-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgui_map.c
661 lines (589 loc) · 22.7 KB
/
gui_map.c
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
/**
*****************************************************************************************
* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
*****************************************************************************************
* @file gui_curtain.c
* @brief create a curtain effect widget,which should be nested in a curtainview.
* @details Slide to extend and retract curtains
* @author [email protected]
* @date 2023/10/24
* @version 1.0
***************************************************************************************
* @attention
* <h2><center>© COPYRIGHT 2017 Realtek Semiconductor Corporation</center></h2>
***************************************************************************************
*/
/*============================================================================*
* Header Files
*============================================================================*/
#include <math.h>
#include <stdio.h>
#include "gui_map.h"
#include "gui_text.h"
#include "gui_img_stb.h"
#include "tp_algo.h"
#include "gui_button.h"
#include "gui_canvas_rect.h"
#include "gui_app.h"
#include "gui_api.h"
/*============================================================================*
* Types
*============================================================================*/
/*============================================================================*
* Constants
*============================================================================*/
/*============================================================================*
* Macros
*============================================================================*/
#define SCREEN_W ((int)gui_get_screen_width())
#define SCREEN_H ((int)gui_get_screen_height())
#define TILE_SIZE (256)
#define EARTH_LONGITUDE_RANGE 360.0
#define GPS_LONGITUDE 120.58
#define GPS_LATITUDE 31.3
#define TILE_ZOOM_LEVEL (7)
#define WIN_W (SCREEN_W*3/2)
#define WIN_H (SCREEN_H*3/2)
#define MAP_WIDGET_NAME "_MAP"
#if _WIN32
#define ROOT_PATH "./realgui/example/screen_454_454/root_image/SDCARD/"
#else
#define ROOT_PATH "/"
#endif
#define PATH404 "map/icon/404.jpg"
typedef long off_t;
/*============================================================================*
* Variables
*============================================================================*/
static int tile_size = TILE_SIZE;
/*============================================================================*
* Private Functions
*============================================================================*/
static void free_for_rgb(void *p);
// Convert longitude to tileX index at a certain zoom level
static int long2tilex(double lon, int z)
{
return (int)(floor((lon + EARTH_LONGITUDE_RANGE / 2) / EARTH_LONGITUDE_RANGE * pow(2.0, z)));
}
// Convert latitude to tileY index at a certain zoom level
static int lat2tiley(double lat, int z)
{
// The formula includes taking tan of latitude then log's the value . After that it's scaled to 2's pow of zoom level
return (int)(floor((1.0 - log(tan(lat * M_PI / 180.0) + 1.0 / cos(lat * M_PI / 180.0)) / M_PI) / 2.0
* pow(2.0, z)));
}
// function to generate tile URL path given the tile indices and zoom level
static void generateTileURL(int tileX, int tileY, int zoom)
{
//gui_log("http://mt0.google.com/vt/lyrs=m@221097413,traffic&x=%d&y=%d&z=%d\n", tileX, tileY, zoom);
}
static void generateTilesForWindow(int windowWidth, int windowHeight, double center_lat,
double center_lon,
int zoom, gui_map_t *parent)
{
// Calculate how many tiles are needed for each direction
int tileCountX = ceil((double)windowWidth / TILE_SIZE);
int tileCountY = ceil((double)windowHeight / TILE_SIZE);
// Calculate the position of the center tile
int centerX = long2tilex(center_lon, zoom);
int centerY = lat2tiley(center_lat, zoom);
//gui_log("centerX:%d,centerY:%d\n", centerX, centerY);
// Calculate the range of x,y of the needed tiles
int startX = centerX - tileCountX / 2;
int startY = centerY - tileCountY / 2;
int endX = startX + tileCountX;
int endY = startY + tileCountY;
// Generate the URLs and relative coordinates for all tiles in the range
for (int x = startX; x < endX; x++)
{
for (int y = startY; y < endY; y++)
{
generateTileURL(x, y, zoom);
//gui_log("Relative coordinates: (%d, %d)\n", (x - startX)*tile_size, (y - startY)*tile_size);
#if 1
typedef long off_t;
char path[100];
memset(path, 0, 100);
sprintf(path, "%s/map/%d/%d/%d/tile.jpg", ROOT_PATH, zoom,
x, y);
int fd;
fd = gui_fs_open((const char *)path, 0);
char *jpg = 0;
off_t filesize = 0;
if (fd > 0)
{
filesize = gui_fs_lseek(fd, 0, SEEK_END);
jpg = gui_malloc(filesize);
//gui_log("open %s Successful!\n", path);
gui_fs_lseek(fd, 0, SEEK_SET);
gui_fs_read(fd, jpg, filesize);
gui_fs_close(fd);
}
else
{
//gui_log("open %s Fail!\n", path);
memset(path, 0, 100);
sprintf(path, "%s/%s", ROOT_PATH, PATH404);
fd = gui_fs_open((const char *)path, 0);
if (fd <= 0)
{
return;
}
filesize = gui_fs_lseek(fd, 0, SEEK_END);
jpg = gui_malloc(filesize);
gui_fs_lseek(fd, 0, SEEK_SET);
gui_fs_read(fd, jpg, filesize);
gui_fs_close(fd);
}
if (parent->tile[y - startY][x - startX].img->data_buffer)
{
gui_free(parent->tile[y - startY][x - startX].img->data_buffer);
}
parent->tile[y - startY][x - startX].x = x;
parent->tile[y - startY][x - startX].y = y;
gui_img_stb_set_attribute(parent->tile[y - startY][x - startX].img, jpg, filesize, JPEG,
(x - startX)*tile_size, (y - startY)*tile_size);
#else
gui_canvas_rect_create((gui_obj_t *)parent, "canvas_rect", (x - startX)*tile_size,
(y - startY)*tile_size, TILE_SIZE - 1,
TILE_SIZE - 1,
APP_COLOR_SILVER);
#endif
}
}
}
static void destroy(gui_obj_t *obj)
{
gui_win_t *this = (void *)obj;
if (this->animate)
{
gui_free(this->animate);
this->animate = NULL;
}
gui_map_t *parent = GUI_TYPE(gui_map_t, obj);
for (size_t i = 0; i < 3; i++)
{
for (size_t j = 0; j < 3; j++)
{
gui_free(parent->tile[i][j].img->data_buffer);
}
gui_free(parent->button_data[i]);
}
}
extern void gui_win_prepare_globle(gui_obj_t *obj);
static void gui_win_cb(gui_obj_t *obj, T_OBJ_CB_TYPE cb_type)
{
if (obj != NULL)
{
switch (cb_type)
{
case OBJ_PREPARE:
gui_win_prepare_globle(obj);
break;
case OBJ_DESTROY:
destroy(obj);
break;
default:
break;
}
}
}
static void ctor(gui_map_t *this, gui_obj_t *parent)
{
extern void gui_win_ctor(gui_win_t *this, gui_obj_t *parent, const char *filename, int16_t x,
int16_t y, int16_t w, int16_t h);
gui_win_ctor((void *)this, parent, MAP_WIDGET_NAME, -(WIN_W - SCREEN_W) / 2,
-(WIN_H - SCREEN_H) / 2, WIN_W,
WIN_H);
this->start_x = GET_BASE(this)->x;
this->start_y = GET_BASE(this)->y;
GET_BASE(this)->obj_cb = gui_win_cb;
}
static void load_new_tile(map_tile_t *tile, int16_t zoom)
{
#if 1
typedef long off_t;
static char path[100];
memset(path, 0, 100);
sprintf(path, "%s/map/%d/%d/%d/tile.jpg", ROOT_PATH,
zoom, tile->x, tile->y);
int fd;
fd = gui_fs_open((const char *)path, 0);
char *jpg = 0;
off_t filesize = 0;
if (fd > 0)
{
filesize = gui_fs_lseek(fd, 0, SEEK_END);
jpg = gui_malloc(filesize);
gui_fs_lseek(fd, 0, SEEK_SET);
gui_fs_read(fd, jpg, filesize);
gui_fs_close(fd);
}
else
{
gui_log("open %s Fail!\n", path);
memset(path, 0, 100);
sprintf(path, "%s/%s", ROOT_PATH, PATH404);
fd = gui_fs_open((const char *)path, 0);
if (fd <= 0)
{
return;
}
filesize = gui_fs_lseek(fd, 0, SEEK_END);
jpg = gui_malloc(filesize);
gui_fs_lseek(fd, 0, SEEK_SET);
gui_fs_read(fd, jpg, filesize);
gui_fs_close(fd);
}
gui_img_stb_set_attribute_static(tile->img, jpg, filesize, JPEG, tile->img->base.x,
tile->img->base.y);
#else
#endif
}
void pixel_to_latlon(double px_dx, double px_dy, double lat_prev, double lon_prev, int zoom,
double *lat, double *lon)
{
double tiles_at_this_zoom = pow(2.0, (double)zoom);
double lon_deg_per_px = 360.0 / (tiles_at_this_zoom * TILE_SIZE);
double lat_deg_per_px = 2 * atan(exp(M_PI)) / (tiles_at_this_zoom * TILE_SIZE) * 180.0 / M_PI;
*lon = lon_prev + px_dx * lon_deg_per_px;
*lat = lat_prev - px_dy * lat_deg_per_px;
}
/**
* @brief Check if the screen is being pressed and released, and record these states
* If the screen is being pressed and moved, this code will move the map according to the slide of the finger and handle page turning issues (when the user slides beyond the currently displayed map area). When the map moves to the edge, it will load new tiles
* When the slide is released, record the final position of the map
* An important thing to note here is that the logic of moving the map includes how to handle it when the map slides to the edge. That is, when there are no more map tiles to display, the code will load new tiles for display. If no more map tiles can be loaded, the code will attempt to open a default image ("./realgui/example/screen_454_454/root_image/SDCARD/map/Tiles not found.jpg").
*/
static void wincb(gui_map_t *this)
{
if (this->base.animate->progress_percent == 1)
{
//gui_log("wincb\n");
}
touch_info_t *tp = tp_get_info();
if (tp->pressed)
{
this->press = 1;
this->release = 0;
}
if (tp->released)
{
this->press = 0;
this->release = 1;
double latitude;
double longitude;
pixel_to_latlon(-tp->deltaX, -tp->deltaY, this->latitude, this->longitude, this->zoom, &latitude,
&longitude);
this->latitude = latitude;
this->longitude = longitude;
}
static bool deltaX_right_flag, deltaX_left_flag;
if (this->press)
{
GUI_BASE(this)->x = this->start_x + tp->deltaX;
GUI_BASE(this)->y = this->start_y + tp->deltaY;
static int deltaX_old;
if (deltaX_old < tp->deltaX)
{
deltaX_right_flag = 1;
deltaX_left_flag = 0;
}
else if (deltaX_old > tp->deltaX)
{
deltaX_left_flag = 1;
deltaX_right_flag = 0;
}
//gui_log("deltaX_old:%d, d:%d\n", deltaX_old, tp->deltaX);
if (GUI_BASE(this)->x >= 0 && (tp->deltaX > 0 || deltaX_right_flag) && !deltaX_left_flag)
{
for (int i = 0; i < 3; i++)
{
for (int j = 2; j > 0; j--)
{
if (j == 2)
{
gui_free(this->tile[i][j].img->data_buffer);
free_for_rgb(this->tile[i][j].img->img->data);
this->tile[i][j].img->img->data = 0;
}
// gui_img_stb_set_attribute(
// this->tile[i][j].img,
// this->tile[i][j - 1].img->data_buffer,
// this->tile[i][j - 1].img->data_length,
// JPEG,
// this->tile[i][j].img->base.x,
// this->tile[i][j].img->base.y
// );
this->tile[i][j].img->data_buffer = this->tile[i][j - 1].img->data_buffer;
this->tile[i][j].img->data_length = this->tile[i][j - 1].img->data_length;
this->tile[i][j].img->img->data = this->tile[i][j - 1].img->img->data;
this->tile[i][j].x--;
}
this->tile[i][0].x--;
load_new_tile(&this->tile[i][0], this->zoom);
}
GUI_BASE(this)->x = -256 ;
this->start_x = -256 - tp->deltaX;
GUI_BASE(this)->matrix->m[0][2] = GUI_BASE(this)->x;
}
if (GUI_BASE(this)->x <= -(GUI_BASE(this)->w - SCREEN_W) && (tp->deltaX < 0 || deltaX_left_flag) &&
!deltaX_right_flag)
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 2; j++)
{
if (j == 0)
{
gui_free(this->tile[i][j].img->data_buffer);
free_for_rgb(this->tile[i][j].img->img->data);
this->tile[i][j].img->img->data = 0;
}
// gui_img_stb_set_attribute(
// this->tile[i][j].img,
// this->tile[i][j + 1].img->data_buffer,
// this->tile[i][j + 1].img->data_length,
// JPEG,
// this->tile[i][j].img->base.x,
// this->tile[i][j].img->base.y
// );
this->tile[i][j].img->data_buffer = this->tile[i][j + 1].img->data_buffer;
this->tile[i][j].img->data_length = this->tile[i][j + 1].img->data_length;
this->tile[i][j].img->img->data = this->tile[i][j + 1].img->img->data;
this->tile[i][j].x++;
}
// Load new image data to "tile[i][2]"
this->tile[i][2].x++;
load_new_tile(&this->tile[i][2], this->zoom);
}
GUI_BASE(this)->x = 0;
this->start_x = - tp->deltaX;
GUI_BASE(this)->matrix->m[0][2] = GUI_BASE(this)->x;
}
if (GUI_BASE(this)->y >= 0 && (tp->deltaY > 0))
{
for (int i = 0; i < 3; i++)
{
for (int j = 2; j > 0; j--)
{
if (j == 2)
{
gui_free(this->tile[j][i].img->data_buffer);
free_for_rgb(this->tile[j][i].img->img->data);
this->tile[j][i].img->img->data = 0;
}
// gui_img_stb_set_attribute(
// this->tile[j][i].img,
// this->tile[j - 1][i].img->data_buffer,
// this->tile[j - 1][i].img->data_length,
// JPEG,
// this->tile[j][i].img->base.x,
// this->tile[j][i].img->base.y
// );
this->tile[j][i].img->data_buffer = this->tile[j - 1][i].img->data_buffer;
this->tile[j][i].img->data_length = this->tile[j - 1][i].img->data_length;
this->tile[j][i].img->img->data = this->tile[j - 1][i].img->img->data;
this->tile[j][i].y--;
}
this->tile[0][i].y--;
load_new_tile(&this->tile[0][i], this->zoom);
}
GUI_BASE(this)->y = -256 ;
this->start_y = -256 - tp->deltaY;
GUI_BASE(this)->matrix->m[1][2] = GUI_BASE(this)->y;
}
if (GUI_BASE(this)->y <= -(256 * 3 - SCREEN_H) && (tp->deltaY < 0))
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 2; j++)
{
if (j == 0)
{
gui_free(this->tile[j][i].img->data_buffer);
free_for_rgb(this->tile[j][i].img->img->data);
this->tile[j][i].img->img->data = 0;
}
// gui_img_stb_set_attribute(
// this->tile[j][i].img,
// this->tile[j + 1][i].img->data_buffer,
// this->tile[j + 1][i].img->data_length,
// JPEG,
// this->tile[j][i].img->base.x,
// this->tile[j][i].img->base.y
// );
this->tile[j][i].img->data_buffer = this->tile[j + 1][i].img->data_buffer;
this->tile[j][i].img->data_length = this->tile[j + 1][i].img->data_length;
this->tile[j][i].img->img->data = this->tile[j + 1][i].img->img->data;
this->tile[j][i].y++;
}
this->tile[2][i].y++;
load_new_tile(&this->tile[2][i], this->zoom);
}
GUI_BASE(this)->y = -(256 * 3 - SCREEN_H - 256) ;
this->start_y = -(256 * 3 - SCREEN_H - 256) - tp->deltaY;
GUI_BASE(this)->matrix->m[1][2] = GUI_BASE(this)->y;
}
deltaX_old = tp->deltaX;
}
if (this->release)
{
this->start_x = GUI_BASE(this)->x;
this->start_y = GUI_BASE(this)->y;
deltaX_right_flag = 0;
deltaX_left_flag = 0;
}
//gui_log("x:%d,%d\n",GUI_BASE(this)->x, tp->deltaX);
}
static void free_for_rgb(void *p)
{
gui_free(p);
}
/*============================================================================*
* Public Functions
*============================================================================*/
static void update_zoom(int zoom)
{
gui_map_t *map = 0;
gui_obj_tree_get_widget_by_name(&gui_current_app()->screen, MAP_WIDGET_NAME, (void *)&map);
//float longitude;
//float latitude;
//tile_to_latlon(map->tile[1][1].x, map->tile[1][1].y, map->zoom, &latitude, &longitude);
if (zoom == 1)
{
map->zoom++;
}
else if (zoom == 0)
{
map->zoom--;
}
else if (zoom == -1)
{
map->latitude = GPS_LATITUDE;
map->longitude = GPS_LONGITUDE;
GUI_BASE(map)->x = -TILE_SIZE / 2;
GUI_BASE(map)->y = -TILE_SIZE / 2;
}
if (map->zoom < 0)
{
map->zoom = 0;
}
else if (map->zoom > 21)
{
map->zoom = 21;
}
//gui_log("%d,%d,%f,%f\n", map->tile[1][1].x, map->tile[1][1].y, latitude, longitude);
generateTilesForWindow(WIN_W, WIN_H, map->latitude, map->longitude, map->zoom, map);
}
static void zoom_cb()
{
update_zoom(1);
}
static void zoom_minus_cb()
{
update_zoom(0);
}
static void gps_cb()
{
update_zoom(-1);
}
gui_map_t *gui_map_create(void *parent)
{
#define _GUI_NEW_GUI_MAP_PARAM this, parent
GUI_CREATE_HELPER(gui_map_t, ctor, _GUI_NEW_GUI_MAP_PARAM)
gui_win_t *win = &(this->base);
gui_win_set_animate(win, 1000, -1, (gui_animate_callback_t)wincb, this);
// Window size
int windowWidth = WIN_W;
int windowHeight = WIN_H;
// The longitude and latitude to be displayed
double center_lat = GPS_LATITUDE;
double center_lon = GPS_LONGITUDE;
this->longitude = GPS_LONGITUDE;
this->latitude = GPS_LATITUDE;
// Zoom level
int zoom = TILE_ZOOM_LEVEL;
this->zoom = zoom;
for (size_t i = 0; i < 3; i++)
{
for (size_t j = 0; j < 3; j++)
{
this->tile[i][j].img = gui_img_stb_create_from_mem(win, 0, 0, 0, JPEG, RGB565, 0, 0);
}
}
generateTilesForWindow(windowWidth, windowHeight, center_lat, center_lon, zoom, this);
{
gui_button_t *zoom = gui_button_create(parent, 50, 200 - 30, 80, 80, 0, 0, 0, BUTTON_BG_ICON, 0);
{
static char path[100];
memset(path, 0, 100);
sprintf(path, "%s/%s", ROOT_PATH, "/map/icon/plus.bin");
int fd;
fd = gui_fs_open(path, 0);
char *jpg = 0;
off_t filesize = 0;
if (fd > 0)
{
filesize = gui_fs_lseek(fd, 0, SEEK_END);
jpg = gui_malloc(filesize);
this->button_data[0] = jpg;
gui_fs_lseek(fd, 0, SEEK_SET);
gui_fs_read(fd, jpg, filesize);
gui_fs_close(fd);
gui_img_t *img = gui_img_create_from_mem((void *)zoom, 0, jpg, 30, 30, 0, 0);
gui_img_set_mode(img, IMG_SRC_OVER_MODE);
}
}
gui_button_click((void *)zoom, (gui_event_cb_t)zoom_cb, 0);
}
{
gui_button_t *zoom = gui_button_create(parent, 50, 300 - 30, 80, 80, 0, 0, 0, BUTTON_BG_ICON, 0);
{
static char path[100];
memset(path, 0, 100);
sprintf(path, "%s/%s", ROOT_PATH, "/map/icon/minus.bin");
int fd;
fd = gui_fs_open(path, 0);
char *jpg = 0;
off_t filesize = 0;
if (fd > 0)
{
filesize = gui_fs_lseek(fd, 0, SEEK_END);
jpg = gui_malloc(filesize);
this->button_data[1] = jpg;
gui_fs_lseek(fd, 0, SEEK_SET);
gui_fs_read(fd, jpg, filesize);
gui_fs_close(fd);
gui_img_t *img = gui_img_create_from_mem((void *)zoom, 0, jpg, 30, 30, 0, 0);
gui_img_set_mode(img, IMG_SRC_OVER_MODE);
}
}
gui_button_click((void *)zoom, (gui_event_cb_t)zoom_minus_cb, 0);
}
{
gui_button_t *zoom = gui_button_create(parent, 300, 300 - 30, 80, 80, 0, 0, 0, BUTTON_BG_ICON, 0);
{
static char path[100];
memset(path, 0, 100);
sprintf(path, "%s/%s", ROOT_PATH, "/map/icon/GPS.bin");
int fd;
fd = gui_fs_open(path, 0);
char *jpg = 0;
off_t filesize = 0;
if (fd > 0)
{
filesize = gui_fs_lseek(fd, 0, SEEK_END);
jpg = gui_malloc(filesize);
this->button_data[2] = jpg;
gui_fs_lseek(fd, 0, SEEK_SET);
gui_fs_read(fd, jpg, filesize);
gui_fs_close(fd);
gui_img_t *img = gui_img_create_from_mem((void *)zoom, 0, jpg, 30, 30, 0, 0);
gui_img_set_mode(img, IMG_SRC_OVER_MODE);
}
}
gui_button_click((void *)zoom, (gui_event_cb_t)gps_cb, 0);
}
return this;
}