Redian新闻
>
How would clear a BufferedImage?
avatar
How would clear a BufferedImage?# Java - 爪哇娇娃
g*g
1
If I want to reset a BufferedImage to a transparent empty image,
(so that I can change the content of image to paint)
I am doing a new BufferedImage(BufferedImage.INT_ARGB) now,
anyway I can fill the raster instead?
I am worried if this frequent memory allocation would be a big
burden for GC and degrade performance.
avatar
m*t
2

Isn't this faster than actually painting it anyway?
I wouldn't worry about it. Speaking of object allocation and GC,
there is an ongoing thread on TSS that might be some good read:
http://www.theserverside.com/news/thread.tss?thread_id=36832

【在 g*****g 的大作中提到】
: If I want to reset a BufferedImage to a transparent empty image,
: (so that I can change the content of image to paint)
: I am doing a new BufferedImage(BufferedImage.INT_ARGB) now,
: anyway I can fill the raster instead?
: I am worried if this frequent memory allocation would be a big
: burden for GC and degrade performance.

avatar
c*t
3
in addition to what magicfat said, you can do direct DataBufferInt
manipulation to set all values to zeros. Of course, new a BufferedImage
is faster in every way you look at :P

【在 g*****g 的大作中提到】
: If I want to reset a BufferedImage to a transparent empty image,
: (so that I can change the content of image to paint)
: I am doing a new BufferedImage(BufferedImage.INT_ARGB) now,
: anyway I can fill the raster instead?
: I am worried if this frequent memory allocation would be a big
: burden for GC and degrade performance.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。