#65 pad images out to full cell size
authorKevin Lamonte <kevin.lamonte@gmail.com>
Wed, 6 Nov 2019 21:38:44 +0000 (15:38 -0600)
committerKevin Lamonte <kevin.lamonte@gmail.com>
Wed, 6 Nov 2019 21:38:44 +0000 (15:38 -0600)
src/jexer/TImage.java
src/jexer/tterminal/ECMA48.java

index 1463f1008f4788fa0d0e056565bc0565c5cfe505..2dfd6a3032c86af375d8ef855314b1a3ed51cd9a 100644 (file)
@@ -425,8 +425,21 @@ public class TImage extends TWidget implements EditMenuUser {
                     }
 
                     Cell cell = new Cell();
-                    cell.setImage(image.getSubimage(x * textWidth,
-                            y * textHeight, width, height));
+                    if ((width != textWidth) || (height != textHeight)) {
+                        BufferedImage newImage;
+                        newImage = new BufferedImage(textWidth, textHeight,
+                            BufferedImage.TYPE_INT_ARGB);
+
+                        java.awt.Graphics gr = newImage.getGraphics();
+                        gr.drawImage(image.getSubimage(x * textWidth,
+                                y * textHeight, width, height),
+                            0, 0, null, null);
+                        gr.dispose();
+                        cell.setImage(newImage);
+                    } else {
+                        cell.setImage(image.getSubimage(x * textWidth,
+                                y * textHeight, width, height));
+                    }
 
                     cells[x][y] = cell;
                 }
index ce06c36bebfb8fd525b262e3097359695c15dd34..369eca93005702b700d1ebc2c48ca4a77afa713e 100644 (file)
@@ -7305,8 +7305,21 @@ public class ECMA48 implements Runnable {
                 }
 
                 Cell cell = new Cell();
-                cell.setImage(image.getSubimage(x * textWidth,
-                        y * textHeight, width, height));
+                if ((width != textWidth) || (height != textHeight)) {
+                    BufferedImage newImage;
+                    newImage = new BufferedImage(textWidth, textHeight,
+                        BufferedImage.TYPE_INT_ARGB);
+
+                    java.awt.Graphics gr = newImage.getGraphics();
+                    gr.drawImage(image.getSubimage(x * textWidth,
+                            y * textHeight, width, height),
+                        0, 0, null, null);
+                    gr.dispose();
+                    cell.setImage(newImage);
+                } else {
+                    cell.setImage(image.getSubimage(x * textWidth,
+                            y * textHeight, width, height));
+                }
 
                 cells[x][y] = cell;
             }