在java中调整图像大小而不使用ImageIO

在java中调整图像大小而不使用ImageIO,java,image,resize,javax.imageio,Java,Image,Resize,Javax.imageio,我们通过获取JPEG缩略图数据成功地调整了图像的大小,但有些图像没有 解决方案只是调整图像大小,以便能够创建缩略图,但只能使用Java1.4及以下版本,因此我不能使用ImageIO,因为设备不支持它 关于如何使用ImageIO调整图像大小的问题,有什么解决方案吗?java.awt.image.getScaledInstancewidth,height,Hights,Hits返回图像的新的缩放实例 最后一个参数提示更改了使用的缩放方法,这将修改结果外观。请参阅下面的代码片段,直接取自JDK源代码

我们通过获取JPEG缩略图数据成功地调整了图像的大小,但有些图像没有

解决方案只是调整图像大小,以便能够创建缩略图,但只能使用Java1.4及以下版本,因此我不能使用ImageIO,因为设备不支持它

关于如何使用ImageIO调整图像大小的问题,有什么解决方案吗?

java.awt.image.getScaledInstancewidth,height,Hights,Hits返回图像的新的缩放实例

最后一个参数提示更改了使用的缩放方法,这将修改结果外观。请参阅下面的代码片段,直接取自JDK源代码

 /**
 * Use the default image-scaling algorithm.
 * @since JDK1.1
 */
public static final int SCALE_DEFAULT = 1;

/**
 * Choose an image-scaling algorithm that gives higher priority
 * to scaling speed than smoothness of the scaled image.
 * @since JDK1.1
 */
public static final int SCALE_FAST = 2;

/**
 * Choose an image-scaling algorithm that gives higher priority
 * to image smoothness than scaling speed.
 * @since JDK1.1
 */
public static final int SCALE_SMOOTH = 4;

/**
 * Use the image scaling algorithm embodied in the
 * <code>ReplicateScaleFilter</code> class.
 * The <code>Image</code> object is free to substitute a different filter
 * that performs the same algorithm yet integrates more efficiently
 * into the imaging infrastructure supplied by the toolkit.
 * @see        java.awt.image.ReplicateScaleFilter
 * @since      JDK1.1
 */
public static final int SCALE_REPLICATE = 8;

/**
 * Use the Area Averaging image scaling algorithm.  The
 * image object is free to substitute a different filter that
 * performs the same algorithm yet integrates more efficiently
 * into the image infrastructure supplied by the toolkit.
 * @see java.awt.image.AreaAveragingScaleFilter
 * @since JDK1.1
 */
public static final int SCALE_AREA_AVERAGING = 16;

试试这段代码,只要把你想要的宽度和高度的大小,它会给你所需的图像。这是我找到的最短的代码。对我来说很好

    Bitmap yourBitmap;
    Bitmap resized = Bitmap.createScaledBitmap(yourBitmap, newWidth, newHeight, true);

您可以使用Image.getScaledInstance检索java.awt.Image的已调整大小的实例。为什么java 1.4会导致OutOfMemoryException?@haraldK,因为我们使用它的设备没有那么多内存。好的。。然后更新问题。说明它是什么类型的设备,以及什么类型的Java,因为它不支持完整的Java2SE1.4。也可以说明它拥有的内存量。这将给那些想帮助你的人一个这样做的机会-我更新了问题,先生。嗯,我无法说明我们正在使用的具体设备@Haraldk根据我的研究,我必须使用imageIO作为BuffereImage。有没有其他方法我无法使用ImageIO来实现此目的?