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?

j3d
  • 9,492
  • 22
  • 88
  • 172
  • Check out http://stackoverflow.com/questions/7574307/c-sharp-read-byte-array-from-resource – Matthew Aug 13 '12 at 16:44
  • Your current method is probably the most compact and efficient... – H H Aug 13 '12 at 16:44
  • In the realm of what is possible, you could create a partial class: http://msdn.microsoft.com/en-us/library/wa80x488(v=vs.80).aspx. But I imagine that a resource file would be a better approach :) – Pooven Aug 13 '12 at 16:53
  • @HenkHolterman ...but probably the less maintainable. Images should be embedded in the XAP as resources. – ken2k Aug 13 '12 at 16:54
  • @ken2k - normally yes but this is XNA. Performance usually trumps everything. – H H Aug 14 '12 at 20:42

0 Answers0