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).

sbool imagesIdentical(BufferedImage img1, BufferedImage img2) {
  if (img1 == img2) true;
  if (img1 == null) ret img2 == null;
  if (img2 == null) false;
  
  int w = img1.getWidth(), h = img1.getHeight();
  if (w != img2.getWidth() || h != img2.getHeight()) false;
  
  var gp1 = grabbableIntPixels_fastOrSlow(img1);
  var gp2 = grabbableIntPixels_fastOrSlow(img2);

  int[] pixels1 = gp1.data, pixels2 = gp2.data;
  int scanlineExtra1 = gp1.scanlineStride-w;
  int scanlineExtra2 = gp2.scanlineStride-w;
  int i1 = gp1.offset, i2 = gp2.offset;

  var ping = pingSource();
  for y to h: {
    for x to w:
      if (pixels1[i1++] != pixels2[i2++])
        false;

    i1 += scanlineExtra1;
    i2 += scanlineExtra2;
    ping?!;
  }

  true;
}

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: 526 / 599
Version history: 3 change(s)
Referenced in: [show references]