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

29
LINES

< > BotCompany Repo | #1007053 // imagesIdentical

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

Libraryless. Click here for Pure Java version (8004L/45K).

1  
sbool imagesIdentical(BufferedImage img1, BufferedImage img2) {
2  
  if (img1 == img2) true;
3  
  if (img1 == null) ret img2 == null;
4  
  if (img2 == null) false;
5  
  
6  
  int w = img1.getWidth(), h = img1.getHeight();
7  
  if (w != img2.getWidth() || h != img2.getHeight()) false;
8  
  
9  
  var gp1 = grabbableIntPixels_fastOrSlow(img1);
10  
  var gp2 = grabbableIntPixels_fastOrSlow(img2);
11  
12  
  int[] pixels1 = gp1.data, pixels2 = gp2.data;
13  
  int scanlineExtra1 = gp1.scanlineStride-w;
14  
  int scanlineExtra2 = gp2.scanlineStride-w;
15  
  int i1 = gp1.offset, i2 = gp2.offset;
16  
17  
  var ping = pingSource();
18  
  for y to h: {
19  
    for x to w:
20  
      if (pixels1[i1++] != pixels2[i2++])
21  
        false;
22  
23  
    i1 += scanlineExtra1;
24  
    i2 += scanlineExtra2;
25  
    ping?!;
26  
  }
27  
28  
  true;
29  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1007053
Snippet name: imagesIdentical
Eternal ID of this version: #1007053/4
Text MD5: ac07da04796a9bafd6c0fe59d26bf848
Transpilation MD5: 6af09630d59b1724450216200aa888b0
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-10 19:44:09
Source code size: 771 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 527 / 600
Version history: 3 change(s)
Referenced in: [show references]