Skip to content

Commit 233a3a4

Browse files
committed
UI: Implemented calling IMAGE with another image variable
1 parent eed01bb commit 233a3a4

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Fix screen dump invalid file name for online files
1212
Fix file manager .bas file case sensitivity
1313
Implemented editor F2 command to display online help
14+
Implemented calling IMAGE with another image variable
1415

1516
2015-10-20
1617
Fix LET when assigning a value to a MAP/ARRAY field

debian/changelog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
smallbasic (0.12.1) unstable; urgency=low
22
* Various - see web site
33

4-
-- Chris Warren-Smith <cwarrensmith@gmail.com> Sat, 17 Sep 2015 09:45:25 +1000
4+
-- Chris Warren-Smith <cwarrensmith@gmail.com> Sat, 17 Nov 2015 09:45:25 +1000
55

66
smallbasic (0.12.0) unstable; urgency=low
77
* Various - see web site

documentation/sbasic_ref.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Graphics,command,CIRCLE,613,"CIRCLE [STEP] x,y,r [,aspect [, color]] [COLOR colo
107107
Graphics,command,COLOR,614,"COLOR foreground-color [, background-color]","Specifies the foreground and background colors."
108108
Graphics,command,DRAW,615,"DRAW ""commands""","Draw lines as specified by the given directional commands. "
109109
Graphics,command,DRAWPOLY,616,"DRAWPOLY array [,x-origin,y-origin [, scalef [, color]]] [COLOR color] [FILLED]","Draws a polyline. "
110-
Graphics,command,IMAGE,617,"IMAGE #handle, index, x, y [,sx,sy [,w,h]]","Display a graphical image."
110+
Graphics,command,IMAGE,617,"IMAGE [#handle | fileName | http://path-to-file.png | image-var | array of pixmap data]","Creates a graphical image object providing access to the following sub-commands: show([x,y [,zindex [,opacity]]]), hide, save([x,y [,w,h]])"
111111
Graphics,command,LINE,618,"LINE [STEP] x,y [,|STEP x2,y2] [, color| COLOR color]","Draws a line."
112112
Graphics,command,PAINT,619,"PAINT [STEP] x, y [,fill-color [,border-color]]","Fills an enclosed area on the graphics screen with a specific color. x,y = Screen coordinate (column, row) within the area that is to be filled."
113113
Graphics,command,PLOT,620,"PLOT xmin, xmax USE f(x)","Graph of f(x)."

src/ui/image.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,22 @@ void ImageDisplay::draw(int x, int y, int w, int h, int cw) {
106106
maDrawRGB(&dstPoint, _buffer->_image, &srcRect, _opacity, _buffer->_width);
107107
}
108108

109+
// share image buffer from another image variable
110+
ImageBuffer *load_image(var_t *map) {
111+
ImageBuffer *result = NULL;
112+
int bid = map->type == V_MAP ? map_get_int(map, IMG_BID, -1) : -1;
113+
if (bid != -1) {
114+
List_each(ImageBuffer *, it, cache) {
115+
ImageBuffer *next = (*it);
116+
if (next->_bid == (unsigned)bid) {
117+
result = next;
118+
break;
119+
}
120+
}
121+
}
122+
return result;
123+
}
124+
109125
ImageBuffer *load_image(dev_file_t *filep) {
110126
ImageBuffer *result = NULL;
111127
List_each(ImageBuffer *, it, cache) {
@@ -294,7 +310,7 @@ void create_image(var_p_t var, ImageBuffer *image) {
294310
map_add_var(var, IMG_OFFSET_TOP, 0);
295311
map_add_var(var, IMG_OFFSET_LEFT, 0);
296312
map_add_var(var, IMG_ZINDEX, 1);
297-
map_add_var(var, IMG_OPACITY, 1);
313+
map_add_var(var, IMG_OPACITY, 0);
298314
map_add_var(var, IMG_ID, ++nextId);
299315

300316
if (image != NULL) {
@@ -416,6 +432,8 @@ extern "C" void v_create_image(var_p_t var) {
416432
}
417433
image = load_xpm_image(data);
418434
delete [] data;
435+
} else {
436+
image = load_image(&arg);
419437
}
420438
v_free(&arg);
421439
break;

0 commit comments

Comments
 (0)