Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP imagettftext()在C++/Java/Python 在C++/java/Python库中有PHP函数IVITETFFTEXTHORE()的简单等价物吗?_Java_Php_C++_Python_Imagettftext - Fatal编程技术网

PHP imagettftext()在C++/Java/Python 在C++/java/Python库中有PHP函数IVITETFFTEXTHORE()的简单等价物吗?

PHP imagettftext()在C++/Java/Python 在C++/java/Python库中有PHP函数IVITETFFTEXTHORE()的简单等价物吗?,java,php,c++,python,imagettftext,Java,Php,C++,Python,Imagettftext,在python中,您可以使用PIL: from PIL import Image, ImageDraw, ImageFont font = ImageFont.truetype("/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf", 18) img = Image.open("test.jpg") draw = ImageDraw.Draw(img) draw.text((40, 40), "...sample text...", fon

在python中,您可以使用
PIL

from PIL import Image, ImageDraw, ImageFont
font = ImageFont.truetype("/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf", 18)
img = Image.open("test.jpg")
draw = ImageDraw.Draw(img)
draw.text((40, 40), "...sample text...", font=font, fill="red")
img.show()
在java中,您只需在任何
java.awt.Image
实例上绘制即可:

import javax.imageio.*;
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.swing.*;

public class ImageTest {
   public static void main(String args[]) throws Exception {
      BufferedImage img = ImageIO.read(new File("test.jpg"));
      Graphics2D g = img.createGraphics();
      Font f = Font.createFont(
            Font.TRUETYPE_FONT,
            new File("/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf")
      ).deriveFont(18f);
      g.setFont(f);
      g.setColor(Color.RED);
      g.drawString("test string", 40, 40);
      JFrame jf = new JFrame("test");
      jf.add(new JLabel(new ImageIcon(img)));
      jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      jf.setVisible(true);
      jf.pack();

   }
}
< C++ >有很多图像库(,…)< /P>