AutoFit (update)

44 replies to this topic
Posted 1+ years ago #26

Well I was coming here to enquirer about using scissors on a scaled display and it seems that siread has come up with a solution. yippee.

As always a big THANKYOU to James Boyd for autofit and a hearty handshake to sired, though I am sure sired is too busy mixing with his new high end dev friends and driving around in one of his many sports cars to care :p

Posted 1+ years ago #27

I was actually going to update it with Si's scissor stuff a while ago... will do soon-ish!

Posted 1+ years ago #28

Just test out this module, looks great but I am having a little trouble.

Just for testing purposes I set up a virtual display of 1280x720 but noticed that the first line of the virtual display was intermittently not being displayed. I assumed that this was just due to the physical screen resolution not matching the virtual one. So I set the virtual screen to match the physical one, so it should not really be scaling and yet the first line is still missing?

This does not draw a rectangle:-

DrawLine(0, 0, 1279, 0)
DrawLine(0, 719, 1279, 719)
DrawLine(0, 0, 0, 719)
DrawLine(1279, 0, 1279, 719)

This does? :-

DrawLine(0, 1, 1279, 1)
DrawLine(0, 719, 1279, 719)
DrawLine(0, 0, 0, 719)
DrawLine(1279, 0, 1279, 719)

It's not a big deal but it may be indicative of a bug.

Posted 1+ years ago #29

Hi! It's possible to "stretch" the virtual canvas to fill the screen, even if it means to lose the aspect ratio?

Posted 1+ years ago #30

Just wanted to say a huge thanks to @druggedbunny for this awesome piece of code. I initially tried doing my own thing, which worked, but it was nowhere near as elegant as this. Thank you for making my life easier :)
The screen rotate and scale changes are simply a godsend.

Posted 1+ years ago #31

Yeah, autofit rocks! I would like to see a possibility to stretch the virtual canvas if, for example, the black border only takes 5% of the total deviceheight or devicewidth. It will lose the aspect ratio, but not much.

Posted 1+ years ago #32

How do I get rid of artifacts from Autofit?

If you look at the arrow - between the squares is a red line. It is as if the images bleed through.

The second image is with Autofit turned off, and voila.. no more artifacts.

The images are 64x64 and the horizontal / vertical parameter for Autofit is 512 / 768.

I am guessing it has a lot to do with the ratio. But where does the red come from? The neighboring image from the file contains red, but it shouldn't bleed into the other image should it? I changed the image to cyan and sure enough the red becomes cyan.

The image file itself is 28 64x64 going 7 across and 4 deep.

Again.. When I disable Autofit, it goes away.

Posted 1+ years ago #34

Not sure what DeFringe is but the the site is currently down. :(

I am going to write some code up in a bit to hopefully load up the "sprite sheet" image and cut it up into the 64x64 pieces and stick them in an array and see if that helps.

Posted 1+ years ago #35

We ( or maybe just *I* ) need a FAQ for Monkey. It appears this type of thing has been discussed many times.. just buried deep in the forums. :)

Posted 1+ years ago #36

Be sure to pad the images, edge fringe is often the result of the bilinear filtering process grabbing pixels from beyond the borders of the texture being displayed and processing them into the end result you see on screen. AutoFit doesn't actually do this, the hardware does. There are multiple solutions to the problem, but probably the easiest (and with least impact on performance) is to simply pad the image.

Now, gaps in tiles is another matter, there are a bunch of problems/solutions for that, depending on whether you need alpha accuracy....

Posted 1+ years ago #37

Nobuyuki and therevills, Thank you both for your help.

Posted 1+ years ago #38

in the last 'autofit' file I observed the GetMultiratio it is missing. i needed that function for my calculations.

why did you delete that function?

Posted 1+ years ago #39

@Raul: I think that might be in Nobuyuki's AutoScale -- it was never in AutoFit anyway!

Posted 1+ years ago #40

@DruggedBunny: I have an old project with those 2 functions... The filename is AutoFit. I never used Nobuyuki's AutoScale :D

Function GetBlackWidth:Int()
	Return VirtualDisplay.Display.widthborder

Function GetMultiratio:Float()
	Return VirtualDisplay.Display.multi


Posted 1+ years ago #41

Someone else must have added those, then -- didn't have a GetBlackWidth either!

Posted 1+ years ago #42

Finally got around to downloading this and giving it a go. Took me all of 5 mins to update my code and get it working.

Thanks DruggedBunny, saved me a lot of work and most likely headaches trying to do this myself.

Posted 1+ years ago #43

I've got a bit of a weird one and was wondering if I could get some help?

I've been using autofit 2.0 in my project for a while now without issues - so much so that I had forgotten about it - and everything has been working great, but it's started playing silly buggers tonight and I have no idea why.

It is 'Imported' fine, and the SetVirtualDisplay and UpdateVirtualDisplay are tokenised normally in the editor (JungleIDE) so the keywords are recognised properly, everything compiles etc

However if I add VMouseX(), VMouseY(), VTouchX() or VTouchY() then I've noticed that they are tokenised in italic, and I get the following error when I actually click/touch:

Monkey Runtime Error : TypeError: Cannot call method 'p_TouchX' of null

The code I am running to get this is just a debug line:

If TouchHit(0)
    DebugLog "vx: " + VTouchX() + " , vy: " + VTouchY()

I should note that I am also using iEngine from the Ignition Framework to swap between game states, and that autofit is working fine in one of the other states (and the commands are not italic in that source either) - just not in this particular one that I added tonight.

I have tried adding autofit, SetVirtualDisplay and UpdateVirtualDisplay to the files manually (as opposed to Importing them from another file) but the issue persists and I keep getting the null error.

Anyone got any ideas?

Posted 1+ years ago #44

OK I seem to have found the problem - I now have precede the VTouchX/VTouchY() etc commands like so...

DrawText "I'm scaled", autofit.VTouchX(), autofit.VTouchY()

I guess something changed since I first used the autofit stuff I coded, but I'll leave it here in case anyone else has the same issue in future.

Posted 1+ years ago #45

Hmm, I can only imagine another module has similarly-named commands if that's what solved it.