-
Notifications
You must be signed in to change notification settings - Fork 449
Expand file tree
/
Copy pathGDIPlusTexture2D.cs
More file actions
49 lines (39 loc) · 1001 Bytes
/
GDIPlusTexture2D.cs
File metadata and controls
49 lines (39 loc) · 1001 Bytes
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
39
40
41
42
43
44
45
46
47
48
49
using System.Drawing;
namespace BizHawk.Bizware.Graphics
{
internal class GDIPlusTexture2D : ITexture2D
{
public Bitmap SDBitmap;
public bool LinearFiltering;
public int Width { get; }
public int Height { get; }
public bool IsUpsideDown => false;
public GDIPlusTexture2D(int width, int height)
{
Width = width;
Height = height;
SDBitmap = BitmapBuffer.CreateBitmapObject(new(width: width, height: height));
}
public virtual void Dispose()
{
SDBitmap?.Dispose();
SDBitmap = null;
}
public BitmapBuffer Resolve()
{
var blo = new BitmapLoadOptions
{
AllowWrap = false, // must be an independent resource
};
return new(SDBitmap, blo);
}
public void LoadFrom(BitmapBuffer buffer)
=> buffer.ToSysdrawingBitmap(SDBitmap);
public void SetFilterLinear()
=> LinearFiltering = true;
public void SetFilterNearest()
=> LinearFiltering = false;
public override string ToString()
=> $"GDI+ Texture2D: {Width}x{Height}";
}
}