UltimateZoneBuilder/Source/Data/FileImage.cs

80 lines
1.6 KiB
C#
Raw Normal View History

2007-10-01 20:57:41 +00:00
#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
#endregion
namespace CodeImp.DoomBuilder.Data
{
2007-10-24 17:25:03 +00:00
public sealed class FileImage : ImageData
2007-10-01 20:57:41 +00:00
{
#region ================== Variables
private string filepathname;
#endregion
#region ================== Constructor / Disposer
// Constructor
2007-10-27 13:59:24 +00:00
public FileImage(string name, string filepathname)
2007-10-01 20:57:41 +00:00
{
// Initialize
this.filepathname = filepathname;
2007-10-27 13:59:24 +00:00
SetName(name);
2007-10-01 20:57:41 +00:00
// We have no destructor
GC.SuppressFinalize(this);
}
#endregion
#region ================== Methods
// This loads the image
public override void LoadImage()
{
// Leave when already loaded
if(this.IsLoaded) return;
lock(this)
{
// Load file
bitmap = (Bitmap)Bitmap.FromFile(filepathname);
2007-11-10 19:24:52 +00:00
// Get width and height from image
width = bitmap.Size.Width;
height = bitmap.Size.Height;
// Pass on to base
base.LoadImage();
}
2007-10-01 20:57:41 +00:00
}
#endregion
}
}