Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Way to change filter when loading images

  1. #1

    Way to change filter when loading images

    Hi Andreaz,

    Again I have a question for you

    I've uploaded this image

    (The jpg compression has made this sample a tad bit worse, but it'll still do.)

    The right soccerplayer including the grass behind it, is actually from a screenshot taken while running a demo made with Phoenix.
    The left soccerplayer is added in photohop, to make it clear what it is actually supposed to look like.
    As you can see, the right image is more blurred. It is especially visible on the t'shirt.

    I was wondering if there is a way to load the images they way they are, without any filtering applied to them.

    Thanks,

  2. #2

    Way to change filter when loading images

    i've been thinking about that too, though i didnt really understand why my sprites were of so much lower quality.

    (originally 24x32 pixelart-sprites, that gets blurred... strange artefacts now and then)

  3. #3

    Way to change filter when loading images

    There's two ways of doing that, if you want to do it for all images use

    Code:
      Uses phxTexture;
    
    setDefaultTextureFilter (tfNearest, tfNearest);
    
    ImageList.LoadImage(...);
    or for a single image

    Code:
    TPHXTextureManager.getInstance.setFilter(tfNearest, tfNearest);
    
    ImageList.LoadImage(...);
    However, they aren really loaded with a filter, the pixeldata is untouched after the loading. But the filtering appears when streching the texture, whitch is defined with the texture magnification and minification functions.
    Amnoxx

    Oh, and this code appears to be an approximate replacement for return(random() & 0x01);

    Phoenix Wiki
    http://www.phoenixlib.net/

    Phoenix Forum
    http://www.pascalgamedevelopment.com/viewforum.php?f=71

  4. #4

    Way to change filter when loading images

    Thanks for the quick reply. I'll give that a try later today, when I get home from work.

  5. #5

    Way to change filter when loading images

    An update on my previous post.
    The suggestion to call setDefaultTextureFilter improved the sprite slightly.
    However, the real solution was actually to resize the image.
    I found out that I had accidently cropped the spirte to the odd size 200x214. Once I had it corrected to 256x256 things went back to normal again.

  6. #6

    Way to change filter when loading images

    Ah, i see, the good old non power of two problem
    Amnoxx

    Oh, and this code appears to be an approximate replacement for return(random() & 0x01);

    Phoenix Wiki
    http://www.phoenixlib.net/

    Phoenix Forum
    http://www.pascalgamedevelopment.com/viewforum.php?f=71

  7. #7

    Way to change filter when loading images

    well, my problem is still there. maybe it doesent have anything to do with this at all?

    i sometimes get artefacts from the above animation (in the spritesheet), and there seems to be some blurring of the sprites themselves.



    heres one of my spritesheets:



    any suggestions as to what is causing this?

  8. #8

    Way to change filter when loading images

    Your spritesheet is 288x256pixels. I'm not sure if that is also what you're using in your game, but I think you would get better results using a size of 256x256

  9. #9

    Way to change filter when loading images

    I dont do any resizing at all, so there really shouldnt be any problem.

    each sprite is 24x32pixels, and 24 does not add up to 256.

    i dont see any reason for having spritesheets that are uniform in sixe either, as long as the sprites fit and have the correct spacing.
    (mine is automatically created, so sizing and spacing is allways correct)

    I have used these spritesheets with unDelphiX and Gamemaker, and they work there, so why not with phoenix?

    heres a pic of the char as it is in phoenix, and they way it should be


  10. #10

    Way to change filter when loading images

    Quote Originally Posted by Diaboli
    I dont do any resizing at all, so there really shouldnt be any problem.

    each sprite is 24x32pixels, and 24 does not add up to 256.

    i dont see any reason for having spritesheets that are uniform in sixe either, as long as the sprites fit and have the correct spacing.
    (mine is automatically created, so sizing and spacing is allways correct)

    I have used these spritesheets with unDelphiX and Gamemaker, and they work there, so why not with phoenix?

    heres a pic of the char as it is in phoenix, and they way it should be

    Its not a problem regarding resizing or streaching, it's a limitaion of the software in the modern GPU's, for speed resons they work best with textures that are power of two (32x32, 64x64 128x128 256x256). And as phoenix renders images as textured quads instead of plotting pixels such artifacts occur.

    I know that some other libs to the resizing on load time, but I've decided not to for a few reasons, it messes with the patterns and takes time.

    I dont know about gamemaker, but DelphiX doesnt use the 2D in 3D approach wich is why it works there, in DelphiX state changes is not an issue either for the same reason.

    So resize the texture to the next power of two size and try again, it could be good to add a 1px border between each pattern aswell, but the latter can be helped with the texture filter as above.

    One thing to note is that the non power of two textures work good on some hardware but far from all...
    Amnoxx

    Oh, and this code appears to be an approximate replacement for return(random() & 0x01);

    Phoenix Wiki
    http://www.phoenixlib.net/

    Phoenix Forum
    http://www.pascalgamedevelopment.com/viewforum.php?f=71

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •