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

Spritesheet sample: broken for small sprites

Last post 8/15/2008 10:34 PM by Charles Cox. 14 replies.
  • 1/28/2008 8:34 AM

    Spritesheet sample: broken for small sprites

    Hi all,

    I have managed to break the Spritesheet sample - it does not seem to like single/few small sprites. With either a single 32x64 sprite or two sprites of this size it borks out with the error printed at the bottom of this post. It will work with 3 sprites of this size, OR two sprites if one of them is larger. Is there a minimum size for the spritesheet, or is it something i am doing wrong?

    (Also, i'd like to push the spritesheetpipeline and spritesheetruntime into a "utility library" instead of having them seperate projects; is this possible?)

    Thanks,

     

    Eljay.

    Error reported:

     

    Error 1 Building content threw ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    Parameter name: destinationRegion
       at Microsoft.Xna.Framework.Content.Pipeline.Graphics.BitmapContent.ValidateCopyArguments(BitmapContent sourceBitmap, Rectangle sourceRegion, BitmapContent destinationBitmap, Rectangle destinationRegion)
       at Microsoft.Xna.Framework.Content.Pipeline.Graphics.BitmapContent.Copy(BitmapContent sourceBitmap, Rectangle sourceRegion, BitmapContent destinationBitmap, Rectangle destinationRegion)
       at SpriteSheetPipeline.SpritePacker.CopySpritesToOutput(List`1 sprites, IList`1 sourceSprites, ICollection`1 outputSprites, Int32 width, Int32 height) in C:\Documents and Settings\Jon\My Documents\Visual Studio 2005\Projects\BattleMap\SpriteSheetSample\SpriteSheetPipeline\SpritePacker.cs:line 107
       at SpriteSheetPipeline.SpritePacker.PackSprites(IList`1 sourceSprites, ICollection`1 outputSprites, ContentProcessorContext context) in C:\Documents and Settings\Jon\My Documents\Visual Studio 2005\Projects\BattleMap\SpriteSheetSample\SpriteSheetPipeline\SpritePacker.cs:line 80
       at SpriteSheetPipeline.SpriteSheetProcessor.Process(String[] input, ContentProcessorContext context) in C:\Documents and Settings\Jon\My Documents\Visual Studio 2005\Projects\BattleMap\SpriteSheetSample\SpriteSheetPipeline\SpriteSheetProcessor.cs:line 57
       at Microsoft.Xna.Framework.Content.Pipeline.ContentProcessor`2.Microsoft.Xna.Framework.Content.Pipeline.IContentProcessor.Process(Object input, ContentProcessorContext context)
       at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAssetWorker(BuildItem item)
       at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAsset(BuildItem item)
       at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.RunTheBuild()
       at Microsoft.Xna.Framework.Content.Pipeline.Tasks.BuildContent.RemoteProxy.RunTheBuild(BuildCoordinatorSettings settings, TimestampCache timestampCache, ITaskItem[] sourceAssets, String[]& outputContent, String[]& rebuiltContent, String[]& intermediates, Dictionary`2& dependencyTimestamps, KeyValuePair`2[]& warnings) D:\JF\Projects\BattleMap\BattleMap\Content\SpriteSheets\otherSprites.xml BattleMap

  • 1/29/2008 12:13 PM In reply to

    Re: Spritesheet sample: broken for small sprites

    Eljay-

    If it's throwing a ArgumentOutOfRangeException on destinationRegion, then the next thing for you to determine is...

    what is the value of destinationRegion that you are passing it.

    If you can't debug the content pipeline easily, you can just catch that exception and add a more descriptive message to it that includes the destinationRegion, and maybe the target texture dimensions.

    5$ says that your destinationRegion really is invalid.
  • 1/30/2008 8:39 AM In reply to

    Re: Spritesheet sample: broken for small sprites

    Hmm...

    Yeah, that was my first thought, although i the error is thrown from:

    tileSprites = content.Load<SpriteSheet>
       ("Content\\SpriteSheets\\tileSprites");
    So the destinationRegion variable is one which is generated by the spritesheet libraries themselves as opposed to something i've specified. I've not used "catch" before (Although i do recall reading about it in a book some time ago!) I will give this a try as you suggested. Tnx.
  • 2/1/2008 6:55 PM In reply to

    Re: Spritesheet sample: broken for small sprites

    I can't reproduce this crash. Here's what I tried:
    • Took the version of the sample from the website
    • Removed all sprites except the cat from the spritesheet XML file
    • Resized the cat texture to be 32x64
    • Built the project, and ran it on Windows
    • As expected, it threw an exception when it came to draw the glow sprites that I had removed
    • Commented out the code that draws the glow sprites
    • Now it runs ok, drawing the stretched cat sprite

    Can you give any more hints on how to reproduce the crash you are seeing, or perhaps upload a copy of your project that demonstrates this?

    Thanks,
    XNA Framework Developer - blog - homepage
  • 2/4/2008 8:44 AM In reply to

    Re: Spritesheet sample: broken for small sprites

    That particular build is not currrently availabe - i've significantly played with it since... however, I have reproduced the problem in a replacement project (ie a re-write i have just started). I have two 128x128 bitmaps in the XML file. Remove one and the error re-occurs. Where can I upload a copy to ? (130kb, zipped)
  • 2/4/2008 1:30 PM In reply to

    Re: Spritesheet sample: broken for small sprites

    I know there are some hosting sites where you can upload projects, but don't remember the URLs: can anyone else chime in here?

    I'd definately like to take a look at this project, so I can figure out what is wrong with our sample code, and what's different between your version and when I tried to repro it.
    XNA Framework Developer - blog - homepage
  • 2/4/2008 3:31 PM In reply to

    Re: Spritesheet sample: broken for small sprites

  • 2/5/2008 11:26 AM In reply to

    Re: Spritesheet sample: broken for small sprites

  • 2/5/2008 8:31 PM In reply to

    Re: Spritesheet sample: broken for small sprites

    Hmm, that site isn't working for me - it's complaining something about a download limit being reached?

    Another option is if you file a bug on the Connect site (http://forums.xna.com/thread/1864.aspx) I believe you can attach files to the bug report there. Post the bug number back here and I should be able to grab the bits from that.
    XNA Framework Developer - blog - homepage
  • 2/6/2008 4:23 AM In reply to

    Re: Spritesheet sample: broken for small sprites

    Reported with bug ID 327379

  • 2/6/2008 10:23 AM In reply to

    Re: Spritesheet sample: broken for small sprites

    Weird, i downloaded it ok :s

  • 2/6/2008 12:22 PM In reply to

    Re: Spritesheet sample: broken for small sprites

    Got it, and reproduced the issue. Thanks a lot for the help with this!

    Here's a quick workaround, pending us getting a proper fix up on the site:

    In SpritePacket.cs, change line 264 to:

        int width = Math.Max((int)Math.Sqrt(totalSize), maxWidth + 2);

    XNA Framework Developer - blog - homepage
  • 2/7/2008 7:49 AM In reply to

    Re: Spritesheet sample: broken for small sprites

    Glad to help...

    Just glad it didn't turn out to be "Problem Exists Between Chair And Keboard"

    Eljay.

  • 3/27/2008 8:58 AM In reply to

    Re: Spritesheet sample: broken for small sprites

    I just had the same problem.. You guy's might want to put something up on the SpriteSheet example page about this!
  • 8/15/2008 10:34 PM In reply to

    Re: Spritesheet sample: broken for small sprites

    The proper fix is now up on the site! :) If you re-download the Sprite Sheet sample, the problem is fixed.

    Thanks,
    Charles Cox

    Charles Cox
    XNA Community Content Producer | Microsoft
    http://www.the-agent.net
Page 1 of 1 (15 items) Previous Next