Ho visto che nel testo di Photoshop può essere facilmente ridimensionato semplicemente trascinandoli. Come possiamo fare la stessa cosa in Java? Qualche idea su come ridimensionare il testo in java? Aggiunto un'istantanea della lettera "A" ridimensionata in PhotoshopCome ridimensionare il testo in java
Per favore fatemi sapere che cosa c'è di sbagliato in questo codice?
public class ResizeImage extends JFrame {
public ResizeImage(){
JPanel panel = new JPanel(){
public void paintComponent(Graphics g) {
// In your paint(Graphics g) method
// Create a buffered image for use as text layer
BufferedImage textLayer = new BufferedImage(240, 240,
BufferedImage.TYPE_INT_RGB);
// Get the graphics instance of the buffered image
Graphics2D gBuffImg = textLayer.createGraphics();
// Draw the string
gBuffImg.drawString("Hello World", 10, 10);
// Rescale the string the way you want it
gBuffImg.scale(200, 50);
// Draw the buffered image on the output's graphics object
g.drawImage(textLayer, 0, 0, null);
gBuffImg.dispose();
}
};
add(panel);
}
public static void main(String [] args){
ResizeImage frame = new ResizeImage();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 300);
frame.setVisible(true);
}
}
È possibile eseguire il rendering del carattere su un 'BufferedImage' e ridimensionarlo nel modo desiderato. – Spoike
Non è tempo che tu abbia accettato *** una risposta o spiegando perché le risposte offerte non erano adatte? –