   [XNA] Texture2D load optimalization
  Hello, i've compared some codes loading image (png) from file to Texture2D objectAnd the fastest of them was:System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(System.Drawing.Image.FromFile(files));Texture2D customTexture = new Texture2D(graphics.GraphicsDevice, bitmap.Width, bitmap.Height, 0, TextureUsage.None, SurfaceFormat.Color);System.Drawing.Imaging.BitmapData data =    bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, bitmap.PixelFormat);byte[] bytes = new byte[data.Height * data.Stride];Marshal.Copy(data.Scan0, bytes, 0, bytes.Length);customTexture.SetData(bytes);bitmap.UnlockBits(data);FromFile takes about 1000-2000 seconds to load 20 images, iterating through pixels takes about 900ms and function above takes 700ms.Well this is not bad but loading these files into (System.Drawing) Bitmap takes 500ms and to Image about 140ms wich is stunning result.Isn't there any way to copy textures from Image and not Bitmap?   
  This isn't surprising, since the Texture2D file loader typically does a lot more than just load the raw image data (such as scaling to power-of-2 dimensions and mipmap generation).Also the Bitmap class has a constructor that takes a file path.   ;  If you want really fast file loading use the DirectX standard .dds file format, ideally with DXT compression to make the file much smaller. That should result a minimal quantity of work to do other than reading in the file.The texture tool that comes with the SDK can create .dds files.   ;  Well there is no way to use other formats, since it will be image viewer, it would be useless without support of png,bmp,jpgEDIT:texture won't load if image is not a bitmap, when i try to set data it gives me an error:The size of the data passed in is too large or too small for this resource.[Source="C#"]System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(files);[/Source] [Edited by - oracle1 on April 13, 2010 3:27:26 PM]