|
| static Texture2D | LoadPNG (string _path, FilterMode filter=FilterMode.Point) |
| |
| static Texture2D | Load (string _path, FilterMode filter, Vector2Int? mipmap) |
| |
| static byte[] | ReadImageFile (string _path) |
| |
Definition at line 4 of file ImageLoader.cs.
◆ IsJpeg()
| static bool ImageLoader.IsJpeg |
( |
byte[] |
data | ) |
|
|
inlinestaticprivate |
Definition at line 69 of file ImageLoader.cs.
70 {
71 if (data.Length >= 2 && data[0] == byte.MaxValue)
72 {
73 return data[1] == 216;
74 }
75 return false;
76 }
Referenced by Load().
◆ IsPng()
| static bool ImageLoader.IsPng |
( |
byte[] |
data | ) |
|
|
inlinestaticprivate |
Definition at line 60 of file ImageLoader.cs.
61 {
62 if (data.Length >= 8 && data[0] == 137 && data[1] == 80 && data[2] == 78 && data[3] == 71 && data[4] == 13 && data[5] == 10 && data[6] == 26)
63 {
64 return data[7] == 10;
65 }
66 return false;
67 }
Referenced by Load().
◆ IsSofMarker()
| static bool ImageLoader.IsSofMarker |
( |
byte |
marker | ) |
|
|
inlinestaticprivate |
Definition at line 141 of file ImageLoader.cs.
142 {
143 switch (marker)
144 {
145 case 192:
146 case 193:
147 case 194:
148 case 195:
149 case 197:
150 case 198:
151 case 199:
152 case 201:
153 case 202:
154 case 203:
155 case 205:
156 case 206:
157 case 207:
158 return true;
159 default:
160 return false;
161 }
162 }
Referenced by TryGetJpegSize().
◆ Load()
| static Texture2D ImageLoader.Load |
( |
string |
_path, |
|
|
FilterMode |
filter, |
|
|
Vector2Int? |
mipmap |
|
) |
| |
|
inlinestatic |
Definition at line 11 of file ImageLoader.cs.
12 {
13 if (!File.Exists(_path))
14 {
15 return null;
16 }
18 if (array == null || array.Length < 8)
19 {
20 return null;
21 }
22 int width;
23 int height;
25 {
27 {
28 return null;
29 }
30 }
31 else
32 {
34 {
35 return null;
36 }
38 {
39 return null;
40 }
41 }
43 bool flag = mipmap.HasValue && (width > mipmap.Value.x || height > mipmap.Value.y);
44 Texture2D texture2D =
new Texture2D(width, height, data.
format, data.
mipmap || flag, data.
linear);
45 texture2D.LoadImage(array);
47 texture2D.filterMode = (flag ? FilterMode.Trilinear : filter);
50 return texture2D;
51 }
static TextureImportSetting.Data importSetting
static bool TryGetJpegSize(byte[] data, out int width, out int height)
static bool TryGetPngSize(byte[] data, out int width, out int height)
static bool IsPng(byte[] data)
static byte[] ReadImageFile(string _path)
static bool IsJpeg(byte[] data)
References TextureImportSetting.Data.anisoLevel, TextureImportSetting.Data.format, IsJpeg(), IsPng(), TextureImportSetting.Data.linear, TextureImportSetting.Data.mipmap, TextureImportSetting.Data.mipmapBias, ReadImageFile(), TryGetJpegSize(), TryGetPngSize(), and TextureImportSetting.Data.wrapMode.
Referenced by IO.LoadObject< T >(), and LoadPNG().
◆ LoadPNG()
| static Texture2D ImageLoader.LoadPNG |
( |
string |
_path, |
|
|
FilterMode |
filter = FilterMode::Point |
|
) |
| |
|
inlinestatic |
Definition at line 6 of file ImageLoader.cs.
7 {
8 return Load(_path, filter,
null);
9 }
static Texture2D Load(string _path, FilterMode filter, Vector2Int? mipmap)
References Load().
Referenced by IO.LoadPNG().
◆ ReadImageFile()
| static byte[] ImageLoader.ReadImageFile |
( |
string |
_path | ) |
|
|
inlinestatic |
Definition at line 53 of file ImageLoader.cs.
54 {
55 using FileStream input = new FileStream(_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
56 using BinaryReader binaryReader = new BinaryReader(input);
57 return binaryReader.ReadBytes((int)binaryReader.BaseStream.Length);
58 }
Referenced by Load().
◆ ReadIntBigEndian()
| static int ImageLoader.ReadIntBigEndian |
( |
byte[] |
data, |
|
|
int |
offset |
|
) |
| |
|
inlinestaticprivate |
Definition at line 164 of file ImageLoader.cs.
165 {
166 if (offset + 3 >= data.Length)
167 {
168 return 0;
169 }
170 return ((data[offset] & 0xFF) << 24) | ((data[offset + 1] & 0xFF) << 16) | ((data[offset + 2] & 0xFF) << 8) | (data[offset + 3] & 0xFF);
171 }
Referenced by TryGetPngSize().
◆ TryGetJpegSize()
| static bool ImageLoader.TryGetJpegSize |
( |
byte[] |
data, |
|
|
out int |
width, |
|
|
out int |
height |
|
) |
| |
|
inlinestaticprivate |
Definition at line 94 of file ImageLoader.cs.
95 {
96 width = (height = 0);
97 int i = 2;
98 while (i + 1 < data.Length)
99 {
100 if (data[i] != byte.MaxValue)
101 {
102 i++;
103 continue;
104 }
105 for (; i < data.Length && data[i] == byte.MaxValue; i++)
106 {
107 }
108 if (i >= data.Length)
109 {
110 break;
111 }
112 byte b = data[i++];
113 if (b == 218 || b == 217 || i + 1 >= data.Length)
114 {
115 break;
116 }
117 int num = (data[i] << 8) | data[i + 1];
118 if (num < 2)
119 {
120 return false;
121 }
123 {
124 if (i + 7 >= data.Length)
125 {
126 return false;
127 }
128 height = (data[i + 3] << 8) | data[i + 4];
129 width = (data[i + 5] << 8) | data[i + 6];
130 if (width > 0)
131 {
132 return height > 0;
133 }
134 return false;
135 }
136 i += num;
137 }
138 return false;
139 }
static bool IsSofMarker(byte marker)
References IsSofMarker().
Referenced by Load().
◆ TryGetPngSize()
| static bool ImageLoader.TryGetPngSize |
( |
byte[] |
data, |
|
|
out int |
width, |
|
|
out int |
height |
|
) |
| |
|
inlinestaticprivate |
Definition at line 78 of file ImageLoader.cs.
79 {
80 width = (height = 0);
81 if (data.Length < 24)
82 {
83 return false;
84 }
87 if (width > 0)
88 {
89 return height > 0;
90 }
91 return false;
92 }
static int ReadIntBigEndian(byte[] data, int offset)
References ReadIntBigEndian().
Referenced by Load().
The documentation for this class was generated from the following file: