1

I have an array that contains a default texture for a sprite like this:

uint[] bitmap = new uint[] {
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    ...
};

Texture2D texture = new Texture2D(
    GameHost.GraphicsDevice,
    (int) Math.Sqrt(bitmap.Length),
    (int) Math.Sqrt(bitmap.Length),
    false, SurfaceFormat.Color);

    texture.SetData<uint>(bitmap, 0, bitmap.Length);

Is there a way to include an external text file that contains the bitmap data? Or, as an alternative, I should add a resource... But how could I embed such a resource in my XNA DLL for WindowsPhone?

5
  • Check out stackoverflow.com/questions/7574307/… Commented Aug 13, 2012 at 16:44
  • Your current method is probably the most compact and efficient... Commented Aug 13, 2012 at 16:44
  • In the realm of what is possible, you could create a partial class: msdn.microsoft.com/en-us/library/wa80x488(v=vs.80).aspx. But I imagine that a resource file would be a better approach :) Commented Aug 13, 2012 at 16:53
  • @HenkHolterman ...but probably the less maintainable. Images should be embedded in the XAP as resources. Commented Aug 13, 2012 at 16:54
  • @ken2k - normally yes but this is XNA. Performance usually trumps everything. Commented Aug 14, 2012 at 20:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.