/*
* Program for Highlighting a particular portion of image in any color
* Copyright 2009 @ yuvadeveloper
* Code By:- Prashant Chandrakar
*
*/
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
class HighlightImage
{
public static void main(String a[])
{
try
{
////pass image file path open for drawing
BufferedImage image = ImageIO.read(new File("1.jpg"));
////taking graphics from image
Graphics g = image.getGraphics();
////just change the transparency value for changing beta values of image
int transparency = 50;
/////drawing string on graphics of opened image
g.drawString("We are highlighting a selected portion of image", 10, 10);
Color color = new Color(255, 255, 0, 255 * transparency / 100);
g.setColor(color);
g.fillRect(30, 30, 100, 100);
////saving image by name output.jpg
ImageIO.write(image, "jpg", new File("output.jpg"));
}
catch (Exception e)
{
System.out.println(e);
}
}
}
No comments:
Post a Comment