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

20
LINES

< > BotCompany Repo | #1035716 // pixelsInImageIterator

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

Libraryless. Click here for Pure Java version (12967L/75K).

static ItIt<Pt> pixelsInImageIterator(BufferedImage image) {
  ret pixelsInImageIterator(image.getWidth(), image.getHeight());
}

static ItIt<Pt> pixelsInImageIterator(WidthAndHeight etc size) {
  int h = size.h(), w = size.w();
  ret new ItIt<Pt> {
    int x, y;
    
    public bool hasNext() {
      ret y < h && x < w;
    }
    
    public Pt next() {
      Pt p = pt(x, y);
      if (++x >= w) { x = 0; ++y; }
      ret p;
    }
  };
}

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035716
Snippet name: pixelsInImageIterator
Eternal ID of this version: #1035716/2
Text MD5: 31da95cc40f2da380b77881834c6d86c
Transpilation MD5: dd0455ba643d6c6dab4808d0d869eb24
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-07-11 21:04:32
Source code size: 460 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 150 / 197
Version history: 1 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1035857 - pixelsInImage - virtual list of Pt
#1035885 - pixelIterator - over Rect