Java 如何以编程方式创建显示其分辨率或多个分辨率的图像

发布于 2025-01-11 11:39:35 字数 342 浏览 6 评论 0原文

如何仅使用 SE(即不使用任何库)以编程方式创建在 Java 中显示 n 个分辨率的图像/图标/位图。

例如,一系列分辨率,例如

[ [640, 480], [720, 576] ]

在此处输入图像描述

分辨率的位置并不重要,但最好如图所示。

使用自定义颜色/字体?甚至可能只是一条线而不是实心填充?

How can I programmatically create an Image/Icon/Bitmap that shows n number of resolutions in Java using just the SE i.e. no libraries.

e.g. an array of resolutions like

[ [640, 480], [720, 576] ]

to

enter image description here

The location of the resolution doesn't matter but would be preferable as shown.

With custom colours/fonts ? maybe even just a line rather than solid fill ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

止于盛夏 2025-01-18 11:39:35

利用 java.awt.*javax.imageio.* 中的图像类:

        BufferedImage img = new BufferedImage(1024, 1024, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = img.createGraphics();

        g.setColor(Color.RED);
        g.fillRect(0, 0, 512, 512);
        g.setColor(Color.BLACK);
        g.drawString("512x512", 10, 20);
        // etc..
        ImageIO.write(img, "PNG", new File("C:\\junk\\output.png"));

我假设您将在输入对上有一个循环,然后您将必须摆弄所需的算术才能将文本的各个位获取到您想要的位置

Make use of the image classes in java.awt.* and javax.imageio.*:

        BufferedImage img = new BufferedImage(1024, 1024, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = img.createGraphics();

        g.setColor(Color.RED);
        g.fillRect(0, 0, 512, 512);
        g.setColor(Color.BLACK);
        g.drawString("512x512", 10, 20);
        // etc..
        ImageIO.write(img, "PNG", new File("C:\\junk\\output.png"));

I assume you'll have a loop over your input pairs, then you'll have to fiddle around with the arithmetic needed to get the various bits of text where you want them

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文