我如何仅在Java的Jframe中显示一部分图像 - 使用Graphics2D方法

发布于 2025-02-01 04:33:55 字数 243 浏览 4 评论 0原文

因此,我正在尝试在Java中制作一个程序,该程序打开Jframe窗口并显示图像。这些图像是图块地图/精灵纸的一部分。

g2.drawImage(image, screenX, screenY, gp.tileSize, gp.tileSize, null);

图像是整个图像,屏幕X/y是位置,瓷砖是图像的大小 - 这显示了整个图像,我将如何以相同的大小显示,但仅显示图像的一部分。如果这还不清楚,请告诉我。

So, I am trying to make a program in Java that opens a JFrame window and displays images. these images are part of a Tile map/Sprite sheet.

g2.drawImage(image, screenX, screenY, gp.tileSize, gp.tileSize, null);

image is the whole image and ScreenX/Y is the location, and the tileSize is the size of the image - this is displaying the whole image, how would i display at the same size but only part of the image. If this is unclear please tell me so.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文