package stego.StegoCreator;

import StegoGUI.StegoFileSelection;
import java.awt.Graphics2D;
import java.awt.image.*;
import java.io.File;
import javax.imageio.ImageIO;
import stego.Drivers;

public class StegoEmbedder_JPEG_PNG_GIF
{

    static String strMyClassName = "StegoEmbedder_JPEG_PNG_GIF";

    public StegoEmbedder_JPEG_PNG_GIF(StegoFileSelection par, File fleImg)
    {
    }

    public byte[] processImage(File fleImage, byte arrMsgToEmbed[])
    {
        byte arrCarrierImage[];
        BufferedImage biCarrierImage = ImageIO.read(fleImage);
        BufferedImage biCarrierImage_UserSpace = convertToUserSpace(biCarrierImage);
        arrCarrierImage = convertToRasterByteArray(biCarrierImage_UserSpace);
        return arrCarrierImage;
        Exception e;
        e;
        Drivers.eop("processImage", strMyClassName, e, e.getLocalizedMessage(), true);
        return null;
    }

    public BufferedImage embedText(BufferedImage biCarrier, byte msgToEmbed[])
    {
        return biCarrier;
        Exception e;
        e;
        Drivers.eop("embedText", strMyClassName, e, e.getLocalizedMessage(), true);
        return null;
    }

    private byte[] convertToRasterByteArray(BufferedImage imgToConvert)
    {
        DataBufferByte bufferImg;
        WritableRaster rasterImg = imgToConvert.getRaster();
        bufferImg = (DataBufferByte)rasterImg.getDataBuffer();
        return bufferImg.getData();
        Exception e;
        e;
        Drivers.eop("convertToRasterByteArray", strMyClassName, e, e.getLocalizedMessage(), true);
        return null;
    }

    public BufferedImage convertToUserSpace(BufferedImage imgToConvert)
    {
        BufferedImage biConvertedImage;
        biConvertedImage = new BufferedImage(imgToConvert.getWidth(), imgToConvert.getHeight(), 5);
        Graphics2D graphics2D = biConvertedImage.createGraphics();
        graphics2D.drawRenderedImage(imgToConvert, null);
        graphics2D.dispose();
        return biConvertedImage;
        Exception e;
        e;
        Drivers.eop("convertToUserSpace", strMyClassName, e, e.getLocalizedMessage(), true);
        return null;
    }

}
