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

srecord noeq PixelSetsEqual(IPixelSet set1, IPixelSet set2) {
  // pixel sets are technically identical with differing bounds
  settable bool boundsMustBeEqual = true;
  
  gettable Pt firstDifferingPixel;
  
  bool get() {
    if (set1 == null) ret set2 == null;
    if (set2 == null) false;
    
    Rect r = set1.bounds();
    if (boundsMustBeEqual && !eq(r, set2.bounds())) false;
    
    for (int y = r.y(); y < r.y2(); y++)
      for (int x = r.x(); x < r.x2(); x++)
        if (set1.contains(x, y) != set2.contains(x, y)) {
          firstDifferingPixel = pt(x, y);
          false;
        }
        
    true;
  }
}

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: 162 / 216
Referenced in: #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167)