Libraryless. Click here for Pure Java version (9267L/52K).
// undefined color, seems to be all black in practice // This is without alpha? static BufferedImage newBufferedImage(int w, int h) { ret new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); } ifclass RGB static BufferedImage newBufferedImage(int w, int h, RGB rgb) { ret newBufferedImage(w, h, rgb.getColor()); } endif static BufferedImage newBufferedImage(int w, int h, Color color) { BufferedImage img = newBufferedImage(w, h); Graphics2D g = img.createGraphics(); g.setColor(or(color, Color.white)); g.fillRect(0, 0, w, h); ret img; } ifclass Pt static BufferedImage newBufferedImage(Pt p, Color color) { ret newBufferedImage(p.x, p.y, color); } endif ifclass WidthAndHeight static BufferedImage newBufferedImage(WidthAndHeight size, Color color) { ret newBufferedImage(size.w(), size.h(), color); } endif // This one is with alpha... static BufferedImage newBufferedImage(int w, int h, int[] pixels) { ret intArrayToBufferedImage(pixels, w, h); }
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1006917 |
Snippet name: | newBufferedImage |
Eternal ID of this version: | #1006917/14 |
Text MD5: | 2cf9c9696d58e43419783df2d5df7da6 |
Transpilation MD5: | 20bad3e80ecd33210cef214a8ee703e4 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-08-17 18:10:33 |
Source code size: | 1011 bytes / 36 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 600 / 724 |
Version history: | 13 change(s) |
Referenced in: | [show references] |