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

37
LINES

< > BotCompany Repo | #1000965 // Bla

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1125L/8K/25K).

!747
!image classes
!FrameWithImages

m {
  static int g = 8;
  static RGBImage img;
  
  !include #1000522 // helper functions
  !include #1000898 // exitOnFrameClose
  
  p {
    img = loadImage("#1000326");
    int w = img.getWidth(), h = img.getHeight();
    RGBImage img2 = new RGBImage(img.getWidth(), img.getHeight(), Color.white);
    for (int y = g; y < h-g; y += g)
      for (int x = g; x < w-g; x += g) {
        double d = calcDiffs(x, y);
        paintBlock(img2, new RGB(d), x, y);
      }
    showImage(img2);
  }
  
  static double calcDiffs(int x, int y) {
    RGB col = img.getPixel(x, y);
    return (pixelDiff(img.getPixel(x, y-g), col)
      +pixelDiff(img.getPixel(x-g, y), col)
      +pixelDiff(img.getPixel(x+g, y), col)
      +pixelDiff(img.getPixel(x, y+g), col))/4;
  }
  
  static void paintBlock(RGBImage img, RGB col, int x, int y) {
    for (int yy = 0; yy < g; yy++)
      for (int xx = 0; xx < g; xx++)
        img.setPixel(x+xx, y+yy, col);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1000965
Snippet name: Bla
Eternal ID of this version: #1000965/1
Text MD5: 2605eb53db07680f36c812bd2b4e5b9b
Transpilation MD5: 7c04c4a50a29fc2001402efc962d3bac
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-10-14 17:25:24
Source code size: 1017 bytes / 37 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 551 / 612
Referenced in: [show references]