MCPcopy Create free account
hub / github.com/DGVPSH/SlackOpen / readColors

Method readColors

src/main/java/net/optifine/CustomColormap.java:192–245  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

190 }
191
192 private void readColors()
193 {
194 try
195 {
196 this.colors = null;
197
198 if (this.source == null)
199 {
200 return;
201 }
202
203 String s = this.source + ".png";
204 ResourceLocation resourcelocation = new ResourceLocation(s);
205 InputStream inputstream = Config.getResourceStream(resourcelocation);
206
207 if (inputstream == null)
208 {
209 return;
210 }
211
212 BufferedImage bufferedimage = TextureUtil.readBufferedImage(inputstream);
213
214 if (bufferedimage == null)
215 {
216 return;
217 }
218
219 int i = bufferedimage.getWidth();
220 int j = bufferedimage.getHeight();
221 boolean flag = this.width < 0 || this.width == i;
222 boolean flag1 = this.height < 0 || this.height == j;
223
224 if (!flag || !flag1)
225 {
226 dbg("Non-standard palette size: " + i + "x" + j + ", should be: " + this.width + "x" + this.height + ", path: " + s);
227 }
228
229 this.width = i;
230 this.height = j;
231
232 if (this.width <= 0 || this.height <= 0)
233 {
234 warn("Invalid palette size: " + i + "x" + j + ", path: " + s);
235 return;
236 }
237
238 this.colors = new int[i * j];
239 bufferedimage.getRGB(0, 0, i, j, this.colors, 0, i);
240 }
241 catch (IOException ioexception)
242 {
243 ioexception.printStackTrace();
244 }
245 }
246
247 private static void dbg(String str)
248 {

Callers 1

isValidMethod · 0.95

Calls 7

getResourceStreamMethod · 0.95
readBufferedImageMethod · 0.95
dbgMethod · 0.95
warnMethod · 0.95
getRGBMethod · 0.80
getWidthMethod · 0.45
getHeightMethod · 0.45

Tested by

no test coverage detected