MCPcopy Index your code
hub / github.com/arduino/Arduino / loadTouchBarImages

Method loadTouchBarImages

app/src/processing/app/EditorToolbar.java:228–256  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

226 }
227
228 private void loadTouchBarImages() {
229 Image allButtonsRetina = Theme.getThemeImage("buttons", this,
230 BUTTON_IMAGE_SIZE * BUTTON_COUNT * 2,
231 BUTTON_IMAGE_SIZE * 3 * 2);
232 touchBarImages = new com.thizzer.jtouchbar.common.Image[BUTTON_COUNT][3];
233
234 for (int i = 0; i < BUTTON_COUNT; i++) {
235 for (int state = 0; state < 3; state++) {
236 BufferedImage image = new BufferedImage(BUTTON_WIDTH * 2, BUTTON_HEIGHT * 2,
237 BufferedImage.TYPE_INT_ARGB);
238 Graphics g = image.getGraphics();
239
240 int offset = (BUTTON_IMAGE_SIZE * 2 - BUTTON_WIDTH * 2) / 2;
241 g.drawImage(allButtonsRetina, -(i * BUTTON_IMAGE_SIZE * 2) - offset,
242 (-2 + state) * BUTTON_IMAGE_SIZE * 2, null);
243
244 // convert the image to a PNG to display on the touch bar
245 ByteArrayOutputStream pngStream = new ByteArrayOutputStream();
246
247 try {
248 ImageIO.write(image, "PNG", pngStream);
249
250 touchBarImages[i][state] = new com.thizzer.jtouchbar.common.Image(pngStream.toByteArray());
251 } catch (IOException e) {
252 // ignore errors
253 }
254 }
255 }
256 }
257
258 @Override
259 public void paintComponent(Graphics screen) {

Callers 1

buildTouchBarMethod · 0.95

Calls 2

getThemeImageMethod · 0.95
writeMethod · 0.45

Tested by

no test coverage detected