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

23
LINES

< > BotCompany Repo | #1035938 // PixelSetsEqual - test if pixel sets are equal

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

Libraryless. Click here for Pure Java version (9740L/55K).

1  
srecord noeq PixelSetsEqual(IPixelSet set1, IPixelSet set2) {
2  
  // pixel sets are technically identical with differing bounds
3  
  settable bool boundsMustBeEqual = true;
4  
  
5  
  gettable Pt firstDifferingPixel;
6  
  
7  
  bool get() {
8  
    if (set1 == null) ret set2 == null;
9  
    if (set2 == null) false;
10  
    
11  
    Rect r = set1.bounds();
12  
    if (boundsMustBeEqual && !eq(r, set2.bounds())) false;
13  
    
14  
    for (int y = r.y(); y < r.y2(); y++)
15  
      for (int x = r.x(); x < r.x2(); x++)
16  
        if (set1.contains(x, y) != set2.contains(x, y)) {
17  
          firstDifferingPixel = pt(x, y);
18  
          false;
19  
        }
20  
        
21  
    true;
22  
  }
23  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035938
Snippet name: PixelSetsEqual - test if pixel sets are equal
Eternal ID of this version: #1035938/1
Text MD5: 44c23f5bcbae3b6b610e3a83c0fbd09a
Transpilation MD5: b7672bd83732d893d967166371d50c26
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-15 20:14:56
Source code size: 647 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 163 / 218
Referenced in: [show references]