convert c# code to java
Hi,
I have the below small c# code that i need to convert to Java.
Hope someone who knows the 2 programming languages help me to convert it to java.
thanks.
protectedvoid Page_Load(object sender, EventArgs e)
{
}
void button_Click(object sender, EventArgs e)
{
Bitmap objBitmap =new Bitmap(108, 80);
Graphics objGraphics = Graphics.FromImage(objBitmap);
System.Drawing.Image fullSizeImg;
fullSizeImg = System.Drawing.Image.FromFile("e:\\temp\\Laura_001.jpg");
System.Drawing.Image thumbNailImg;
thumbNailImg = Crop(fullSizeImg, 100, 74);
thumbNailImg.Save("E:\\temp\\cropped.jpg", ImageFormat.Jpeg);
System.Drawing.Image objImage2 = System.Drawing.Image.FromFile("e:\\temp\\projectFrame.gif");
objGraphics.DrawImage(thumbNailImg, 0, 0, 100, 74);
objGraphics.DrawImage(objImage2, 0, 0, 108, 80);
objBitmap.Save("E:\\temp\\final.jpg", ImageFormat.Jpeg);
objGraphics.Dispose();
fullSizeImg.Dispose();
thumbNailImg.Dispose();
objImage2.Dispose();
}
private System.Drawing.Image Crop(System.Drawing.Image original,int Width,int Height)
{
int sourceWidth = original.Width;
int sourceHeight = original.Height;
int sourceX = 0;
int sourceY = 0;
int destX = 0;
int destY = 0;
float nPercent = 0;
float nPercentW = 0;
float nPercentH = 0;
nPercentW = (((float)(Width)) / ((float)(sourceWidth)));
nPercentH = (((float)(Height)) / ((float)(sourceHeight)));
if (nPercentH < nPercentW)
{
nPercent = nPercentW;
destY = ((int)(((Height - (sourceHeight * nPercent)) / 2)));
}
else
{
nPercent = nPercentH;
destX = ((int)(((Width - (sourceWidth * nPercent)) / 2)));
}
int destWidth = ((int)((sourceWidth * nPercent)));
int destHeight = ((int)((sourceHeight * nPercent)));
Bitmap bmPhoto =new Bitmap(Width, Height, PixelFormat.Format24bppRgb);
bmPhoto.SetResolution(original.HorizontalResolution, original.VerticalResolution);
Graphics grPhoto = Graphics.FromImage(bmPhoto);
grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;
grPhoto.DrawImage(original,new Rectangle(destX, destY, destWidth, destHeight),new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight), GraphicsUnit.Pixel);
grPhoto.Dispose();
return bmPhoto;
}

