• Post Reply Bookmark Topic Watch Topic
  • New Topic

AffineTransform, RescaleOp and Bilinear hint  RSS feed

 
Martin Thorpe
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

I have written an application that manipulates images. It can rescale and make the image brighter working with BufferedImages and jpegs.

I am using the AffineTransformOp() to physically scale the size of the image and the RescaleOp() to make it brighter.

Both work fine UNLESS I apply the AffineTransform, first, with an interpolation rendering hint of bilinear. If I do this and then try to apply the RescaleOp after the image just goes to black.

The RescaleOp works fine if I use the AffineTransform with and interpolatin of nearest neighbour, but I want to use bilenear.

This is the code for the physical rescale:


And this is the code for the brightness


This has me perplexed. It must be something to do with the bilinear hint as it functions fine with nearest neighbour.

thanks for taking the time to read.
cheers
Martin
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JPEGImageEncoder corrupts BufferedImage scaled w/AffineTransformOp.TYPE_BILINEAR
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4503132
 
Martin Thorpe
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Craig, that is brilliant, nice one. There is a workaround on the page that when you pass in a new BufferedImage to the filter function then it all works ok with Bilinear, and it works too. Thanks for the pointer, this is the solution I have implemented:



Works fine. thanks again.

cheers
Martin
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!