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

24
LINES

< > BotCompany Repo | #1034815 // HashBWImage - makes a 64 bit hash of an BWImage (compatible with HashBufferedImage)

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

Libraryless. Click here for Pure Java version (10614L/61K).

1  
srecord noeq HashBWImage(BWImage img) {
2  
  long hash;
3  
  
4  
  long get() {
5  
    if (img == null) ret hash;
6  
    
7  
    int w = img.getWidth(), h = img.getHeight();
8  
    int n = w*h;
9  
    byte[] pixels = img.pixels;
10  
11  
    addToHash(w);
12  
    addToHash(h);
13  
    
14  
    for i to n:
15  
      addToHash(0xFF000000 | rgbIntFromGrayscale(ubyteToInt(pixels[i])));
16  
17  
    ret hash;
18  
  }
19  
  
20  
  void addToHash(long x) {
21  
    hash = boostHashCombine64(hash, x);
22  
    printVars ifdef HashBWImage_debug(x := longToHex(x), +hash);
23  
  }
24  
}

Author comment

Began life as a copy of #1034798

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034815
Snippet name: HashBWImage - makes a 64 bit hash of an BWImage (compatible with HashBufferedImage)
Eternal ID of this version: #1034815/7
Text MD5: b878e2b6f75e654bd7f9cfbb03000f13
Transpilation MD5: 6289a0d9c3100f31ca6ae4558e9f0cf9
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 22:57:47
Source code size: 519 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 91 / 149
Version history: 6 change(s)
Referenced in: [show references]