Saturday, 15 June 2013

Round corners on images using Java and JAI -


We are using JAI for scaling and crop images in Java We want to make rounded corners on our images Are there. How do we do it?

Images are JPG and PNG I think it's easy to do with JPGs?

Image is a PlanarImage with JAI

  PlanarImage src = JAI.create (..., ...);  

which can be converted into java.awt.Graphics object

Has anyone been done before this?

PNG supports a transparent alpha channel, but JPG does not. Therefore, for the JPG you have to choose a color to paint the "invisible" part of the rectangle for the sphericals.

(Graphics2D) g; Goalrectangle 2D RR = new roundrackngal 2d. Float (50, 50, 200, 100, 10, 10); G2d.draw (rr); } Float () method of square RoundRectangle2D takes six arguments:

  • The first two represent the location of the upper left corner.
  • Logic represent the width and height of the round 3 and 4 round rectangle.
  • The last two logic represent the height and height of the arc drawn in the corner.

In this way, draw a rounded rectangle in which only the picture will be included which you want the rounded corners and then either use the mask to get the overlay or desired effect.


No comments:

Post a Comment