Reputation: 7933
I am sorry that this is a little bit ambiguous. I am having an issue using System.Drawing in XNA; from my research it is not available to XNA (since its part of the windows.dll?)
I want to create a sprite sheet analyzer which automatically dissembles a sprite sheet into its proper segmentation, number of frames, etc. for later playback. For this I need to grab the actual PNG file and it would be nice to have something that already has the functionality for working with images. Is there a class in XNA which provides similar functionality as System.drawing?
Upvotes: 0
Views: 1511
Reputation: 7933
I found the answer. I can actually obtain the color data from the texture2D, allowing me to disassemble an image for analysis without using any extra libraries outside of XNA
http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2D/Texture_to_Colors.php
Upvotes: 1
Reputation: 1206
You can use System.Drawing
in conjuction with XNA with no problem -- you just have to add a reference to it in your XNA project. However, System.Drawing
does not support loading of .pngs, while XNA does.
The usual way to load images in XNA is to first add them to your content project (usually when you create an XNA project there is always a corresponding content project created). Add the saved .png to your content project and give it a unique name. Then in your code, load the image as a Texture2D
:
Texture2D myTexture = Content.Load<Texture2D>("my image name");
Note the use of Content
which is a ContentManager
object that can be referenced from the Game
object you are currently using for your XNA game.
Check this out for more information.
Upvotes: 1