I read images from the disk, resize them to a smaller size,, and then
simply convert them to JPEG.. I use JPEGAsyncEncoder for this..
Here is the code I wrote for your reference..
var fileStream= new air.FileStream();
fileStream.open(imageFile, air.FileMode.READ);
//reading image into bytearray and closing stream
var imgBytes = new air.ByteArray();
fileStream.readBytes(imgBytes);
fileStream.close();
//creating loader and injecting image bytes into it
tmploader[ I ]= new air.Loader();
tmploader[ I ].contentLoaderInfo.addEventListener( air.Event.COMPLETE,
function(e){
saveTheFile(e,i,propid);
tmploader[ I ].loadBytes( imgBytes, air.loaderContext );
function saveTheFile(){
// +++++++++++++++++++++++++++++++++++++++++++++++++
// here is where I had smoothing enabled,, is this the right way ?
tmploader[ I ].content.smoothing = true;
tmploader[ I ].content.height =(600/ tmploader.content.width) *
tmploader.content.height ;
tmploader[ I ].content.width =600;
var bd =new air.BitmapData(600,tmploader.content.height);
bd.draw(tmploader[ I ],null,null,null,null,true); // 6th
parameter is set to true for smoothing
// ++++++++++++++++++++++++++++++++++++++++++++++++
var encoder = new window.runtime.com.pfp.utils.JPEGAsyncEncoder(80);
encoder.PixelsPerIteration = 128;
encoder.addEventListener(
window.runtime.com.pfp.events.JPEGAsyncCompleteEvent.JPEGASYNC_COMPLET
E, function(e){
encodeDone(e, lastid, propid);
bd.dispose();
air.System.gc();
tmploader[ I ].unload();
});
encoder.encode(bd);
}
--- In [email protected], "Ralf Bokelberg"
<[EMAIL PROTECTED]> wrote:
>
> Actually i always found Flash/Flex to be rather good in converting
> images. What exactly is your workflow?
>
> Cheers
> Ralf.
>
> On Wed, Sep 24, 2008 at 4:46 PM, semelak1 <[EMAIL PROTECTED]> wrote:
> > Where can I get it from ?? I thought it is not yet available !!
> > My project is pending because of these low quality images...
> >
> > --- In [email protected], "Gregor Kiddie" <gkiddie@>
> > wrote:
> >
> >>
> >> There is a compiler that can take C / C++ code and output
> > Actionscript
> >> that you might want to take a look at.
> >>
> >>
> >>
> >> Gk.
> >>
> >> Gregor Kiddie
> >> Senior Developer
> >> INPS
> >>
> >> Tel: 01382 564343
> >>
> >> Registered address: The Bread Factory, 1a Broughton Street,
London
> > SW8
> >> 3QJ
> >>
> >> Registered Number: 1788577
> >>
> >> Registered in the UK
> >>
> >> Visit our Internet Web site at www.inps.co.uk
> >> <blocked::http://www.inps.co.uk/>
> >>
> >> The information in this internet email is confidential and is
> > intended
> >> solely for the addressee. Access, copying or re-use of
information
> > in it
> >> by anyone else is not authorised. Any views or opinions presented
> > are
> >> solely those of the author and do not necessarily represent those
of
> >> INPS or any of its affiliates. If you are not the intended
recipient
> >> please contact is.helpdesk@
> >>
> >> ________________________________
> >>
> >> From: [email protected]
[mailto:[EMAIL PROTECTED]
> > On
> >> Behalf Of semelak1
> >> Sent: 23 September 2008 09:45
> >> To: [email protected]
> >> Subject: [flexcoders] Re: Bad quality for JPEG encoded images
> >> ,,<***(sample images INSIDE)***>
> >>
> >>
> >>
> >> Is it possible to use external libraries with Flex/Air ??? Say I
> > found
> >> a c++ or c sharp class that does the image encoding,,, can I call
it
> >> and make use of it in my AIR application ??
> >>
> >> --- In [email protected]
> > <mailto:flexcoders%40yahoogroups.com>
> >> , "semelak1" <semelak1@> wrote:
> >> >
> >> > I have noticed that the quality of the images produced by the
> >> > JPEGEncoder does not match that of other encoders available
(i.e.
> >> > php's built in image compression functions from the gd library)
> >> >
> >> > Any explanation ? or hints/workarounds for improving the
quality
> > of
> >> > compressed images by JPEGEncoder ??
> >> >
> >> > Please have a look at the following samples:
> >> >
> >> > original image:
> >> > http://img212.imageshack.us/img212/5930/67624460qh5.jpg
> >> <http://img212.imageshack.us/img212/5930/67624460qh5.jpg>
> >> > Size: 110KB
> >> >
> >> > Image encoded with JPEGAsync (same effect with JPEGEncoder):
> >> > http://img136.imageshack.us/img136/3554/77570198qp0.jpg
> >> <http://img136.imageshack.us/img136/3554/77570198qp0.jpg>
> >> > Size:46.7KB
> >> >
> >> > Image encoded with Php's built-in functions (gd library):
> >> > http://img382.imageshack.us/img382/7751/1492if8.jpg
> >> <http://img382.imageshack.us/img382/7751/1492if8.jpg>
> >> > Size:33.4KB
> >> > Much smoother than the JPEGAsyncencoder and JPEGEncoder
version..
> >> and
> >> > smaller too
> >> >
> >> >
> >> > Any hints ? or workarounds to improve the quality of the
encoded
> >> > images ?
> >> >
> >>
> >
> >
>