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

30
LINES

< > BotCompany Repo | #1022978 // IBWImage - interface virtualizing BWImage

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

Transpiled version (10749L) is out of date.

sinterface IBWImage extends MakesBufferedImage, IRGBImage {
  float getFloatPixel(int x, int y); // usually between 0 and 1
  
  default int getInt(int x, int y) { ret iround(getFloatPixel(x, y)*255f); }
  
  // implementing IRGBImage
  default int getIntPixel(int x, int y) { ret rgbIntFromGrayscale(getInt(x, y)); }
  
  default float getFloatPixel(Pt p) { ret getFloatPixel(p.x, p.y); }
  
  default float getFloatPixel(int index) {
    int w = w();
    ret getFloatPixel(index % w, index / w);
  }
  
  default float[] toFloatArray() {
    float[] data = new[w()*h()];
    for i over data:
      data[i] = getFloatPixel(i);
    ret data;
  }
  
  public default BufferedImage getBufferedImage() {
    ret grayImageFromIBWImage(this);
  }
  
  default BWImage toBWImage() {
    ret this instanceof BWImage ? (BWImage) this : iBWImageToBWImage(this);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 12 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, ofpaelxlmzfo, omdjrrnzbjjv, podlckwnjdmb, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv

No comments. add comment

Snippet ID: #1022978
Snippet name: IBWImage - interface virtualizing BWImage
Eternal ID of this version: #1022978/12
Text MD5: bdaddc66818592e26a6c5932bd2fdc72
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-05 19:01:00
Source code size: 887 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 393 / 1299
Version history: 11 change(s)
Referenced in: #1027297 - iBWImageFromFloats
#1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)
#1034420 - IRGBImage - interface virtualizing RGBImage
#1034924 - IBinaryImage - interface virtualizing Image2B