Reputation: 73
I'm currently trying to load a simple bitmap using XNA but I get the following error:
Error loading "Maps\standard". File contains Microsoft.Xna.Framework.Graphics.Texture2D but trying to load as System.Drawing.Bitmap.
code:
public Bitmap map;
public void load(Game game, String image) {
path = image; //path to image
map = game.Content.Load<Bitmap>("Maps/"+path);
sizeX = map.Width;
sizeY = map.Height;
}
Upvotes: 1
Views: 921
Reputation: 73
Now, I just use the C# standard
Bitmap bmp = (Bitmap)Bitmap.FromFile(path);
Upvotes: 0
Reputation: 32418
You want the below:
map = game.Content.Load<Texture2D>("Maps/"+path);
The way XNA works is that there is a content pipeline, which takes inputs (like your bitmap image) and produces outputs (the Texture2D
), which is in a different format to the input.
XNA works with a Texture2D
object when displaying images.
Upvotes: 1