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

18
LINES

< > BotCompany Repo | #1024564 // imageSurfaceColorPicker

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

Uses 108K of libraries. Click here for Pure Java version (9058L/65K).

// onColor is called with null value when mouse moves outside of image surface
svoid imageSurfaceColorPicker(ImageSurface is, VF1<RGB> onColor) {
  if (is == null || onColor == null) ret;
  swing {
    MouseAdapter ma = new MouseAdapter {
      public void mouseMoved(MouseEvent e) { pick(e); }
      public void mouseEntered(MouseEvent e) { pick(e); }
      public void mouseExited(MouseEvent e) { pick(null); }
      
      void pick(MouseEvent e) {
        if (e == null) callF(onColor, (RGB) null);
        else callF(onColor, bufferedImage_getRGB(is.getImage(), is.pointFromEvent(e)));
      }
    };
    is.addMouseMotionListener(ma);
    is.addMouseListener(ma);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024564
Snippet name: imageSurfaceColorPicker
Eternal ID of this version: #1024564/4
Text MD5: 69ff8d5247413dc46aefa9060ceca58b
Transpilation MD5: a3dd21e019c980ee367671645f1dc831
Author: stefan
Category: javax / image analysis
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-18 14:52:56
Source code size: 692 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 223 / 309
Version history: 3 change(s)
Referenced in: [show references]