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).

// SnP = Scale and Posterize
// pixelRows = -1 means use original image's height
srecord SnPSettings(int pixelRows, int colors) extends MetaWithChangeListeners {
  SnPSettings() { pixelRows = 128; colors = 8; }
  
  // use full image resolution (no downsampling)
  SnPSettings(BufferedImage image, int colors) {
    pixelRows = image.getHeight();
    this.colors = colors;
  }

  SnPSettings cloneMe() { ret shallowClone(this); }
  
  // optional - null for simple decolorization
  settableWithVar Decolorizer decolorizer;
  
  int pixelRowsForImage(WidthAndHeight img) {
    ret pixelRows < 0 ? img.getHeight() : pixelRows;
  }
  
  static SnPSettings allColors(int pixelRows) {
    ret new SnPSettings(pixelRows, 255);
  }
}

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