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

24
LINES

< > BotCompany Repo | #1034027 // SnPSettings (Scale & Posterize)

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

Libraryless. Click here for Pure Java version (10073L/56K).

1  
// SnP = Scale and Posterize
2  
// pixelRows = -1 means use original image's height
3  
srecord SnPSettings(int pixelRows, int colors) extends MetaWithChangeListeners {
4  
  SnPSettings() { pixelRows = 128; colors = 8; }
5  
  
6  
  // use full image resolution (no downsampling)
7  
  SnPSettings(BufferedImage image, int colors) {
8  
    pixelRows = image.getHeight();
9  
    this.colors = colors;
10  
  }
11  
12  
  SnPSettings cloneMe() { ret shallowClone(this); }
13  
  
14  
  // optional - null for simple decolorization
15  
  settableWithVar Decolorizer decolorizer;
16  
  
17  
  int pixelRowsForImage(WidthAndHeight img) {
18  
    ret pixelRows < 0 ? img.getHeight() : pixelRows;
19  
  }
20  
  
21  
  static SnPSettings allColors(int pixelRows) {
22  
    ret new SnPSettings(pixelRows, 255);
23  
  }
24  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1034027
Snippet name: SnPSettings (Scale & Posterize)
Eternal ID of this version: #1034027/8
Text MD5: aa9388ad50b87a6e2597a07b3fd9f1dd
Transpilation MD5: 03a41a45785da859f0e2b5a0244170b4
Author: stefan
Category: javax / gazelle 22
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-05-07 01:43:14
Source code size: 749 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 200 / 364
Version history: 7 change(s)
Referenced in: [show references]