drawing an image at a floating point location

BlitzMax Forums/BlitzMax Beginners Area/drawing an image at a floating point location

Nate the Great(Posted 2009) [#1]
hi, so I am tired of my images having to be drawn at integer locations. is there a way around this so I can get a completely smoothed movement? I read something about filteredimage but it doesnt work for me here is my code that proves it doesnt work

img = LoadImage("c:/box.bmp",FILTEREDIMAGE)

Graphics 800,600,0,60

Global x# = 10
While Not KeyDown(key_escape)
Cls
x# :+ .1
DrawImage img,x#,10.5

Flip
Wend
End



Who was John Galt?(Posted 2009) [#2]
I thought that worked? I can't test as I don't have Blitz here. You do get a bit of an aliasing effect- when things are plotted at integer positions, there is no interpolation, whereas there is at non integer positions. Try making going super-resolution with your sprite, i.e: draw it bigger and scale down.

[Off-topic]What did you come up with for that point-line collision response problem in the end?


GfK(Posted 2009) [#3]
Change you name to "Nate the Slightly Mediocre" ;)

(just kidding)

Anyway, that code works fine here (with a PNG image - don't have a BMP to hand) but you should really declare img as a TImage. I remember in the early days of Blitzmax, GC could really get its knickers in a twist if you load an image to an integer but I don't know if that's still the case.


Brucey(Posted 2009) [#4]
You should really declare img as a TImage


To save you the bother of having to remember... just stick SuperStrict at the top of your program ;-)


ImaginaryHuman(Posted 2009) [#5]
filtered image filters the pixels WITHIN the image, it does not do anything to antialiase the four edges of the image against the background. For that you have to use polygon antialiasing, which blitzmax does not. That's why it can appear as though the edge of the sprite might be not drawing at a subpixel reference. maybe you should draw it subpixel and grab the screen and zoom in and see what is going on.


Nate the Great(Posted 2009) [#6]
@ IH oh ok. I get it now.. I thought the outsides would be alpha'd but I guess I was wrong.

@Gfk & brucey. I use superstrict all of the time, I just thought this was so simple it didnt need superstrict. :p


ImaginaryHuman(Posted 2009) [#7]
I think in terms of the GPU, it works out if a pixel is like at least half covering a pixel and if so that pixel gets a FULL pixel drawn, with no antialiasing of the background. Then it works out what to fill it with. Filtering is more to do with how the texture is READ from memory than how it's combined with the background.


plash(Posted 2009) [#8]
@Gfk & brucey. I use superstrict all of the time, I just thought this was so simple it didnt need superstrict. :p
There is never a reason to /not/ use it!

*Goes off to register the domain 'superstrictisyourfriend.com', in which the index page says, in big lettering, "AND IF YOU DON'T USE HER SHE WILL INVOKE BSODs ON YOUR COMPUTER!"*


N(Posted 2009) [#9]
SHE WILL INVOKE BSODs ON YOUR COMPUTER!
Guess I'm safe, what with being a Mac user. We have very pretty kernel panics.