Problem while saving the images

hi all

m creating an image editor in java

but i m facing one major problem in it.

In my code i use Write method of ImageIO to save a file....fo ex..

String outfile = dialog.getFile();

File outputFile = new File(dialog.getDirectory()

+ outfile);

ImageIO.write(bufferedImage,"jpg", outputFile);

This code saves file.But there is one big problem. This code reduces the size of the jpeg image and also distorts the colour combination. Such as if i open an image (size 255 Kb) and save it without any editing it will be save with the size 110 Kb..another problem is that if i apply some effects to image and then save it,it reduces the size further (arnd 90 kb and at such size images loose their color combination...nd look reddish!!)

Whenever i open these files in any other image editor other than my code, images look distorted!!!

Could some one suggest me a solution

Plzzzzzzzzzzzzzzz

[957 byte] By [rav_ahja] at [2007-11-26 18:24:33]
# 1

create

// outFile is path of file where you want to save file

FileOutputStream out = new FileOutputStream(outFile);

JPEGEncodeParam encodeParam = new JPEGEncodeParam();

// you can perform more operation on image with help of encodeParam

ImageEncoder encoder = ImageCodec.createImageEncoder("JPEG", out, encodeParam );

try

{

// image which you want to save

encoder.encode(image);

out.close();

}

catch (IOException e)

{

System.out.println("IOException at encoding..");

System.exit(1);

}

Prashant_SDNa at 2007-7-9 5:58:37 > top of Java-index,Security,Cryptography...