get Data from PixelBitmapContent - CSharp System.Drawing

CSharp examples for System.Drawing:Bitmap

Description

get Data from PixelBitmapContent

Demo Code


using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
using System;//from w  w w.  j a va 2s .  c o  m

public class Main{
    public static Color[] getData( this PixelBitmapContent<Color> self )
      {
         var data = new Color[self.Width * self.Height];
         var i = 0;
         for( var y = 0; y < self.Height; y++ )
         {
            for( var x = 0; x < self.Width; x++ )
               data[i++] = self.GetPixel( x, y );
         }

         return data;
      }
}

Related Tutorials