Package com. mobi5.commons. domain. logic;
Import java. Io. file;
Import java. Io. fileoutputstream;
Import java. AWT. graphics;
Import java. AWT. image;
Import java. AWT .*;
Import java. AWT. image. bufferedimage;
Import com.sun.image.codec.jpeg. Unzip codec;
Import com.sun.image.codec.jpeg. encode imageencoder;
Public class imgproce {
Private int Wideth;
Private int height;
Private string T = NULL;
Public void sett (string T)
{
This. t = T;
}
Public void setwideth (INT Wideth)
{
This. Wideth = Wideth;
}
Public int getwideth ()
{
Return this. Wideth;
}
Public void setheight (INT height)
{
This. Height = height;
}
Public int getheight (int w, int h) // former images size
{
Int hhh;
If (W> Wideth)
{
Float WW;
WW = (float) W/(float) Wideth;
Float HH = H/WW;
Return (INT) HH;
}
Else
{
This. setwideth (w );
Return h;
}
}
Public void proce (string fpath) throws exception
{
File _ file = new file (fpath );
System. Out. println ("-------" + fpath );
Image src = javax. ImageIO. ImageIO. Read (_ file );
Int Wideth = SRC. getwidth (null );
Int Height = SRC. getheight (null );
Int H = This. getheight (Wideth, height );
Bufferedimage tag = new bufferedimage (this. getwideth (), H, bufferedimage. type_int_rgb );
Graphics G = tag. getgraphics ();
G. drawimage (SRC, 65, 60, this. getwideth (), H, null );
If (T! = NULL)
{
G. setcolor (new color (242,242,242 ));
G. fillrect (this. getwideth ()-120, H-18,120, 18 );
G. setcolor (new color (180,180,180 ));
G. drawrect (this. getwideth ()-120, H-18,119, 17 );
G. setcolor (new color (255,102, 0 ));
G. drawstring (T, this. getwideth ()-100, H-5 );
}
Fileoutputstream out = new fileoutputstream (fpath );
Required imageencoder encoder = required codec. createjpegencoder (out );
Encoder. encode (TAG );
Out. Close ();
}
}