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

29
LINES

< > BotCompany Repo | #1034182 // decolorizeImage

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

Transpiled version (9656L) is out of date.

static BWImage decolorizeImage(Decolorizer decolorizer, BufferedImage image) {
  if (image == null) null;
  var gp = grabbableIntPixels_fastOrSlow(image);
  if (gp == null) null;
  
  var ping = pingSource();
  int[] pixelsIn = gp.data;
  int w = gp.w, h = gp.h;
  int scanlineExtra = gp.scanlineStride-w;
  int iIn = gp.offset, iOut = 0;
  byte[] pixelsOut = new[w*h];
  
  for y to h: {
    for x to w: {
      int packed = pixelsIn[iIn++];
      int brightness = decolorizer.toGrayScale(packed);
      pixelsOut[iOut++] = (byte) brightness;
    }

    iIn += scanlineExtra;
    ping?!;
  }
  
  ret BWImage(w, h, pixelsOut);
}

static BWImage decolorizeImage(BufferedImage image, Decolorizer decolorizer) {
  ret decolorizeImage(decolorizer, image);
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1034182
Snippet name: decolorizeImage
Eternal ID of this version: #1034182/3
Text MD5: d013e4f2e9a971e52718447140d626c6
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-25 23:04:30
Source code size: 778 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 147 / 224
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)