-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathMaterial.cs
28 lines (26 loc) · 835 Bytes
/
Material.cs
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
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Drawing;
using System.IO;
namespace ConsoleGraphics
{
class Material
//convert textures
{
public byte[,] bitmapColorsCached;
public int SIZE;
public Material(string fileName)
{
Bitmap sourceBmp = (Bitmap)Image.FromFile(fileName, true);//load character set (digits 1->9..)
bitmapColorsCached = new byte[sourceBmp.Width, sourceBmp.Height];
SIZE = sourceBmp.Width;
for (int i = 0; i < sourceBmp.Width; i++)
for (int j = 0; j < sourceBmp.Height; j++)
{
Color c = sourceBmp.GetPixel(i, j);
bitmapColorsCached[i,j] = (byte)((c.R + c.B + c.G) / 3);
}
}
}
}