问题描述
当我从磁盘读取JPEG时,Java有时会给我一个BufferedImage,其getType()返回TYPE_CUSTOM -即,它具有自定义的颜色模型。我想调整此BufferedImage的大小,但不确定如何构造目标对象。有人可以提供使用以下构造函数的示例代码吗?
When I read a JPEG from disk, Java sometimes gives me a BufferedImage whose getType() returns TYPE_CUSTOM -- that is, it has a custom color model. I'd like to resize this BufferedImage but I'm not sure how to construct the destination object. Can someone please provide sample code for using the following constructor?
我想创建一个与源相同类型的BufferedImage,只是更大并传输内容结束。有想法吗?
I would like to create a BufferedImage of the same type as the source, just bigger, and transfer the contents over. Any ideas?
推荐答案
回答我自己的问题,它看起来像是答案。具体来说:
Answering my own question, it looks like ImageTypeSpecifier is the answer. Specifically:
- 调用以获取
ImageTypeSpecifier
来自具有自定义颜色模型的图像。 - 调用在
ImageTypeSpecifier
从步骤1开始创建具有与原始图像相同颜色模型的新图像。
- Invoke ImageTypeSpecifier.createFromRenderedImage(RenderedImage image) to get back an
ImageTypeSpecifier
from the image with the custom color model. - Invoke ImageTypeSpecifier.createBufferedImage(int width, int height) on the
ImageTypeSpecifier
from step 1 to create a new image with the same color model as the original image.
这篇关于调整TYPE_CUSTOM BufferedImages的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!