[java] AffineTransformOp

Started by
2 comments, last by Lyrrwen 19 years, 1 month ago
I've always been curious. In AffineTransformOp you have the method filter(src,dst) (specified by BufferedImageOp). The method takes a source image, and a destination image. In addition, it returns a BufferedImage. So, what exactly does this mean? does filter(src,null) create a new BufferedImage and returns this one? does filter(src,dest) return dest, or does it still create a new BufferedImage (in addition to dest), and return this one? why not BufferedImage im = op.filter(src,null); instead of BufferedImage im; op.filter(src,im); ? I guess there is something about this method that I just don't understand correctly. If someone could explain, that would be great. In addition, how is accelleration results with these returned images. Do the two examples give the same accelleration possibilities?
Development blog, The Omega Sector -- http://www.omegasector.org
Advertisement
Ignore my last post, it's nonsense. I think I was drunk...
I tried reading the source (I always do), however this specific source is quite ... akward. The method mentioned does alot of things with both alternatives, and my knowledge is too limited to make much sense of it. If anyone has any hard facts about the two ways of doing it, please do elaborate. Even hunches are appreciated ;)
Development blog, The Omega Sector -- http://www.omegasector.org
First of all, let me say that I have never used AffineTransformOp, and I am only speculating based on reading the API and looking at the code. So, it appears that:

filter(src, null) does indeed create a new BufferedImage, and assigns it the same ColorModel src has.

With filter(src, dest), dest may have a different color model than src, in which case "a color conversion into the destination color model is performed." During that conversion, one or more temporary BufferedImages might be created, although dest is the one returned in the end.

So, filter(src, dest) lets you change the ColorModel at the same time, or, if you use the same ColorModel, might perform slightly better if you reuse dest for multiple filter operations. Being able to pass null seems to be a convenience so that you don't have to create an empty BufferedImage to be used only once (and you are assured that it will have the same ColorModel as src).

I don't know what effect the actual contents of dest will have on the result of the filter. I don't think any blanket statement about accelleration results can be made: it depends on the properties of src and dest.

Hope this helps, remember I'm only guessing!

This topic is closed to new replies.

Advertisement