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

37
LINES

< > BotCompany Repo | #1033519 // IIImageSurface - Image Surface showing integral image

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

Libraryless. Click here for Pure Java version (17327L/106K).

sclass IIImageSurface extends ImageSurface {
  IBWIntegralImage ii;

  *() {}
  
  *(IBWIntegralImage *ii) {}
  *(IBWIntegralImage *ii, BufferedImage img) { super(img); }
  
  void drawImageItself(int w, int h, Graphics2D g) {
    if (ii == null)
      ret with super.drawImageItself(w, h, g);
      
    int iw = getZoomedWidth(), ih = getZoomedHeight();
    
    Rect r = toRect(getVisibleRect());
    //_print(visibleRect := r);
    
    // TODO: scale only the visible part
    //var scaled = scaledGrayImageFromBWIntegralImage(ii, iw, ih);
    var scaled = scaledGrayImageFromBWIntegralImage_clip(ii, doubleRatio(iw, ii.getWidth()), r);
    g.drawImage(scaled, r.x, r.y, null);
  }
  
  public void setImage(BufferedImage img) {
    ii = null;
    super.setImage(img);
  }
  
  void setImage(BWIntegralImage ii, BufferedImage img default null) {
    this.ii = ii;
    super.setImage(img);
  }
  
  bool hasImage() { ret ii != null || image != null; }
  int w() { ret ii != null ? ii.getWidth() : super.w(); }
  int h() { ret ii != null ? ii.getHeight() : super.h(); }
}

Author comment

Began life as a copy of #1004553

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1033519
Snippet name: IIImageSurface - Image Surface showing integral image
Eternal ID of this version: #1033519/21
Text MD5: a571c6207c693ddb028ae17bc3c7c1ad
Transpilation MD5: 60c706f9a653baf014cb18b7d863df66
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-12-25 23:06:00
Source code size: 1110 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 199 / 308
Version history: 20 change(s)
Referenced in: #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)