aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui/image-help.pd30
-rw-r--r--gui/image.c37
2 files changed, 48 insertions, 19 deletions
diff --git a/gui/image-help.pd b/gui/image-help.pd
index c0612f5..77f397b 100644
--- a/gui/image-help.pd
+++ b/gui/image-help.pd
@@ -1,4 +1,26 @@
-#N canvas 0 0 450 300 10;
-#X obj 90 167 image logo100.gif;
-#X text 20 36 Incorporate images. This is instantiated with;
-#X text 20 52 [image logo100.gif];
+#N canvas 140 178 568 628 10;
+#X obj 246 361 image logo100.gif;
+#X text 19 18 Incorporate images. This is instantiated with;
+#X text 19 34 [image logo100.gif];
+#X text 17 57 [image] works with .gif \, .ppm \, and .pgm image formats
+only.;
+#X msg 86 132 open \$1;
+#X obj 86 88 bng 15 250 50 0 empty empty empty 0 -6 0 10 -4034 -1 -1
+;
+#X obj 86 109 openpanel;
+#X obj 238 567 bng 15 250 50 0 empty empty empty 0 -6 0 10 -262144
+-1 -1;
+#X msg 265 152 size \$1 \$2;
+#X obj 265 129 pack 0 0;
+#X obj 313 106 hsl 128 15 0 127 0 0 empty empty y 7 7 0 10 -203904
+-1 -1 11800 1;
+#X obj 263 88 hsl 128 15 0 127 0 0 empty empty x 7 7 0 10 -204800 -1
+-1 12700 1;
+#X connect 0 0 7 0;
+#X connect 4 0 0 0;
+#X connect 5 0 6 0;
+#X connect 6 0 4 0;
+#X connect 8 0 0 0;
+#X connect 9 0 8 0;
+#X connect 10 0 9 1;
+#X connect 11 0 9 0;
diff --git a/gui/image.c b/gui/image.c
index a025628..5d9a5ca 100644
--- a/gui/image.c
+++ b/gui/image.c
@@ -23,26 +23,26 @@ typedef struct _image
void image_drawme(t_image *x, t_glist *glist, int firsttime)
{
- if (firsttime) {
- char fname[MAXPDSTRING];
- canvas_makefilename(glist_getcanvas(x->x_glist), x->x_fname->s_name,
- fname, MAXPDSTRING);
+ if (firsttime) {
+ char fname[MAXPDSTRING];
+ canvas_makefilename(glist_getcanvas(x->x_glist), x->x_fname->s_name,
+ fname, MAXPDSTRING);
- sys_vgui("image create photo img%x -file \"%s\"\n",x,fname);
+ sys_vgui("image create photo img%x -file {%s}\n",x,fname);
sys_vgui(".x%x.c create image %d %d -image img%x -tags %xS\n",
- glist_getcanvas(glist),text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),x,x);
+ glist_getcanvas(glist),text_xpix(&x->x_obj, glist),
+ text_ypix(&x->x_obj, glist),x,x);
/* TODO callback from gui
sys_vgui("image_size logo");
*/
}
else {
- sys_vgui(".x%x.c coords %xS \
-%d %d\n",
- glist_getcanvas(glist), x,
- text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist));
+ sys_vgui(".x%x.c coords %xS %d %d\n",
+ glist_getcanvas(glist), x,
+ text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist));
}
-
+
}
@@ -159,6 +159,13 @@ void image_color(t_image* x,t_symbol* col)
*/
}
+void image_open(t_image* x, t_symbol* fname)
+{
+ x->x_fname = fname;
+ image_erase(x, x->x_glist);
+ image_drawme(x, x->x_glist, 1);
+}
+
static void image_setwidget(void)
{
image_widgetbehavior.w_getrectfn = image_getrect;
@@ -186,7 +193,7 @@ static void *image_new(t_symbol* fname)
x->x_width = 15;
x->x_height = 15;
- x->x_fname = fname;
+ x->x_fname = fname;
outlet_new(&x->x_obj, &s_float);
return (x);
}
@@ -196,17 +203,17 @@ void image_setup(void)
image_class = class_new(gensym("image"), (t_newmethod)image_new, 0,
sizeof(t_image),0, A_DEFSYM,0);
-/*
class_addmethod(image_class, (t_method)image_size, gensym("size"),
A_FLOAT, A_FLOAT, 0);
+/*
class_addmethod(image_class, (t_method)image_color, gensym("color"),
A_SYMBOL, 0);
*/
-/*
+
class_addmethod(image_class, (t_method)image_open, gensym("open"),
A_SYMBOL, 0);
-*/
+
image_setwidget();
class_setwidget(image_class,&image_widgetbehavior);
#if PD_MINOR_VERSION >= 37