|
Hi,
I am using following code to save an pixel array as an jpg image on disk
<code> public static BufferedImage toImage(byte[] pixels, int w, int h) { DataBuffer db = new DataBufferByte(pixels, w*h); WritableRaster raster = Raster.createInterleavedRaster(db, w, h, w, 1, new int[]{0}, null); ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY); ColorModel cm = new ComponentColorModel(cs, false, false, Transparency.OPAQUE ,DataBuffer.TYPE_BYTE); return new BufferedImage(cm, raster, false, null); }
public static void saveImage(String filename,byte OriginalByte[], int width1,int height1) { BufferedImage image1 = toImage(OriginalByte, width1, height1); try{ ImageIO.write(image1, "jpg", new File(filename)); } catch(IOException e){} } </code>
I saved pixel array of 1024(32*32) bytes on disk as image.jpg and pixel array of 800(40*20) bytes as image1.jpg on disk using above code.
But the size of image1.jpg on disk is greater then image.jpg.
why this is happening?
Please help,
Thanks,
Rupali
|