Re: [flexcoders] Re: Exporting Charts as Image

2007-02-14 Thread Brendan Meutzner

Hey Paul,

It's in there... just not shown in the Language Reference documents if
that's where you're looking...  check out

corelib\src\trunk\src\actionscript3\com\adobe\images

Andrew Trice also has a tutorial on capturing UI to bitmap on his blog here:

http://www.cynergysystems.com/blogs/page/andrewtrice?entry=flex_2_bitmapdata_tricks_and


Brendan


On 2/14/07, Paul Whitelock [EMAIL PROTECTED] wrote:


  Hi Ely,

I'm also interested in creating bitmap in Flex and transferring it as
a JPG or PNG to the server. I took a look at the as3corelib but didn't
see anything in the documentation about working with bitmap/image
files. I could be I'm just missing it, so could you perhaps point out
where in the package/class the image tools are located?

Also, is there an example or documentation somewhere regarding how to
send a JPG or PNG created in a Flex application from a bitmap to
ColdFusion and have ColdFusion create the physical file on the server?

Thanks!

Paul

---
Paul Whitelock
Denver, Colorado

--- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Ely
Greenfield [EMAIL PROTECTED] wrote:


 Hi Prateek. There are various libraries around that allow you to capture
 a chart, or any other flex component, as a PNG or JPG. you could then
 upload that to the server, and do what you want with it.

 See:

 http://code.google.com/p/as3corelib/

 Ely.

 





--
Brendan Meutzner
Stretch Media - RIA Adobe Flex Development
[EMAIL PROTECTED]
http://www.stretchmedia.ca


RE: [flexcoders] Re: Exporting Charts as Image

2007-02-14 Thread Andrew Trice
Glad my blog entry helped. :-)

You can use the as3  PNGEncoder or JPGEncoder libraries at
http://code.google.com/p/as3corelib/ to do the image format conversion
within the flex application.  You can post it to a server using either
remoting, web service, or http service.  Remoting/AMF3 is fastest and
easiest, but the other methods work well too.  Remoting does not require
any base64 conversion for the binary data; you can send it across the
wire as is.

 

-Andy

 

This is from a previous post I wrote here on flexcoders...

 

If you are using AMF3 (RemoteObject), you can serialize binary data
without any conversion.  If you are trying a standard HTTP post, I would
use a HTTPService with the method= POST.  Then you have to Base64
encode the binary data and attach it to the parameters of the http
service.  On the server side, you will need to decode the base64 encoded
data back into binary.

 

Example:

 

mx:HTTPService 

id=httpService

   showBusyCursor=true

   useProxy=false

   method=POST

   resultFormat=text

   url=/BinaryData/cf/HTTPImageSave.cfm 

result=onResult('Data Saved via mx:HTTPService') 

fault=onFault(event) /

 

private function base64Encode( data : ByteArray ) : String

{

var encoder : Base64Encoder = new Base64Encoder();

encoder.encodeBytes( data );

return encoder.flush();

}

 

private function sendData() : void

{

var data : ByteArray = encoder.encode( myPngByteArray );  

var params : Object = { data : base64Encode( data ) };

httpService.send( params );

}

 

In ColdFusion, you can decode the base64 data simply by using the
toBinary function.  Other languages have similar functions as well.  

 

Just a FYI... using the JPG instead of PNG requires significantly less
bandwidth  time to post the data to the server.  Base64 encoding the
data also increases the size of the data being transferred across the
wire.  It is much more efficient to use a remoteObject method with
JPG-compressed data.

 

 

 

_

Andrew Trice

Cynergy Systems, Inc.

http://www.cynergysystems.com

 

Blog: http://www.cynergysystems.com/blogs/page/andrewtrice

Email: [EMAIL PROTECTED]

Office: 866-CYNERGY 

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Paul Whitelock
Sent: Wednesday, February 14, 2007 1:51 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Exporting Charts as Image

 

Thanks Brendan! I was indeed looking in the Language Reference
documents which is why I couldn't find anything.

In the last section of the Andrew Trice tutorial he's doing pretty
much what I'd like to do, but he doesn't supply the source. The piece
that I think I need is how to handle the data sent from Flex on the
ColdFusion side (i.e., how to create the JPG from a ByteArray sent
from Flex). Has anyone seen any tutorials or documentation on this?

Paul

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Brendan Meutzner [EMAIL PROTECTED]
wrote:

 Hey Paul,
 
 It's in there... just not shown in the Language Reference documents if
 that's where you're looking... check out
 
 corelib\src\trunk\src\actionscript3\com\adobe\images
 
 Andrew Trice also has a tutorial on capturing UI to bitmap on his
blog here:
 

http://www.cynergysystems.com/blogs/page/andrewtrice?entry=flex_2_bitmap
data_tricks_and
http://www.cynergysystems.com/blogs/page/andrewtrice?entry=flex_2_bitma
pdata_tricks_and 
 
 
 Brendan

 



RE: [flexcoders] Re: Exporting Charts as Image

2007-02-14 Thread Andrew Trice
Forgot this too... Here's an example how to use the encoder.

 

var jpegEncoder : JPEGEncoder = new JPEGEncoder(quality);

myEncodedByteArray = jpegEncoder.encode( bitmapData );

 

_

Andrew Trice

Cynergy Systems, Inc.

http://www.cynergysystems.com

 

Blog: http://www.cynergysystems.com/blogs/page/andrewtrice

Email: [EMAIL PROTECTED]

Office: 866-CYNERGY 

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Andrew Trice
Sent: Wednesday, February 14, 2007 2:15 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Re: Exporting Charts as Image

 

Glad my blog entry helped. :-)

You can use the as3  PNGEncoder or JPGEncoder libraries at
http://code.google.com/p/as3corelib/
http://code.google.com/p/as3corelib/  to do the image format
conversion within the flex application.  You can post it to a server
using either remoting, web service, or http service.  Remoting/AMF3 is
fastest and easiest, but the other methods work well too.  Remoting does
not require any base64 conversion for the binary data; you can send it
across the wire as is.

 

-Andy

 

This is from a previous post I wrote here on flexcoders...

 

If you are using AMF3 (RemoteObject), you can serialize binary data
without any conversion.  If you are trying a standard HTTP post, I would
use a HTTPService with the method= POST.  Then you have to Base64
encode the binary data and attach it to the parameters of the http
service.  On the server side, you will need to decode the base64 encoded
data back into binary.

 

Example:

 

mx:HTTPService 

id=httpService

   showBusyCursor=true

   useProxy=false

   method=POST

   resultFormat=text

   url=/BinaryData/cf/HTTPImageSave.cfm 

result=onResult('Data Saved via mx:HTTPService') 

fault=onFault(event) /

 

private function base64Encode( data : ByteArray ) : String

{

var encoder : Base64Encoder = new Base64Encoder();

encoder.encodeBytes( data );

return encoder.flush();

}

 

private function sendData() : void

{

var data : ByteArray = encoder.encode( myPngByteArray );  

var params : Object = { data : base64Encode( data ) };

httpService.send( params );

}

 

In ColdFusion, you can decode the base64 data simply by using the
toBinary function.  Other languages have similar functions as well.  

 

Just a FYI... using the JPG instead of PNG requires significantly less
bandwidth  time to post the data to the server.  Base64 encoding the
data also increases the size of the data being transferred across the
wire.  It is much more efficient to use a remoteObject method with
JPG-compressed data.

 

 

 

_

Andrew Trice

Cynergy Systems, Inc.

http://www.cynergysystems.com http://www.cynergysystems.com 

 

Blog: http://www.cynergysystems.com/blogs/page/andrewtrice
http://www.cynergysystems.com/blogs/page/andrewtrice 

Email: [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] 

Office: 866-CYNERGY 

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Paul Whitelock
Sent: Wednesday, February 14, 2007 1:51 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Exporting Charts as Image

 

Thanks Brendan! I was indeed looking in the Language Reference
documents which is why I couldn't find anything.

In the last section of the Andrew Trice tutorial he's doing pretty
much what I'd like to do, but he doesn't supply the source. The piece
that I think I need is how to handle the data sent from Flex on the
ColdFusion side (i.e., how to create the JPG from a ByteArray sent
from Flex). Has anyone seen any tutorials or documentation on this?

Paul

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Brendan Meutzner [EMAIL PROTECTED]
wrote:

 Hey Paul,
 
 It's in there... just not shown in the Language Reference documents if
 that's where you're looking... check out
 
 corelib\src\trunk\src\actionscript3\com\adobe\images
 
 Andrew Trice also has a tutorial on capturing UI to bitmap on his
blog here:
 

http://www.cynergysystems.com/blogs/page/andrewtrice?entry=flex_2_bitmap
data_tricks_and
http://www.cynergysystems.com/blogs/page/andrewtrice?entry=flex_2_bitma
pdata_tricks_and 
 
 
 Brendan

 



Re: [flexcoders] Re: Exporting Charts as Image

2007-02-14 Thread Brendan Meutzner

So Andrew... I'm curious... any insight into what you're doing in your
examples that you're not willing to share? :-)


Brendan



On 2/14/07, Andrew Trice [EMAIL PROTECTED] wrote:


   Forgot this too… Here's an example how to use the encoder.



var jpegEncoder : JPEGEncoder = new JPEGEncoder(quality);

myEncodedByteArray = jpegEncoder.encode( bitmapData );



_

*Andrew Trice*

Cynergy Systems, Inc.

http://www.cynergysystems.com



Blog: http://www.cynergysystems.com/blogs/page/andrewtrice

Email: [EMAIL PROTECTED]

Office: 866-CYNERGY


  --

*From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
Behalf Of *Andrew Trice
*Sent:* Wednesday, February 14, 2007 2:15 PM
*To:* flexcoders@yahoogroups.com
*Subject:* RE: [flexcoders] Re: Exporting Charts as Image



Glad my blog entry helped. J

You can use the as3  PNGEncoder or JPGEncoder libraries at
http://code.google.com/p/as3corelib/ to do the image format conversion
within the flex application.  You can post it to a server using either
remoting, web service, or http service.  Remoting/AMF3 is fastest and
easiest, but the other methods work well too.  Remoting does not require any
base64 conversion for the binary data; you can send it across the wire as
is.



-Andy



This is from a previous post I wrote here on flexcoders…



If you are using AMF3 (RemoteObject), you can serialize binary data
without any conversion.  If you are trying a standard HTTP post, I would use
a HTTPService with the method= POST.  Then you have to Base64 encode the
binary data and attach it to the parameters of the http service.  On the
server side, you will need to decode the base64 encoded data back into
binary.



Example:



mx:HTTPService

id=httpService

   showBusyCursor=true

   useProxy=false

   method=POST

   resultFormat=text

   url=/BinaryData/cf/HTTPImageSave.cfm

result=onResult('Data Saved via mx:HTTPService')

fault=onFault(event) /



private function base64Encode( data : ByteArray ) : String

{

var encoder : Base64Encoder = new Base64Encoder();

encoder.encodeBytes( data );

return encoder.flush();

}



private function sendData() : void

{

var data : ByteArray = encoder.encode( myPngByteArray );

var params : Object = { data : base64Encode( data ) };

httpService.send( params );

}



In ColdFusion, you can decode the base64 data simply by using the
toBinary function.  Other languages have similar functions as well.



Just a FYI… using the JPG instead of PNG requires significantly less
bandwidth  time to post the data to the server.  Base64 encoding the data
also increases the size of the data being transferred across the wire.  It
is much more efficient to use a remoteObject method with JPG-compressed
data.







_

*Andrew Trice*

Cynergy Systems, Inc.

http://www.cynergysystems.com



Blog: http://www.cynergysystems.com/blogs/page/andrewtrice

Email: [EMAIL PROTECTED]

Office: 866-CYNERGY


  --

*From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
Behalf Of *Paul Whitelock
*Sent:* Wednesday, February 14, 2007 1:51 PM
*To:* flexcoders@yahoogroups.com
*Subject:* [flexcoders] Re: Exporting Charts as Image



Thanks Brendan! I was indeed looking in the Language Reference
documents which is why I couldn't find anything.

In the last section of the Andrew Trice tutorial he's doing pretty
much what I'd like to do, but he doesn't supply the source. The piece
that I think I need is how to handle the data sent from Flex on the
ColdFusion side (i.e., how to create the JPG from a ByteArray sent
from Flex). Has anyone seen any tutorials or documentation on this?

Paul

--- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Brendan
Meutzner [EMAIL PROTECTED]
wrote:

 Hey Paul,

 It's in there... just not shown in the Language Reference documents if
 that's where you're looking... check out

 corelib\src\trunk\src\actionscript3\com\adobe\images

 Andrew Trice also has a tutorial on capturing UI to bitmap on his
blog here:



http://www.cynergysystems.com/blogs/page/andrewtrice?entry=flex_2_bitmapdata_tricks_and


 Brendan

 





--
Brendan Meutzner
Stretch Media - RIA Adobe Flex Development
[EMAIL PROTECTED]
http://www.stretchmedia.ca


RE: [flexcoders] Re: Exporting Charts as Image

2007-02-14 Thread Andrew Trice
Nothing too fancy... It will be in next month's issue of Web Designer 
Developer's Journal, I'm waiting until then to release the code on my
blog.

 

_

Andrew Trice

Cynergy Systems, Inc.

http://www.cynergysystems.com

 

Blog: http://www.cynergysystems.com/blogs/page/andrewtrice

Email: [EMAIL PROTECTED]

Office: 866-CYNERGY 

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Brendan Meutzner
Sent: Wednesday, February 14, 2007 2:34 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re: Exporting Charts as Image

 

So Andrew... I'm curious... any insight into what you're doing in your
examples that you're not willing to share? :-)


Brendan




On 2/14/07, Andrew Trice [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]  wrote:

Forgot this too... Here's an example how to use the encoder.

 

var jpegEncoder : JPEGEncoder = new JPEGEncoder(quality);

myEncodedByteArray = jpegEncoder.encode( bitmapData );

 

_

Andrew Trice

Cynergy Systems, Inc.

http://www.cynergysystems.com http://www.cynergysystems.com 

 

Blog: http://www.cynergysystems.com/blogs/page/andrewtrice
http://www.cynergysystems.com/blogs/page/andrewtrice 

Email: [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] 

Office: 866-CYNERGY 

 



From: flexcoders@yahoogroups.com [mailto: flexcoders@
mailto:flexcoders@ yahoogroups.com http://yahoogroups.com ] On
Behalf Of Andrew Trice
Sent: Wednesday, February 14, 2007 2:15 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Re: Exporting Charts as Image

 

Glad my blog entry helped. :-)

You can use the as3  PNGEncoder or JPGEncoder libraries at
http://code.google.com/p/as3corelib/
http://code.google.com/p/as3corelib/  to do the image format
conversion within the flex application.  You can post it to a server
using either remoting, web service, or http service.  Remoting/AMF3 is
fastest and easiest, but the other methods work well too.  Remoting does
not require any base64 conversion for the binary data; you can send it
across the wire as is.

 

-Andy

 

This is from a previous post I wrote here on flexcoders...

 

If you are using AMF3 (RemoteObject), you can serialize binary data
without any conversion.  If you are trying a standard HTTP post, I would
use a HTTPService with the method= POST.  Then you have to Base64
encode the binary data and attach it to the parameters of the http
service.  On the server side, you will need to decode the base64 encoded
data back into binary.

 

Example:

 

mx:HTTPService 

id=httpService

   showBusyCursor=true

   useProxy=false

   method=POST

   resultFormat=text

   url=/BinaryData/cf/HTTPImageSave.cfm 

result=onResult('Data Saved via mx:HTTPService') 

fault=onFault(event) /

 

private function base64Encode( data : ByteArray ) : String

{

var encoder : Base64Encoder = new Base64Encoder();

encoder.encodeBytes( data );

return encoder.flush();

}

 

private function sendData() : void

{

var data : ByteArray = encoder.encode( myPngByteArray );  

var params : Object = { data : base64Encode( data ) };

httpService.send( params );

}

 

In ColdFusion, you can decode the base64 data simply by using the
toBinary function.  Other languages have similar functions as well.  

 

Just a FYI... using the JPG instead of PNG requires significantly less
bandwidth  time to post the data to the server.  Base64 encoding the
data also increases the size of the data being transferred across the
wire.  It is much more efficient to use a remoteObject method with
JPG-compressed data.

 

 

 

_

Andrew Trice

Cynergy Systems, Inc.

http://www.cynergysystems.com http://www.cynergysystems.com 

 

Blog: http://www.cynergysystems.com/blogs/page/andrewtrice
http://www.cynergysystems.com/blogs/page/andrewtrice 

Email: [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] 

Office: 866-CYNERGY 

 



From: [EMAIL PROTECTED] ups.com [mailto:flexcoders@ yahoogroups.com
http://yahoogroups.com ] On Behalf Of Paul Whitelock
Sent: Wednesday, February 14, 2007 1:51 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Exporting Charts as Image

 

Thanks Brendan! I was indeed looking in the Language Reference
documents which is why I couldn't find anything.

In the last section of the Andrew Trice tutorial he's doing pretty
much what I'd like to do, but he doesn't supply the source. The piece
that I think I need is how to handle the data sent from Flex on the
ColdFusion side (i.e., how to create the JPG from a ByteArray sent
from Flex). Has anyone seen any tutorials or documentation on this?

Paul

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Brendan Meutzner [EMAIL PROTECTED]
wrote:

 Hey Paul,
 
 It's in there... just not shown in the Language Reference

RE: [flexcoders] Re: Exporting Charts as Image

2007-02-14 Thread Andrew Trice
In it's most simple form:  this is all you need to do in CF.  You don't
need to convert it.  It comes over AMF as binary data.

 

cffunction name=save access=remote output=false
returntype=void
cfargument name=data type=binary required=true /
cffile action=write file=c:\temp\data.jpg
output=#arguments.data# /
/cffunction

 

You only need to use tobinary if you are sending it as base64 encoded
data across a web service or http service.

-Andy

_

Andrew Trice

Cynergy Systems, Inc.

http://www.cynergysystems.com

 

Blog: http://www.cynergysystems.com/blogs/page/andrewtrice

Email: [EMAIL PROTECTED]

Office: 866-CYNERGY 

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Paul Whitelock
Sent: Wednesday, February 14, 2007 2:32 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Exporting Charts as Image

 

Hi Andy,

I'm using remoting/AMF in other parts of my application, so I don't
think I'll have a problem sending the data to ColdFusion after it's
prepared. I just wasn't sure what to do with the data once I got it to
ColdFusion to turn it into a file (I'm fairly new to ColdFusion).

I'll take a look at the ColdFusion toBinary function and I assume that
after the data comes out of toBinary I can write the file using
cffile. Anyway, it gives me a foothold to get started :-) Thanks!

Paul

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Andrew Trice [EMAIL PROTECTED]
wrote:

 Glad my blog entry helped. :-) 
 
 You can use the as3 PNGEncoder or JPGEncoder libraries at
 http://code.google.com/p/as3corelib/
http://code.google.com/p/as3corelib/  to do the image format
conversion
 within the flex application. You can post it to a server using either
 remoting, web service, or http service. Remoting/AMF3 is fastest and
 easiest, but the other methods work well too. Remoting does not
require
 any base64 conversion for the binary data; you can send it across the
 wire as is.
 
 
 
 -Andy
 
 
 
 This is from a previous post I wrote here on flexcoders...
 
 
 
 If you are using AMF3 (RemoteObject), you can serialize binary data
 without any conversion. If you are trying a standard HTTP post, I
would
 use a HTTPService with the method= POST. Then you have to Base64
 encode the binary data and attach it to the parameters of the http
 service. On the server side, you will need to decode the base64
encoded
 data back into binary.
 
 
 
 Example:
 
 
 
 mx:HTTPService 
 
 id=httpService
 
 showBusyCursor=true
 
 useProxy=false
 
 method=POST
 
 resultFormat=text
 
 url=/BinaryData/cf/HTTPImageSave.cfm 
 
 result=onResult('Data Saved via mx:HTTPService') 
 
 fault=onFault(event) /
 
 
 
 private function base64Encode( data : ByteArray ) : String
 
 {
 
 var encoder : Base64Encoder = new Base64Encoder();
 
 encoder.encodeBytes( data );
 
 return encoder.flush();
 
 }
 
 
 
 private function sendData() : void
 
 {
 
 var data : ByteArray = encoder.encode( myPngByteArray ); 
 
 var params : Object = { data : base64Encode( data ) };
 
 httpService.send( params );
 
 }
 
 
 
 In ColdFusion, you can decode the base64 data simply by using the
 toBinary function. Other languages have similar functions as well. 
 
 
 
 Just a FYI... using the JPG instead of PNG requires significantly less
 bandwidth  time to post the data to the server. Base64 encoding the
 data also increases the size of the data being transferred across the
 wire. It is much more efficient to use a remoteObject method with
 JPG-compressed data.
 
 _
 
 Andrew Trice
 
 Cynergy Systems, Inc.
 
 http://www.cynergysystems.com http://www.cynergysystems.com 
 
 
 
 Blog: http://www.cynergysystems.com/blogs/page/andrewtrice
http://www.cynergysystems.com/blogs/page/andrewtrice 
 
 Email: [EMAIL PROTECTED]
 
 Office: 866-CYNERGY 

 



RE: [flexcoders] Re: Exporting Charts as Image

2007-02-14 Thread Andrew Trice
Revision... I'm waiting until then to release the full code (flex and
CF).  I just posted code a few minutes ago to do a very basic save
function in a cfc.  It's very basic though, no locks or try catch to
prevent real-world and synchronization errors.

 

_

Andrew Trice

Cynergy Systems, Inc.

http://www.cynergysystems.com

 

Blog: http://www.cynergysystems.com/blogs/page/andrewtrice

Email: [EMAIL PROTECTED]

Office: 866-CYNERGY 

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Andrew Trice
Sent: Wednesday, February 14, 2007 2:45 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Re: Exporting Charts as Image

 

Nothing too fancy... It will be in next month's issue of Web Designer 
Developer's Journal, I'm waiting until then to release the code on my
blog.

 

_

Andrew Trice

Cynergy Systems, Inc.

http://www.cynergysystems.com http://www.cynergysystems.com 

 

Blog: http://www.cynergysystems.com/blogs/page/andrewtrice
http://www.cynergysystems.com/blogs/page/andrewtrice 

Email: [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] 

Office: 866-CYNERGY 

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Brendan Meutzner
Sent: Wednesday, February 14, 2007 2:34 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re: Exporting Charts as Image

 

So Andrew... I'm curious... any insight into what you're doing in your
examples that you're not willing to share? :-)


Brendan





On 2/14/07, Andrew Trice [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]  wrote:

Forgot this too... Here's an example how to use the encoder.

 

var jpegEncoder : JPEGEncoder = new JPEGEncoder(quality);

myEncodedByteArray = jpegEncoder.encode( bitmapData );

 

_

Andrew Trice

Cynergy Systems, Inc.

http://www.cynergysystems.com http://www.cynergysystems.com 

 

Blog: http://www.cynergysystems.com/blogs/page/andrewtrice
http://www.cynergysystems.com/blogs/page/andrewtrice 

Email: [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] 

Office: 866-CYNERGY 

 



From: flexcoders@yahoogroups.com [mailto: flexcoders@
mailto:flexcoders@ yahoogroups.com http://yahoogroups.com ] On
Behalf Of Andrew Trice
Sent: Wednesday, February 14, 2007 2:15 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Re: Exporting Charts as Image

 

Glad my blog entry helped. :-)

You can use the as3  PNGEncoder or JPGEncoder libraries at
http://code.google.com/p/as3corelib/
http://code.google.com/p/as3corelib/  to do the image format
conversion within the flex application.  You can post it to a server
using either remoting, web service, or http service.  Remoting/AMF3 is
fastest and easiest, but the other methods work well too.  Remoting does
not require any base64 conversion for the binary data; you can send it
across the wire as is.

 

-Andy

 

This is from a previous post I wrote here on flexcoders...

 

If you are using AMF3 (RemoteObject), you can serialize binary data
without any conversion.  If you are trying a standard HTTP post, I would
use a HTTPService with the method= POST.  Then you have to Base64
encode the binary data and attach it to the parameters of the http
service.  On the server side, you will need to decode the base64 encoded
data back into binary.

 

Example:

 

mx:HTTPService 

id=httpService

   showBusyCursor=true

   useProxy=false

   method=POST

   resultFormat=text

   url=/BinaryData/cf/HTTPImageSave.cfm 

result=onResult('Data Saved via mx:HTTPService') 

fault=onFault(event) /

 

private function base64Encode( data : ByteArray ) : String

{

var encoder : Base64Encoder = new Base64Encoder();

encoder.encodeBytes( data );

return encoder.flush();

}

 

private function sendData() : void

{

var data : ByteArray = encoder.encode( myPngByteArray );  

var params : Object = { data : base64Encode( data ) };

httpService.send( params );

}

 

In ColdFusion, you can decode the base64 data simply by using the
toBinary function.  Other languages have similar functions as well.  

 

Just a FYI... using the JPG instead of PNG requires significantly less
bandwidth  time to post the data to the server.  Base64 encoding the
data also increases the size of the data being transferred across the
wire.  It is much more efficient to use a remoteObject method with
JPG-compressed data.

 

 

 

_

Andrew Trice

Cynergy Systems, Inc.

http://www.cynergysystems.com http://www.cynergysystems.com 

 

Blog: http://www.cynergysystems.com/blogs/page/andrewtrice
http://www.cynergysystems.com/blogs/page/andrewtrice 

Email: [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] 

Office: 866-CYNERGY 

 



From: [EMAIL PROTECTED] ups.com [mailto:flexcoders