quote:
We provide a set of library routines for reading and writing JPEG image files,
plus two sample applications "cjpeg" and "djpeg", which use the library to
perform conversion between JPEG and some other popular image file formats..
quote:
package {
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.geom.Rectangle;
import flash.utils.ByteArray;
import flash.utils.getTimer;
import flash.events.Event;
import flash.display.Loader;
import flash.net.URLRequest;
import hurlant.jpeg.as3_jpeg_wrapper;
import com.adobe.images.JPGEncoder;
public class JpegTest extends Sprite {
private var _loader:Loader = new Loader();
public function JpegTest() {
trace("hello.");
testWrite();
}
private function testWrite():void {
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete) ;
_loader.load(new URLRequest("acura.jpg"));
}
public function onComplete(event:Event):ByteArray{
var image:Bitmap = Bitmap(_loader.content);
var b:BitmapData = image.bitmapData;
addChild(image);
// as3 way
var t1:int = getTimer();
var s:JPGEncoder = new JPGEncoder();
var jpg:ByteArray = s.encode(b);
trace("AS3 JPEG ENCODING: "+(getTimer()-t1)+"ms.");
trace("jpg.length = "+jpg.length);
// C way
var t2:int = getTimer();
var ba:ByteArray = b.getPixels(new Rectangle(0,0,320,200));
var ret:ByteArray = as3_jpeg_wrapper.write_jpeg_file(ba, 320, 200, 3, 2);
trace(" C JPEG ENCODING: "+(getTimer()-t2)+"ms.");
trace(" ret.length="+ret.length);
return ret;
}
}
}
Hello,
I have test the library for record some Jpeg file.
It's very fast, but i have a problem, how can I modify the source for add a new variable for change the compression ( Number between 0 to 100 )
Do you have any idea, because in the actual state, it's impossible to work with this code...
Thanks a lot for your help.
-Geo
@Geo: Check this blog post: http://www.websector.de/blog/2009/06/21/speed-up-jpeg-encoding-using-a lchemy/
There you will find a modification of metalbots example for changing the quality of a compression.
-Jens
North America
Europe, Middle East and Africa
Asia Pacific