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

24
LINES

< > BotCompany Repo | #1033124 // imagePixelsToRGBAWithSize_virtualIntList

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4216L/24K).

1  
static L<Int> imagePixelsToRGBAWithSize_virtualIntList(BufferedImage etc img) {
2  
  if (img == null) null;
3  
  int w = img.getWidth(), h = img.getHeight(), n = w*h+2;
4  
5  
  ret new RandomAccessAbstractList<Int>() {
6  
    public int size() { ret n; }
7  
    
8  
    public Int get(int i) {
9  
      if (i == 0) ret w;
10  
      if (i == 1) ret h;
11  
      i -= 2;
12  
      ret img.getRGB(i % w, i / w);
13  
    }
14  
    
15  
    public Int set(int i, Int val) {
16  
      if (i < 2) fail();
17  
      i -= 2;
18  
      int old = img.getRGB(i % w, i / w);
19  
      if (old != (int) val)
20  
        img.setRGB(i % w, i / w, val);
21  
      ret old;
22  
    }
23  
  };
24  
}

Author comment

Began life as a copy of #1033069

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033124
Snippet name: imagePixelsToRGBAWithSize_virtualIntList
Eternal ID of this version: #1033124/3
Text MD5: 77a6e8a56b0aea839023927758c7900d
Transpilation MD5: ce6b3bb51eb2432800f34f40b9746685
Author: stefan
Category: javax / compression /pattern recognition
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-15 16:47:13
Source code size: 620 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 167 / 223
Version history: 2 change(s)
Referenced in: [show references]