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.

1  
sinterface IBWImage extends MakesBufferedImage, IRGBImage {
2  
  float getFloatPixel(int x, int y); // usually between 0 and 1
3  
  
4  
  default int getInt(int x, int y) { ret iround(getFloatPixel(x, y)*255f); }
5  
  
6  
  // implementing IRGBImage
7  
  default int getIntPixel(int x, int y) { ret rgbIntFromGrayscale(getInt(x, y)); }
8  
  
9  
  default float getFloatPixel(Pt p) { ret getFloatPixel(p.x, p.y); }
10  
  
11  
  default float getFloatPixel(int index) {
12  
    int w = w();
13  
    ret getFloatPixel(index % w, index / w);
14  
  }
15  
  
16  
  default float[] toFloatArray() {
17  
    float[] data = new[w()*h()];
18  
    for i over data:
19  
      data[i] = getFloatPixel(i);
20  
    ret data;
21  
  }
22  
  
23  
  public default BufferedImage getBufferedImage() {
24  
    ret grayImageFromIBWImage(this);
25  
  }
26  
  
27  
  default BWImage toBWImage() {
28  
    ret this instanceof BWImage ? (BWImage) this : iBWImageToBWImage(this);
29  
  }
30  
}

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: 394 / 1302
Version history: 11 change(s)
Referenced in: [show references]