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

sbool binaryImagesIdentical(IBinaryImage img1, IBinaryImage 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;
  
  ret binaryImagesIdentical(img1.toImage2B(), img2.toImage2B());
}

sbool binaryImagesIdentical(Image2B img1, Image2B 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;
  
  byte[] pixels1 = img1.pixels, pixels2 = img2.pixels;
  ret Arrays.equals(pixels1, pixels2);
}

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: 116 / 163
Referenced in: [show references]