[PD] [pix_data] - convert rgb values to pd canvas format

João Pais jmmmpais at gmail.com
Fri Jan 8 22:58:46 CET 2016


Thanks for your help. Here is the resulting patch, pix2canvas. Sooner or
later it will join the other abstractions in the jmmmp library.

Best,

Joao

2016-01-01 13:10 GMT+01:00 Roman Haefeli <reduzent at gmail.com>:

>
> On Thu, 2015-12-31 at 18:01 +0100, João Pais wrote:
> > If understandable, I send this patch so that it's possible to see what
> > I'm doing.
> >
> >
> > The idea is actually to convert a pix into a bunch of canvases, pixel
> > per pixel - so that a "picture" can be shown on vanilla. Follow the
> > instructions in the patch, and everything should be clear.
> > The conversion is done in [pd RGB]. There are 2 versions, but they
> > have the same output.
>
> There are quite a few different color encodings around in Pd world. For
> the iemguis, there is a difference in encoding between sending a 'color'
> message and defining a color as creation argument. What you've done
> works well for sending 'color' messages to canvas, but not as a creation
> argument. If you want to define a color as creation argument, you have
> to encode it differently, namely as 6bit-per-channel value. So, instead
> of multiplying by 255 and powers of 256, you need to multiply by 63 and
> powers of 64. See attached patch.
>
> I guess the reason is a limitation in how Pd displays (and saves)
> numbers. Although 32-bit float numbers can fully represent 24bit integer
> numbers, numbers are saved with less precision in pd files (and text
> files), since they are truncated to 6 digits. This limitation is
> worked-around by reducing the resolution to 6 bits per channel. The
> highest number (the one representing white) is -262144. It does not
> exceed 6 digits and can be stored at full precision.
>
> Roman
>
> _______________________________________________
> Pd-list at lists.iem.at mailing list
> UNSUBSCRIBE and account-management ->
> http://lists.puredata.info/listinfo/pd-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20160108/98d8a199/attachment.html>
-------------- next part --------------
#N canvas 191 7 438 666 10;
#X obj 13 245 gemhead;
#X obj 63 285 pix_draw;
#X obj 53 265 pix_image;
#X obj 63 185 bng 15 250 50 0 empty empty empty 0 -6 0 8 -204786 -1
-1;
#X obj 63 205 openpanel;
#X obj 63 225 list prepend open;
#X obj 63 245 list trim;
#X obj 63 305 pix_info . . . .;
#X obj 38 542 pix_data;
#X obj 38 442 f+ 0;
#X obj 38 482 /;
#X obj 38 422 until;
#X obj 21 362 f;
#X obj 157 422 f+ 0;
#X obj 147 482 /;
#X obj 125 422 - 1;
#X obj 147 462 moses;
#X obj 147 502 t b f;
#X obj 21 382 t b f b f;
#X obj 38 502 t b f;
#N canvas 8 115 344 182 pixx 0;
#X restore 373 205 pd pixx;
#X obj 70 642 s pd-pixx;
#X obj 70 592 pack f f f;
#X obj 157 442 t f f;
#X obj 38 462 t f f;
#X msg 321 562 vis 0 \, clear;
#N canvas 687 323 309 283 rgb2iemcreate 0;
#X obj 17 37 inlet;
#X obj 17 87 * 63;
#X obj 51 87 * 63;
#X obj 86 86 * 63;
#X obj 17 107 << 6;
#X obj 17 127 +;
#X obj 17 147 << 6;
#X obj 17 167 +;
#X obj 17 187 * -1;
#X obj 17 207 - 1;
#X obj 17 257 outlet;
#X obj 17 57 unpack f f f f;
#X obj 17 237 spigot;
#X text 67 237 Pixels with alpha = 0 are left out.;
#X text 17 17 Generates color number. Made by Roman Haefeli.;
#X connect 0 0 11 0;
#X connect 1 0 4 0;
#X connect 2 0 5 1;
#X connect 3 0 7 1;
#X connect 4 0 5 0;
#X connect 5 0 6 0;
#X connect 6 0 7 0;
#X connect 7 0 8 0;
#X connect 8 0 9 0;
#X connect 9 0 12 0;
#X connect 11 0 1 0;
#X connect 11 1 2 0;
#X connect 11 2 3 0;
#X connect 11 3 12 1;
#X connect 12 0 10 0;
#X restore 60 562 pd rgb2iemcreate;
#N canvas 1291 441 254 228 gemwindow 0;
#X obj 20 36 route load;
#X obj 20 56 route success;
#X obj 20 76 bang;
#X msg 20 146 destroy \, dimen 100 100 \, create \, 1;
#X obj 20 196 gemwin 1;
#X obj 20 16 inlet;
#X obj 30 176 inlet;
#X obj 30 96 del 100;
#X obj 30 116 outlet;
#X connect 0 0 1 0;
#X connect 1 0 2 0;
#X connect 2 0 3 0;
#X connect 2 0 7 0;
#X connect 3 0 4 0;
#X connect 5 0 0 0;
#X connect 6 0 4 0;
#X connect 7 0 8 0;
#X restore 130 285 pd gemwindow;
#X msg 199 265 destroy;
#X obj 130 362 t b b b b;
#X msg 130 382 vis 1;
#X obj 160 342 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X obj 98 482 + 20;
#X obj 184 562 expr 20 + $f2 - $f1;
#X msg 70 612 obj \$2 \$3 cnv 1 1 1 \$2x\$3 \$2x\$3-i empty 0 0 0 10
\$1 22 0 \;;
#X obj 72 442 - 1;
#X text 13 91 A display innacuracy makes the pixels in the top row
and right column too thick.;
#X text 83 184 Load a file \, and check the subpatch pixx for the result.
;
#X text 12 151 (C) João Pais - jmmmpais at gmail.com;
#X text 13 51 This makes it possible to "import" images into vanilla.
Small pictures are converted fast \, but medium and big files can take
some time to convert and display.;
#X text 13 11 This patch converts images into groups of canvases with
thickness of 1x1 \, pixel per pixel. Invisible pixels (with alpha =
0) are ignored.;
#X text 13 121 Each canvas (i.e. pixel) has its a send and receive
name based on the coordinate: "XxY" and "XxY-i" respectively.;
#X connect 0 0 2 0;
#X connect 2 0 1 0;
#X connect 2 0 7 0;
#X connect 2 0 8 1;
#X connect 2 1 27 0;
#X connect 3 0 4 0;
#X connect 4 0 5 0;
#X connect 5 0 6 0;
#X connect 6 0 2 0;
#X connect 7 1 12 1;
#X connect 7 2 15 0;
#X connect 7 2 16 1;
#X connect 7 2 33 1;
#X connect 8 1 26 0;
#X connect 9 0 24 0;
#X connect 10 0 19 0;
#X connect 11 0 9 0;
#X connect 12 0 18 0;
#X connect 13 0 23 0;
#X connect 14 0 17 0;
#X connect 15 0 14 1;
#X connect 16 0 14 0;
#X connect 17 0 12 0;
#X connect 17 1 8 3;
#X connect 18 0 13 0;
#X connect 18 1 11 0;
#X connect 18 2 9 1;
#X connect 18 3 35 0;
#X connect 19 0 8 0;
#X connect 19 1 8 2;
#X connect 22 0 34 0;
#X connect 23 0 16 0;
#X connect 23 1 33 0;
#X connect 24 0 10 0;
#X connect 24 1 32 0;
#X connect 25 0 21 0;
#X connect 26 0 22 0;
#X connect 27 0 29 0;
#X connect 28 0 27 1;
#X connect 29 0 30 0;
#X connect 29 1 13 0;
#X connect 29 2 13 1;
#X connect 29 3 25 0;
#X connect 30 0 21 0;
#X connect 31 0 29 0;
#X connect 32 0 22 1;
#X connect 33 0 22 2;
#X connect 34 0 21 0;
#X connect 35 0 10 1;


More information about the Pd-list mailing list