-
Notifications
You must be signed in to change notification settings - Fork 2
/
of.imagetexture-help.pd
250 lines (250 loc) · 8.23 KB
/
of.imagetexture-help.pd
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
#N canvas 549 23 690 703 12;
#X declare -lib ofelia;
#X obj 9 10 cnv 15 600 60 empty empty empty 20 12 0 14 -233017 -66577
0;
#X obj 462 45 declare -lib ofelia;
#X text 44 169 open png with alpha channel;
#X msg 79 379 get;
#X text 72 329 save to file;
#X msg 57 239 open https://puredata.info/portal_css/Plone%20Default/logo.png
, f 68;
#X obj 71 284 openpanel;
#X msg 71 307 open \$1;
#X obj 71 263 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X msg 46 191 open data/transparency.png;
#X msg 73 348 save export.png;
#X text 58 220 works also with online files if connected to internet
;
#X obj 19 98 of.draw;
#X obj 518 19 of.window 1;
#X obj 497 21 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X text 132 480 get pixels color r \, g \, b \, a, f 16;
#X text 32 123 open relative to the patch;
#X text 92 263 browse for a file...;
#X obj 136 461 print pixel;
#X text 26 40 Arguments: path \, draw \, posX \, posY \, posZ \, width
\, height;
#N canvas 598 139 667 421 draw_on_screen 0;
#X floatatom 41 29 5 0 0 0 - - -;
#X msg 70 114 drawsubsection 1 100 0 100 100 120 200;
#X obj 74 155 of.mouse;
#X text 349 112 active \, posX \, posY \, witdh \, height \, cropfromX
\, cropfromY \, posCropX \, posCropY, f 42;
#X msg 76 311 anchorpoint \$1 \$1;
#X floatatom 76 283 5 0 0 0 - - -;
#X text 117 283 change anchor point;
#X text 361 206 active \, posX \, posY \, witdh \, height \, cropfromX
\, cropfromY \, posCropX \, posCropY, f 42;
#X text 217 247 Desactivate drawsubsection;
#X text 149 83 Desactivate draw;
#X obj 74 182 spigot;
#X obj 149 167 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X msg 74 210 drawsubsection 1 -100 110 200 100 \$1 \$2;
#X msg 41 54 draw 1 \$1 0 0 100 100;
#X msg 59 83 draw 0 0;
#X msg 73 247 drawsubsection 0 0;
#X text 201 53 activation \, X \, Y \, Z \, width \, height;
#X text 82 27 pos X;
#X text 175 164 -> acivate this to scroll image with mouse on window
;
#X text 37 4 draw image buffer on screen;
#X obj 20 339 send imagetexture;
#X connect 0 0 13 0;
#X connect 1 0 20 0;
#X connect 2 0 10 0;
#X connect 4 0 20 0;
#X connect 5 0 4 0;
#X connect 10 0 12 0;
#X connect 11 0 10 1;
#X connect 12 0 20 0;
#X connect 13 0 20 0;
#X connect 14 0 20 0;
#X connect 15 0 20 0;
#X restore 459 444 pd draw_on_screen;
#N canvas 816 141 464 290 pixels_process 1;
#X msg 39 168 crop 100 100 100 100;
#X msg 39 194 cropfrom img 100 100 300 300;
#X msg 40 90 mirror 1 0;
#X text 124 90 vertical \, horizontal;
#X msg 40 115 rotate 1;
#X text 124 115 rotate by 90°;
#X text 144 141 resize width \, height;
#X text 152 65 0= Grayscale \, 1 =rgb \, 2 = rgba;
#X text 245 193 to do...;
#X text 190 168 width \, height \, posX \, posY (careful);
#X msg 40 65 setimagetype \$1;
#X obj 40 42 hradio 15 1 0 3 empty empty empty 0 -8 0 10 -262144 -1
-1 1;
#X text 35 12 Careful: Cannot be undone!;
#X msg 40 141 resize 100 100;
#X obj 8 241 send imagetexture;
#X connect 0 0 14 0;
#X connect 1 0 14 0;
#X connect 2 0 14 0;
#X connect 4 0 14 0;
#X connect 10 0 14 0;
#X connect 11 0 10 0;
#X connect 13 0 14 0;
#X restore 459 472 pd pixels_process;
#X msg 422 338 getpixel 100 100;
#X text 422 309 Get pixels color at X \, Y to middle outlet, f 37
;
#X text 26 579 draw plane from center;
#X msg 264 329 filter \$1;
#X obj 422 268 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1
1;
#X msg 422 290 warp \$1;
#X floatatom 42 521 5 0 0 0 - - -;
#X msg 42 546 texturemap 0 0 \$1 \$1;
#X obj 19 456 of.view;
#X obj 19 490 of.depth 1;
#X obj 264 263 vradio 15 1 0 4 empty empty empty 0 -8 0 10 -262144
-1 -1 2;
#X text 284 260 nearest;
#X text 284 290 mipmap nearest;
#X text 284 306 mipmap linear;
#X obj 19 598 of.sphere 200 20;
#X msg 35 142 open data/earth.jpg;
#X text 284 276 linear (default);
#X obj 19 422 of.imagetexture data/earth.jpg, f 34;
#X text 28 22 Image loader using memory and gpu based pixels with texture
;
#X text 442 269 texture warp;
#X obj 422 369 receive imagetexture;
#N canvas 527 48 651 683 Set_buffer_&_Pixels 0;
#X msg 185 594 clear;
#X text 232 594 clear all pixels = careful \, need re-allocate!;
#N canvas 418 393 528 305 Work_with_alpha 0;
#X obj 56 207 outlet;
#X floatatom 85 116 5 0 0 0 - - -;
#X msg 56 54 allocate 10 10 2 \, fill 200 0 0 50 \, draw 1 -150 -150
10 300 300;
#X text 55 30 allocate colortype =2 \, fill rgba (alpha = 50) \, draw
300x300px, f 67;
#X text 131 116 need after \, and update (carefull of the values!)
;
#X msg 85 142 setpixel \$1 0 255 255 255 150 \, update;
#X text 357 139 alpha = 150;
#X connect 1 0 5 0;
#X connect 2 0 0 0;
#X connect 5 0 0 0;
#X restore 102 118 pd Work_with_alpha;
#X msg 180 564 save \$1;
#X obj 180 540 savepanel;
#X obj 180 515 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X text 176 429 Grabs pixels from the opengl window specified by the
region (x \, y \, w \, h) and turns them into an image. It resizes
or allocates the ofImage if it's necessary.;
#X text 203 511 export the image buffer;
#X msg 182 479 grab 250 250 100 100;
#X obj 18 7 cnv 15 400 20 empty empty empty 20 12 0 14 -191407 -66577
0;
#X text 195 54 (0= Grayscale \, 1 =rgb \, 2 = rgba);
#X msg 96 90 fill 0 0 0;
#X msg 71 54 allocate 10 10 1;
#X obj 19 154 cnv 15 400 20 empty empty empty 20 12 0 14 -191407 -66577
0;
#X floatatom 119 187 5 0 0 0 - - -;
#X msg 135 237 update;
#X floatatom 157 282 5 0 0 0 - - -;
#X text 163 184 Set pixels X \, Y \, r \, g \, b \, a;
#X text 192 236 need after set pixel;
#X msg 119 212 setpixel \$1 0 255 255 255 255;
#X msg 157 308 setpixel \$1 0 255 0 0 \, update;
#X floatatom 174 329 5 0 0 0 - - -;
#X msg 174 353 setpixel \$1 \$1 255 0 0 \, update;
#X text 220 327 set XY \, and update (carefull of the values!);
#X text 203 282 set X -> end \, and update (carefull of the values!)
;
#X text 68 10 Allocate pixel buffer size and clear color;
#X text 65 36 1/ allocate Width \, Height \, colortype;
#X text 95 72 2 fill (clear);
#X text 182 91 -> fill rgb (black). fill rgb or rgba if colortype =2
;
#X text 162 155 Set pixels;
#X obj 28 406 cnv 15 400 20 empty empty empty 20 12 0 14 -191407 -66577
0;
#X text 171 407 Grab etc;
#X obj 22 622 send imagetexture;
#X connect 0 0 32 0;
#X connect 2 0 32 0;
#X connect 3 0 32 0;
#X connect 4 0 3 0;
#X connect 5 0 4 0;
#X connect 8 0 32 0;
#X connect 11 0 32 0;
#X connect 12 0 32 0;
#X connect 14 0 19 0;
#X connect 15 0 32 0;
#X connect 16 0 20 0;
#X connect 19 0 32 0;
#X connect 20 0 32 0;
#X connect 21 0 22 0;
#X connect 22 0 32 0;
#X restore 459 498 pd Set_buffer_&_Pixels;
#X text 80 520 texture map (default 0 0 1 1);
#X text 113 379 get infos to right outlet, f 16;
#N canvas 801 493 391 251 Get_infos 0;
#X obj 20 20 inlet;
#X floatatom 47 146 5 0 0 0 - - -;
#X floatatom 74 126 5 0 0 0 - - -;
#X floatatom 129 83 5 0 0 0 - - -;
#X text 270 94 1 = rgb;
#X text 270 84 0 = grayscale;
#X text 177 84 Image type:;
#X text 89 147 width px;
#X text 114 127 height px;
#X obj 20 60 unpack 0 0 0 0 0;
#X floatatom 101 104 5 0 0 0 - - -;
#X text 143 105 Ratio;
#X text 270 104 2 = rgba;
#X obj 20 154 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X text 19 182 0 = load fail;
#X text 18 169 1 = load success;
#X connect 0 0 9 0;
#X connect 9 0 13 0;
#X connect 9 1 1 0;
#X connect 9 2 2 0;
#X connect 9 3 10 0;
#X connect 9 4 3 0;
#X restore 254 461 pd Get_infos;
#X text 262 441 -> get infos as a list;
#X text 259 73 of.Image is a convenient object that lets you both draw
images to the screen and manipulate their pixel data. The ofImage allows
you to load/save an image from/to disk \, \, manipulate the pixels
\, and create an OpenGL texture that you can display on any shape with
texture coordinate. Loading a file into the ofImage allocates an ofPixels
object and creates the ofTexture to display the pixels. ofImage uses
a library called "freeImage" under the hood.;
#X text 259 193 Difference with of.image: texture access with mipmapping
, f 61;
#X obj 264 388 t a;
#X connect 3 0 39 0;
#X connect 5 0 39 0;
#X connect 6 0 7 0;
#X connect 7 0 39 0;
#X connect 8 0 6 0;
#X connect 9 0 39 0;
#X connect 10 0 39 0;
#X connect 12 0 39 0;
#X connect 14 0 13 0;
#X connect 22 0 50 0;
#X connect 25 0 50 0;
#X connect 26 0 27 0;
#X connect 27 0 50 0;
#X connect 28 0 29 0;
#X connect 29 0 36 0;
#X connect 30 0 31 0;
#X connect 31 0 36 0;
#X connect 32 0 25 0;
#X connect 37 0 39 0;
#X connect 39 0 30 0;
#X connect 39 1 18 0;
#X connect 39 2 46 0;
#X connect 42 0 50 0;
#X connect 50 0 39 0;