NaaLaa
xform question/issue? - Printable Version

+- NaaLaa (https://www.naalaa.com/forum)
+-- Forum: NaaLaa (https://www.naalaa.com/forum/forum-1.html)
+--- Forum: NaaLaa 7 Questions (https://www.naalaa.com/forum/forum-3.html)
+--- Thread: xform question/issue? (/thread-197.html)



xform question/issue? - kevin - 02-19-2025

Hi, 
I have a question about the xform function please. In the attached example, I have a png image of 100 * 100 pixels (created in GIMP), that I am displaying on screen using the xform function with a scaling of 7. However, rather than displaying an image of 700 * 700 pixels, the image dimensions would appear to be 693 * 693 pixels? I have tried this with image files created in different applications, with the same results.

Am I maybe using the xform function incorrectly, or is there a very small issue with it? This is such a small problem that I was unsure whether to raise it, and I can work around it in my routines, so please do not rush to respond.

All the best - Kevin.

.zip   xform test.zip (Size: 848 bytes / Downloads: 5)


RE: xform question/issue? - Marcus - 02-19-2025

How odd, I'll investigate it!

Edit I just had a quick look at the n7 source code on my phone, while walking home from work, and found the cause. I'll release an update when I get home Smile


RE: xform question/issue? - 1micha.elok - 02-19-2025

sorry, I deleted a reply... I still make an error  Big Grin

(02-19-2025, 10:40 AM)kevin Wrote: Hi, 
I have a question about the xform function please. In the attached example, I have a png image of 100 * 100 pixels (created in GIMP), that I am displaying on screen using the xform function with a scaling of 7. However, rather than displaying an image of 700 * 700 pixels, the image dimensions would appear to be 693 * 693 pixels? I have tried this with image files created in different applications, with the same results.
...

Hi Kevin
Perhaps this one resolve this issue ?

Code:
set window "xform test",700,700
set redraw off

img = loadimage("hundred by hundred pixels.png")

set color 255,255,255;cls

factor = screenw()/screenh()           
draw image xform img,0,0,7*factor,7*factor,0,0,0
save image primary, "700.png"

temp = rln()



RE: xform question/issue? - Marcus - 02-19-2025

(02-19-2025, 01:34 PM)1micha.elok Wrote: sorry, I deleted a reply... I still make an error  Big Grin

(02-19-2025, 10:40 AM)kevin Wrote: Hi, 
I have a question about the xform function please. In the attached example, I have a png image of 100 * 100 pixels (created in GIMP), that I am displaying on screen using the xform function with a scaling of 7. However, rather than displaying an image of 700 * 700 pixels, the image dimensions would appear to be 693 * 693 pixels? I have tried this with image files created in different applications, with the same results.
...

Hi Kevin
Perhaps this one resolve this issue ?

Code:
set window "xform test",700,700
set redraw off

img = loadimage("hundred by hundred pixels.png")

set color 255,255,255;cls

factor = screenw()/screenh()           
draw image xform img,0,0,7*factor,7*factor,0,0,0
save image primary, "700.png"

temp = rln()

It's all my bad, there's an error in the calculations in the 'draw image xform' implementation (C code). Simply put, the implementation subtracts 1 from the width and height of the image before applying the transformations, so when scaling by 7, 7 pixels goes missing. Sorry, I don't know how that bug got there, I must have left some test in the code by mistake.

Thanks for noticing this bug, Kevin! Smile


RE: xform question/issue? - kevin - 02-19-2025

That's great - thanks for looking into this so quickly Marcus.

1micha.elok - thanks to you too for looking at the issue and trying to produce a workaround.

All the best - Kevin.