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

15
LINES

< > BotCompany Repo | #1034407 // volatileImageScalingDemo

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

Libraryless. Click here for Pure Java version (12094L/71K).

static Swingable volatileImageScalingDemo(BufferedImage srcImage default loadImage2(#1102649)) {
  new VolatileImageSurfaceDemo demo;
  demo.renderable((g, w, h) -> {
      g.setColor(Color.white);
      g.fillRect(0, 0, w, h);
      double scale = scaleToFitInside(srcImage, w, h);
      int x = (w-iround(srcImage.getWidth()*scale))/2;
      int y = (h-iround(srcImage.getHeight()*scale))/2;
      g.translate(x, y);
      g.scale(scale, scale);
      demo.time("scale image", ->
        g.drawImage(srcImage, 0, 0, null));
    });
  ret demo;
}

Author comment

Began life as a copy of #1034401

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034407
Snippet name: volatileImageScalingDemo
Eternal ID of this version: #1034407/3
Text MD5: 24534f15bbc188aee47449eb0fff08bc
Transpilation MD5: ec9c85b8e63c821e76d3d4da2486fb1a
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-05 23:38:33
Source code size: 561 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 131 / 201
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)