简体   繁体   English

如何在Java中放大图像而不损失质量?

[英]How might I enlarge image in java without losing quality?

I am working with images in Java. 我正在使用Java处理图像。 I have a set of images - let's say 600x800 pixels each. 我有一组图像-假设每个图像600x800像素。 I resize them at 100x100 and I make some stuff on it. 我将它们的尺寸调整为100x100,然后在上面做一些东西。 Now I would like to enlarge the image at the beginning size without losing my changing and pixel quality. 现在,我想以开始的尺寸放大图像,而不会丢失更改和像素质量。 Is this possible? 这可能吗?

No. This also isn't really a Java question. 不。这也不是Java问题。 How would you do this with an image editor? 您将如何使用图片编辑器执行此操作? If you resize twice (especially smaller than larger), you're going to lose quality. 如果您调整大小两次(尤其是小于大),则质量会下降。

Your best bet is to keep the native resolution, then use vector graphics to draw what you need - eliminating any unnecessary resizing. 最好的选择是保持原始分辨率,然后使用矢量图形绘制所需的图像-消除不必要的调整大小。 (IE, calculate what you need to draw, taking into account the current size - without first resizing to 100x100.) This will also fix some issues you're also probably seeing regarding the aspect ratios - as when you would resize from 100x100 back to 600x800, whatever you added is going to appear "stretched" / wider. (即,在不首先调整为100x100的情况下,考虑当前尺寸来计算需要绘制的内容。)这还将解决一些您可能还会看到的有关宽高比的问题-例如,当您将尺寸从100x100调整为600x800,无论您添加什么内容,都将显示为“拉伸” /宽。

I would like to enlarge the image at the beginning size without losing my changing and pixel quality. 我想以开始的尺寸放大图像,而又不丢失更改和像素质量。 Is this possible? 这可能吗?

Yes, it's possible and very simple. 是的,这是可能的,而且非常简单。

Here's how you do it: use your original. 操作方法如下: 使用原件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM