I think it’s almost done. I just don’t know how to select the right image using a name.
fx_jpeg :
to_rgb
inum=$!
q=$1
($2,$4,$6;$3,$5,$7;0,0,0)
nm. params
eval. "begin(list=transpose(crop(0,0,3,2),2));
for(n=0,n<3,++n,
pos=n*2;
i(n,2)=(find(list,list[pos,2],0,2)*0.5
));"
tcount=0
repeat 3
tnum={i(#$params,$>,2)}
if $tnum==$>
tw={i(#$params,$>,0)}
th={i(#$params,$>,1)}
dct_tileset $tw,$th
idct_tileset $tw,$th
nm[-2,-1] "dct"$tcount"","idct"$tcount""
tcount+=1
fi
done
repeat {$inum} l[$>,{(-2*$tcount)-1}--1]
ww={w(#0)}
hh={h(#0)}
csswap[0] 0,15 s[0] c
display
repeat 3
tw={i(#$params,$>,0)}
th={i(#$params,$>,1)}
tn={i(#$params,$>,2)}
r[$>] {w(#0)+(-w(#0)%$tw)},{h(#0)+(-h(#0)%$th)},1,100%,0,3
{w#0},{h#0},{d#0},{s#0}
f[$>] :"
begin(const tw="$tw";const th="$th";const twh=tw*th;const tn="$tn");
if (!(x%tw) && !(y%th),
res=vector(#twh,0);
ref(crop(x,y,tw,th),src);
for (l = 0, l<th, ++l, for (k = 0, k<tw, ++k,
off = k + tw*l;
res += src[off]*crop(#""$dct"tn",k*tw,l*th,tw,th,1))); # ?
draw(#-1,res,x,y,0,0,tw,th);
); i"
f. :"begin_t(const qual="$tw"*"$th"*0.0625*(1-"$q"*0.01)^3);round(i,qual)"
f. :"
begin(const tw="$tw";const th="$th";const twh=tw*th;const tn="$tn");
if (!(x%tw) && !(y%th),
res=vector(#twh,0);
ref(crop(x,y,tw,th),src);
for (l = 0, l<th, ++l, for (k = 0, k<tw, ++k,
off = k + tw*l;
res += src[off]*crop(#""$idct"tn",k*tw,l*th,tw,th,1))); # ?
draw(#"$>",res,x,y,0,0,tw,th);
); i"
rm.
r[$>] {$ww},{$hh},1,100%,0,3
done
display
a[0-2] c csswap[0] 15,0
How do I get #""$dct"tn"
to turn into #$dct1
etc…?