int imageWidth = cells.get(0).getImage().getWidth();
int imageHeight = cells.get(0).getImage().getHeight();
- // cells.get(x).getImage() has a dithered bitmap containing indexes
- // into the color palette. Piece these together into one larger
- // image for final rendering.
+ // Piece these together into one larger image for final rendering.
int totalWidth = 0;
- int fullWidth = cells.size() * getTextWidth();
- int fullHeight = getTextHeight();
+ int fullWidth = cells.size() * imageWidth;
+ int fullHeight = imageHeight;
for (int i = 0; i < cells.size(); i++) {
totalWidth += cells.get(i).getImage().getWidth();
}
int [] rgbArray;
for (int i = 0; i < cells.size() - 1; i++) {
- int tileWidth = Math.min(cells.get(i).getImage().getWidth(),
- imageWidth);
- int tileHeight = Math.min(cells.get(i).getImage().getHeight(),
- imageHeight);
+ int tileWidth = imageWidth;
+ int tileHeight = imageHeight;
if (false && cells.get(i).isInvertedImage()) {
// I used to put an all-white cell over the cursor, don't do
image.setRGB((cells.size() - 1) * imageWidth, 0, totalWidth,
imageHeight, rgbArray, 0, totalWidth);
- if (totalWidth < getTextWidth()) {
+ if (totalWidth < imageWidth) {
int backgroundColor = cells.get(cells.size() - 1).getBackground().getRGB();
for (int imageX = image.getWidth() - totalWidth;
}
}
+ if ((image.getWidth() != cells.size() * getTextWidth())
+ || (image.getHeight() != getTextHeight())
+ ) {
+ // Rescale the image to fit the text cells it is going into.
+ BufferedImage newImage;
+ newImage = new BufferedImage(cells.size() * getTextWidth(),
+ getTextHeight(), BufferedImage.TYPE_INT_ARGB);
+
+ java.awt.Graphics gr = newImage.getGraphics();
+ gr.drawImage(image, 0, 0, newImage.getWidth(),
+ newImage.getHeight(), null, null);
+ gr.dispose();
+ image = newImage;
+ fullHeight = image.getHeight();
+ }
+
// Dither the image. It is ok to lose the original here.
if (palette == null) {
palette = new SixelPalette();
// Piece cells.get(x).getImage() pieces together into one larger
// image for final rendering.
int totalWidth = 0;
- int fullWidth = cells.size() * getTextWidth();
- int fullHeight = getTextHeight();
+ int fullWidth = cells.size() * imageWidth;
+ int fullHeight = imageHeight;
for (int i = 0; i < cells.size(); i++) {
totalWidth += cells.get(i).getImage().getWidth();
}
int [] rgbArray;
for (int i = 0; i < cells.size() - 1; i++) {
- int tileWidth = Math.min(cells.get(i).getImage().getWidth(),
- imageWidth);
- int tileHeight = Math.min(cells.get(i).getImage().getHeight(),
- imageHeight);
+ int tileWidth = imageWidth;
+ int tileHeight = imageHeight;
if (false && cells.get(i).isInvertedImage()) {
// I used to put an all-white cell over the cursor, don't do
// that anymore.
image.setRGB((cells.size() - 1) * imageWidth, 0, totalWidth,
imageHeight, rgbArray, 0, totalWidth);
- if (totalWidth < getTextWidth()) {
+ if (totalWidth < imageWidth) {
int backgroundColor = cells.get(cells.size() - 1).getBackground().getRGB();
for (int imageX = image.getWidth() - totalWidth;
}
}
+ if ((image.getWidth() != cells.size() * getTextWidth())
+ || (image.getHeight() != getTextHeight())
+ ) {
+ // Rescale the image to fit the text cells it is going into.
+ BufferedImage newImage;
+ newImage = new BufferedImage(cells.size() * getTextWidth(),
+ getTextHeight(), BufferedImage.TYPE_INT_ARGB);
+
+ java.awt.Graphics gr = newImage.getGraphics();
+ gr.drawImage(image, 0, 0, newImage.getWidth(),
+ newImage.getHeight(), null, null);
+ gr.dispose();
+ image = newImage;
+ fullHeight = image.getHeight();
+ }
+
/*
* From https://iterm2.com/documentation-images.html:
*
// Piece cells.get(x).getImage() pieces together into one larger
// image for final rendering.
int totalWidth = 0;
- int fullWidth = cells.size() * getTextWidth();
- int fullHeight = getTextHeight();
+ int fullWidth = cells.size() * imageWidth;
+ int fullHeight = imageHeight;
for (int i = 0; i < cells.size(); i++) {
totalWidth += cells.get(i).getImage().getWidth();
}
int [] rgbArray;
for (int i = 0; i < cells.size() - 1; i++) {
- int tileWidth = Math.min(cells.get(i).getImage().getWidth(),
- imageWidth);
- int tileHeight = Math.min(cells.get(i).getImage().getHeight(),
- imageHeight);
+ int tileWidth = imageWidth;
+ int tileHeight = imageHeight;
if (false && cells.get(i).isInvertedImage()) {
// I used to put an all-white cell over the cursor, don't do
// that anymore.
image.setRGB((cells.size() - 1) * imageWidth, 0, totalWidth,
imageHeight, rgbArray, 0, totalWidth);
- if (totalWidth < getTextWidth()) {
+ if (totalWidth < imageWidth) {
int backgroundColor = cells.get(cells.size() - 1).getBackground().getRGB();
for (int imageX = image.getWidth() - totalWidth;
}
}
+ if ((image.getWidth() != cells.size() * getTextWidth())
+ || (image.getHeight() != getTextHeight())
+ ) {
+ // Rescale the image to fit the text cells it is going into.
+ BufferedImage newImage;
+ newImage = new BufferedImage(cells.size() * getTextWidth(),
+ getTextHeight(), BufferedImage.TYPE_INT_ARGB);
+
+ java.awt.Graphics gr = newImage.getGraphics();
+ gr.drawImage(image, 0, 0, newImage.getWidth(),
+ newImage.getHeight(), null, null);
+ gr.dispose();
+ image = newImage;
+ fullHeight = image.getHeight();
+ }
+
if (jexerImageOption == JexerImageOption.PNG) {
// Encode as PNG
ByteArrayOutputStream pngOutputStream = new ByteArrayOutputStream(1024);