/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sister.kelompok5;

import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

import javax.imageio.ImageIO;

public class Message extends UnicastRemoteObject implements MessageInterface {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public Message() throws RemoteException {        
    }

	public void Convert(byte[] imageByteArray, int fileNumber, String fileName, String fileExtension) throws IOException {
		BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageByteArray));
				
		String pathNewFile = "";
			
		File path = new File(pathNewFile + fileNumber + "_" + fileName + "_grayscale." + fileExtension);
			
		ImageIO.write(image, fileExtension, path);
	}
    
}

@@ -124,16 +124,39 @@
 mpok5;%0A%0A
+import java.awt.Color;%0A
 import j
@@ -221,16 +221,54 @@
 Stream;%0A
+import java.io.ByteArrayOutputStream;%0A
 import j
@@ -741,16 +741,54 @@
 ption %7B%0A
+%09%09// Handle byte array of image input%0A
 %09%09Buffer
@@ -800,16 +800,18 @@
 ge image
+In
  = Image
@@ -863,18 +863,854 @@
 ay));%0A%09%09
+%0A
 %09%09
+// Get image attributes%0A%09%09int height = imageIn.getHeight();%0A%09%09int width = imageIn.getWidth();%0A%09%09%0A%09%09BufferedImage imageAttributes = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);%0A%09%09%0A%09%09// Convert to grayscale%0A%09%09for (int y = 0; y %3C height; y++) %7B%0A%09%09%09for (int x = 0; x %3C width; x++) %7B%0A%09%09%09%09Color color = new Color(imageIn.getRGB(x, y));%0A%09%09%09%09%0A%09%09%09%09int temp = (int) (color.getRed() * 0.299 + color.getGreen() * 0.587 + color.getBlue() * 0.114);%0A%09%09%09%09%0A%09%09%09%09imageAttributes.setRGB(x, y, temp %3C%3C 16 %7C temp %3C%3C 8 %7C temp);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09ByteArrayOutputStream baos = new ByteArrayOutputStream();%0A%09%09// Get byte array image again%0A%09%09ImageIO.write(imageAttributes, fileExtension, baos);%0A%09%09%0A%09%09byte%5B%5D imageOut = baos.toByteArray();%0A%09%09%0A%09%09// Construct image like before%0A%09%09BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageOut));
 %0A%09%09Strin

add rgb to grayscale converter