09-11-2021, 12:40 AM | #1 |
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
How does gfx_xformblit work?
I would appreciate it very much if someone could explain to me how the "transformation table" of gfx_xformblit works.
The help documentation simply states: Code:
gfx_xformblit(srcidx, x,y,w,h, wdiv, hdiv, tab[, wantalpha=0]) Blits with a transformation table. tab is wdiv*hdiv*2 table of source point coordinates. If wantalpha=1, tab is wdiv*hdiv*3 table of src points including alpha for each point |
09-12-2021, 05:27 PM | #2 |
Human being with feelings
Join Date: Aug 2020
Location: Brasil
Posts: 679
|
This thread has actual example of gfx_xformblit that transforms a square video into a circle:
https://forum.cockos.com/showthread.php?p=2443941 |
09-13-2021, 03:38 AM | #3 |
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
I have indeed seen that thread and I have also checked other presets that use gfx_xformblit, but unfortunately I haven't been able to figure out exactly how the transformation table works.
|
09-13-2021, 06:33 PM | #4 | |
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,721
|
Quote:
So, in a simple form, suppose wdiv=hdiv=3, and wantalpha=0. In this case the table would need to be 3*3*2 items in length, in this example a straight copy of the image would be: Code:
tab[0] = 0; tab[1] = 0; // top left corner destination coordinate tab[2] = srcw/2; tab[3] = 0; // top middle edge destination tab[4] = srcw; tab[5] = 0; // top right corner tab[6] = 0; tab[7] = srch/2; // middle left edge tab[8] = srcw/2; tab[9] = srch/2; // middle of destination tab[10] = srcw; tab[11] = srch/2; // middle right edge tab[12] = 0; tab[13] = srch; // bottom left corner tab[14] = srcw/2; tab[15]=srch; // bottom middle edge tab[16] = srcw; tab[17]=srch; // bottom right corner |
|
09-14-2021, 03:09 PM | #5 |
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Ah, thanks, I think I understand now!
|
09-14-2021, 05:16 PM | #6 |
Human being with feelings
Join Date: Aug 2020
Location: Brasil
Posts: 679
|
Many thanx too. I cannot claim yet to fully understand the power of this table transform yet but you gave us the key to start experimenting!
|
09-15-2021, 05:39 PM | #7 |
Human being with feelings
Join Date: Aug 2020
Location: Brasil
Posts: 679
|
Ok now I got it!
here is a simple pseudo-zoom with a simple 2x2x2 table: Code:
//zoom xformblit() //@param1:zoom "zoom" 1 0.01 4 1 0.001 src=0; input_info(src,srcw,srch); gfx_set(0,0,0,1); gfx_fillrect(0,0,srcw,srch); function zoom_img(img,zoom) local(tab,dx,dy) ( dx=srcw-srcw*zoom; dy=srch-srch*zoom; tab[0]=0-dx; tab[1]=0-dy; tab[2]=srcw+dx; tab[3]=0-dy; tab[4]=0-dx; tab[5]=srch+dy; tab[6]=srcw+dx; tab[7]=srch+dy; gfx_xformblit(src, 0,0,srcw,srch, 2,2,tab, 0); ); zoom_img(src,zoom); |
Thread Tools | |
Display Modes | |
|
|