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

22
LINES

< > BotCompany Repo | #1035838 // binaryImagesIdentical

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

Libraryless. Click here for Pure Java version (10950L/62K).

1  
sbool binaryImagesIdentical(IBinaryImage img1, IBinaryImage 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  
  ret binaryImagesIdentical(img1.toImage2B(), img2.toImage2B());
10  
}
11  
12  
sbool binaryImagesIdentical(Image2B img1, Image2B img2) {
13  
  if (img1 == img2) true;
14  
  if (img1 == null) ret img2 == null;
15  
  if (img2 == null) false;
16  
  
17  
  int w = img1.getWidth(), h = img1.getHeight();
18  
  if (w != img2.getWidth() || h != img2.getHeight()) false;
19  
  
20  
  byte[] pixels1 = img1.pixels, pixels2 = img2.pixels;
21  
  ret Arrays.equals(pixels1, pixels2);
22  
}

Author comment

Began life as a copy of #1034813

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035838
Snippet name: binaryImagesIdentical
Eternal ID of this version: #1035838/1
Text MD5: 81406a7048399f1fc171119f8f508417
Transpilation MD5: a831aca0f031f92ca5adbe0c91f959a0
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-02 19:22:58
Source code size: 722 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 118 / 167
Referenced in: [show references]