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

1  
static Swingable volatileImageScalingDemo(BufferedImage srcImage default loadImage2(#1102649)) {
2  
  new VolatileImageSurfaceDemo demo;
3  
  demo.renderable((g, w, h) -> {
4  
      g.setColor(Color.white);
5  
      g.fillRect(0, 0, w, h);
6  
      double scale = scaleToFitInside(srcImage, w, h);
7  
      int x = (w-iround(srcImage.getWidth()*scale))/2;
8  
      int y = (h-iround(srcImage.getHeight()*scale))/2;
9  
      g.translate(x, y);
10  
      g.scale(scale, scale);
11  
      demo.time("scale image", ->
12  
        g.drawImage(srcImage, 0, 0, null));
13  
    });
14  
  ret demo;
15  
}

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