BitmapCache.cs
952 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class BitmapCache
{
static Dictionary<string, Bitmap> Store = new Dictionary<string, Bitmap>();
public static void AddBmp(string name, Bitmap bitmap) {
Store[name] = bitmap;
}
public static Bitmap GetBmp(string name) {
if (!Store.ContainsKey(name))
return null;
return Store[name];
}
public static bool HasBmp(string name)
{
return Store.ContainsKey(name);
}
public static void RemoveBmp(string name)
{
if (!Store.ContainsKey(name))
return;
try
{
Store[name].Dispose();
}
catch { }
Store.Remove(name);
}
}
}