Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

10
LINES

< > BotCompany Repo | #1004506 // invertImage - invert a BufferedImage. TODO: rescaleOp?

JavaX fragment (include)

1  
static void invertImage(BufferedImage img) {
2  
  int w = img.getWidth(), h = img.getHeight();
3  
  for (int x = 0; x < w; x++)
4  
    for (int y = 0; y < h; y++) {
5  
      int rgba = img.getRGB(x, y);
6  
      Color col = new Color(rgba, true);
7  
      col = new Color(255-col.getRed(), 255-col.getGreen(), 255-col.getBlue());
8  
      img.setRGB(x, y, col.getRGB());
9  
    }
10  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1004506
Snippet name: invertImage - invert a BufferedImage. TODO: rescaleOp?
Eternal ID of this version: #1004506/4
Text MD5: f28aa3169a2373e65b3e3f6c6df66db8
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-15 12:30:42
Source code size: 366 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 664 / 647
Version history: 3 change(s)
Referenced in: [show references]