I have found the problem.
This is the solution. (you don't find any solutions for this problem).
private Device device;
private Texture texture;
private Material material;
private Sprite sprite;
Surface s;
SurfaceDescription desc;
public Form1()
{
InitializeComponent();
this.SetStyle(ControlStyles.AllPaintingInWmPaint |
ControlStyles.Opaque, true);
}
public void InitializeDevice()
{
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
presentParams.AutoDepthStencilFormat = DepthFormat.D16;
presentParams.EnableAutoDepthStencil = true;
device = new Device(0, DeviceType.Hardware, this,
CreateFlags.SoftwareVertexProcessing, presentParams);
sprite = new Sprite(device);
device.RenderState.Lighting = false;
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
device.RenderState.AlphaBlendEnable = true;
device.RenderState.AlphaTestEnable = false;
device.RenderState.SourceBlend = Blend.SourceAlpha;
device.RenderState.DestinationBlend = Blend.InvSourceAlpha;
device.Clear(ClearFlags.Target, Color.Blue, 1.0f, 0);
device.BeginScene();
sprite.Begin(SpriteFlags.AlphaBlend);
sprite.Draw2D(texture, new Point(0,0),0, new Point(0,0),
Color.White);
device.RenderState.AlphaBlendEnable = false;
sprite.End();
device.EndScene();
device.Present();
this.Invalidate();
}
public void LoadTexturesAndMaterials()
{
material = new Material();
material.Diffuse = Color.White;
material.Specular = Color.LightGray;
material.SpecularSharpness = 15.0F;
device.Material = material;
string path = Application.StartupPath;
texture = TextureLoader.FromFile(device, @path + "\\image.png"
);
s = texture.GetSurfaceLevel(0);
desc = s.Description;
}