XNA Creators Club Online
Page 1 of 1 (5 items)
Sort Posts: Previous Next

Image Scaling Method

Last post 9/1/2009 5:17 AM by AndrewFM. 4 replies.
  • 8/31/2009 9:41 PM

    Image Scaling Method

    Is there a way to change the method the GraphicsDevice uses to scale a Texture2D sprite? By default, when you scale up a sprite, the individual pixels begin to get blurred. Instead, I would rather the sprite to be "pixel resized".

    So say you have this sprite:


    By default, when scaled, it'll look something like this:


    While I want it to look like this:

  • 8/31/2009 11:15 PM In reply to

    Re: Image Scaling Method

    If you want that, you'll have to write the scaling code yourself. I would just have two different textures, one at each size.
    Jim Perry - Microsoft XNA MVP
    If people spent a minute searching the forums and reading the FAQs before posting I'd be out of a job.
      Got some XNA Game Studio/XNA Framework development info to share with the community? Put it on the XNA Wiki.
        Please mark posts as Answers or Good Feedback when appropriate.
  • 8/31/2009 11:37 PM In reply to

    Re: Image Scaling Method

    Just set the filter mode of the texture sampler to NEAREST and you'll be good.
    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
  • 9/1/2009 3:29 AM In reply to

    Re: Image Scaling Method

    Here's the code for what you want. Works great.
    http://forums.xna.com/forums/p/4184/21267.aspx#21267
  • 9/1/2009 5:17 AM In reply to

    Re: Image Scaling Method

    Thanks a bunch; works great.
Page 1 of 1 (5 items) Previous Next