Sign in to follow this  
Addictman

[java] AffineTransformOp

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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 ;)

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this