Re: [Flashcoders] Binary Data Question

2008-08-16 Thread Juan Pablo Califano
I haven't used amfphp extensively, but it might be a problem in the type
of data amfphp expects... I'm not sure this is a good idea:

ba.toString()

As with a JPG you'll sure get lots of 0's in the ByteArray; parsed as a char
in a string, a 0 value is what's known as an embedded null, which
traditionally is used to signal the end of the string, so probably at some
point the data is being truncated.

Maybe if you just send the ByteArray object, amfphp will figure out the type
of the object and will be able to deserialize it correctly. I think that's
the whole idea behind amfphp, it automatically serializes and deserializes
native objects using the amf format.


Cheers
Juan Pablo Califano


2008/8/16, Omar Fouad [EMAIL PROTECTED]:

 well I've been trying this amfphp and it does not work. amfphp responds
 back
 an error saying amfphp_runtime_error.

 I have this php file in the services dir which hace this function  that I
 call throuh actionscript

 function getData($image)
 {
$data = mysql_query(Insert into table01 (image) values
 ('$image'));
if($data == null) {
   return false;
}eles{
   return true;
   }
 }

 in the mysql database there is a longblob field image and in fd I wrote:

 [Embed(source = 'mail[1].jpg')]
private var _img:Class;
private var img:Bitmap = new _img();

private var gw:NetConnection;
private var res:Responder;
private var TF:TextField = new TextField();

private var ba:ByteArray;
private var encoder:JPGEncoder;
private var bd:BitmapData;

public function Main():void {

TF.autoSize  = TextFieldAutoSize.LEFT;
addChild(TF);

bd = new BitmapData(img.width, img.height);
bd.draw(img);
encoder = new JPGEncoder(90);
ba = encoder.encode(bd);

gw = new NetConnection();
gw.connect(http://localhost/amfphp/amfphp/gateway.php;);
res = new Responder(onResult, onFault);
gw.call(Test.getData, res, ba.toString());
}

private function onResult(responds:Object):void {
TF.text = String(responds);
}

private function onFault(responds:Object):void {
for (var i:* in responds) {
TF.text = String(responds[i]);
}
}

 Is there something I missed in the AS or PHP?

 Thanks



 On Sat, Aug 16, 2008 at 2:16 AM, Omar Fouad [EMAIL PROTECTED]
 wrote:

  Thanks.. I will try this now and feed you back.
 
 
 
  On Sat, Aug 16, 2008 at 1:41 AM, Juan Pablo Califano 
  [EMAIL PROTECTED] wrote:
 
  Yes. Using that particular class I mentioned, from the php side you'd
  receive the data like a regular html form post with multipart-encode,
 that
  means, you can retrieve the text variables you want to send with
  $_POST['someVar'] and the file (or files) with $_FILES['varName'] (or
 the
  name you choose). Treat it like if it were a html form.
 
  To add a text field to the form use the add
 addField(varName,varValue)
  method; to add a file, use addFile(varName, jpgByteArray,
  originalFileName, imageMimeType);
 
  For originalFileName, use whatever you want, like image.jpg, it
  doesn't
  really matter. That's what you'll get with $_FILES['varName']['name'].
 For
  the imageMimeType, use the constant in the class for JPG.
 
 
  Cheers
  Juan Pablo Califano
 
  2008/8/15, Omar Fouad [EMAIL PROTECTED]:
  
   I guess I can send the ByteArray to the php that will handle its
  insertion
   to the database. Right?
  
   On Fri, Aug 15, 2008 at 7:07 PM, Juan Pablo Califano 
   [EMAIL PROTECTED] wrote:
  
With the newest player, I think, it's possible to save data into the
   USER's
hard drive without a trip to the server, but you want to store the
  data
   on
the server side, you need to send it to the server...
   
You have to post that data using a URLLoader object, and specifying
  the
input as binary data.
   
I've wrapped up some code to do that and being able to pass
 variables
  as
well. If you want to check it out:
   
http://pastebin.com/f11a897cf
   
(Sorry, comments are in Spanish, but the indentifiers are in
 English)
   
A example of use (it's a copy  paste from some wortking code, just
 to
   give
you an idea):
   
   
import ar.com.califa010.utils.FormData;
   
  // getEncodedImg() is a method that returns a JPG as a byteArray
   
  var rawJpg:ByteArray = getEncodedImg();
  var formData:FormData = new FormData();
   
  var imageMimeType:String = FormData.JPG_FILE;
  var fileName:String = imageFile.jpg;
   
  formData.addFile(imageFile, rawJpg, fileName, imageMimeType);
   
   
  formData.addField(sFormat,imgFormat);
  formData.addField(idImagen,_idImagen);
   
  var req:URLRequest  = new URLRequest(url);
   
  req.method   = POST;
  req.contentType  = formData.contentType;
  req.data   = 

Re: [Flashcoders] Binary Data Question

2008-08-16 Thread Omar Fouad
When I use ba without toString() amfphp says Object of class ByteArray
could not be converted to string.
I think there is something to be done in the php to convert the data back
from string into binary data, but I cannot find it out.

Ideas?

On Sat, Aug 16, 2008 at 9:02 PM, Juan Pablo Califano 
[EMAIL PROTECTED] wrote:

 I haven't used amfphp extensively, but it might be a problem in the type
 of data amfphp expects... I'm not sure this is a good idea:

 ba.toString()

 As with a JPG you'll sure get lots of 0's in the ByteArray; parsed as a
 char
 in a string, a 0 value is what's known as an embedded null, which
 traditionally is used to signal the end of the string, so probably at some
 point the data is being truncated.

 Maybe if you just send the ByteArray object, amfphp will figure out the
 type
 of the object and will be able to deserialize it correctly. I think that's
 the whole idea behind amfphp, it automatically serializes and deserializes
 native objects using the amf format.


 Cheers
 Juan Pablo Califano


 2008/8/16, Omar Fouad [EMAIL PROTECTED]:
 
  well I've been trying this amfphp and it does not work. amfphp responds
  back
  an error saying amfphp_runtime_error.
 
  I have this php file in the services dir which hace this function  that I
  call throuh actionscript
 
  function getData($image)
  {
 $data = mysql_query(Insert into table01 (image) values
  ('$image'));
 if($data == null) {
return false;
 }eles{
return true;
}
  }
 
  in the mysql database there is a longblob field image and in fd I wrote:
 
  [Embed(source = 'mail[1].jpg')]
 private var _img:Class;
 private var img:Bitmap = new _img();
 
 private var gw:NetConnection;
 private var res:Responder;
 private var TF:TextField = new TextField();
 
 private var ba:ByteArray;
 private var encoder:JPGEncoder;
 private var bd:BitmapData;
 
 public function Main():void {
 
 TF.autoSize  = TextFieldAutoSize.LEFT;
 addChild(TF);
 
 bd = new BitmapData(img.width, img.height);
 bd.draw(img);
 encoder = new JPGEncoder(90);
 ba = encoder.encode(bd);
 
 gw = new NetConnection();
 gw.connect(http://localhost/amfphp/amfphp/gateway.php;);
 res = new Responder(onResult, onFault);
 gw.call(Test.getData, res, ba.toString());
 }
 
 private function onResult(responds:Object):void {
 TF.text = String(responds);
 }
 
 private function onFault(responds:Object):void {
 for (var i:* in responds) {
 TF.text = String(responds[i]);
 }
 }
 
  Is there something I missed in the AS or PHP?
 
  Thanks
 
 
 
  On Sat, Aug 16, 2008 at 2:16 AM, Omar Fouad [EMAIL PROTECTED]
  wrote:
 
   Thanks.. I will try this now and feed you back.
  
  
  
   On Sat, Aug 16, 2008 at 1:41 AM, Juan Pablo Califano 
   [EMAIL PROTECTED] wrote:
  
   Yes. Using that particular class I mentioned, from the php side you'd
   receive the data like a regular html form post with multipart-encode,
  that
   means, you can retrieve the text variables you want to send with
   $_POST['someVar'] and the file (or files) with $_FILES['varName'] (or
  the
   name you choose). Treat it like if it were a html form.
  
   To add a text field to the form use the add
  addField(varName,varValue)
   method; to add a file, use addFile(varName, jpgByteArray,
   originalFileName, imageMimeType);
  
   For originalFileName, use whatever you want, like image.jpg, it
   doesn't
   really matter. That's what you'll get with $_FILES['varName']['name'].
  For
   the imageMimeType, use the constant in the class for JPG.
  
  
   Cheers
   Juan Pablo Califano
  
   2008/8/15, Omar Fouad [EMAIL PROTECTED]:
   
I guess I can send the ByteArray to the php that will handle its
   insertion
to the database. Right?
   
On Fri, Aug 15, 2008 at 7:07 PM, Juan Pablo Califano 
[EMAIL PROTECTED] wrote:
   
 With the newest player, I think, it's possible to save data into
 the
USER's
 hard drive without a trip to the server, but you want to store the
   data
on
 the server side, you need to send it to the server...

 You have to post that data using a URLLoader object, and
 specifying
   the
 input as binary data.

 I've wrapped up some code to do that and being able to pass
  variables
   as
 well. If you want to check it out:

 http://pastebin.com/f11a897cf

 (Sorry, comments are in Spanish, but the indentifiers are in
  English)

 A example of use (it's a copy  paste from some wortking code,
 just
  to
give
 you an idea):


 import ar.com.califa010.utils.FormData;

   // getEncodedImg() is a method that returns a JPG as a byteArray

   var rawJpg:ByteArray = 

Re: [Flashcoders] Binary Data Question

2008-08-16 Thread Juan Pablo Califano
Maybe you don't have a version of amfphp that supports AS 3.0 objects...

Check this out:

http://www.sephiroth.it/tutorials/flashPHP/amfphp_bytearray/

On the other hand, if using amfphp is not a requirement, you could just use
the class I posted, and handle things from the php side as if it were a
regular html form post.

Cheers
Juan Pablo Califano

2008/8/16, Omar Fouad [EMAIL PROTECTED]:

 When I use ba without toString() amfphp says Object of class ByteArray
 could not be converted to string.
 I think there is something to be done in the php to convert the data back
 from string into binary data, but I cannot find it out.

 Ideas?

 On Sat, Aug 16, 2008 at 9:02 PM, Juan Pablo Califano 
 [EMAIL PROTECTED] wrote:

  I haven't used amfphp extensively, but it might be a problem in the type
  of data amfphp expects... I'm not sure this is a good idea:
 
  ba.toString()
 
  As with a JPG you'll sure get lots of 0's in the ByteArray; parsed as a
  char
  in a string, a 0 value is what's known as an embedded null, which
  traditionally is used to signal the end of the string, so probably at
 some
  point the data is being truncated.
 
  Maybe if you just send the ByteArray object, amfphp will figure out the
  type
  of the object and will be able to deserialize it correctly. I think
 that's
  the whole idea behind amfphp, it automatically serializes and
 deserializes
  native objects using the amf format.
 
 
  Cheers
  Juan Pablo Califano
 
 
  2008/8/16, Omar Fouad [EMAIL PROTECTED]:
  
   well I've been trying this amfphp and it does not work. amfphp responds
   back
   an error saying amfphp_runtime_error.
  
   I have this php file in the services dir which hace this function  that
 I
   call throuh actionscript
  
   function getData($image)
   {
  $data = mysql_query(Insert into table01 (image) values
   ('$image'));
  if($data == null) {
 return false;
  }eles{
 return true;
 }
   }
  
   in the mysql database there is a longblob field image and in fd I
 wrote:
  
   [Embed(source = 'mail[1].jpg')]
  private var _img:Class;
  private var img:Bitmap = new _img();
  
  private var gw:NetConnection;
  private var res:Responder;
  private var TF:TextField = new TextField();
  
  private var ba:ByteArray;
  private var encoder:JPGEncoder;
  private var bd:BitmapData;
  
  public function Main():void {
  
  TF.autoSize  = TextFieldAutoSize.LEFT;
  addChild(TF);
  
  bd = new BitmapData(img.width, img.height);
  bd.draw(img);
  encoder = new JPGEncoder(90);
  ba = encoder.encode(bd);
  
  gw = new NetConnection();
  gw.connect(http://localhost/amfphp/amfphp/gateway.php;);
  res = new Responder(onResult, onFault);
  gw.call(Test.getData, res, ba.toString());
  }
  
  private function onResult(responds:Object):void {
  TF.text = String(responds);
  }
  
  private function onFault(responds:Object):void {
  for (var i:* in responds) {
  TF.text = String(responds[i]);
  }
  }
  
   Is there something I missed in the AS or PHP?
  
   Thanks
  
  
  
   On Sat, Aug 16, 2008 at 2:16 AM, Omar Fouad [EMAIL PROTECTED]
   wrote:
  
Thanks.. I will try this now and feed you back.
   
   
   
On Sat, Aug 16, 2008 at 1:41 AM, Juan Pablo Califano 
[EMAIL PROTECTED] wrote:
   
Yes. Using that particular class I mentioned, from the php side
 you'd
receive the data like a regular html form post with
 multipart-encode,
   that
means, you can retrieve the text variables you want to send with
$_POST['someVar'] and the file (or files) with $_FILES['varName']
 (or
   the
name you choose). Treat it like if it were a html form.
   
To add a text field to the form use the add
   addField(varName,varValue)
method; to add a file, use addFile(varName, jpgByteArray,
originalFileName, imageMimeType);
   
For originalFileName, use whatever you want, like image.jpg, it
doesn't
really matter. That's what you'll get with
 $_FILES['varName']['name'].
   For
the imageMimeType, use the constant in the class for JPG.
   
   
Cheers
Juan Pablo Califano
   
2008/8/15, Omar Fouad [EMAIL PROTECTED]:

 I guess I can send the ByteArray to the php that will handle its
insertion
 to the database. Right?

 On Fri, Aug 15, 2008 at 7:07 PM, Juan Pablo Califano 
 [EMAIL PROTECTED] wrote:

  With the newest player, I think, it's possible to save data into
  the
 USER's
  hard drive without a trip to the server, but you want to store
 the
data
 on
  the server side, you need to send it to the server...
 
  You have to post that data using a URLLoader object, and
  specifying
the
  

Re: [Flashcoders] Binary Data Question

2008-08-15 Thread Glen Pike

Hi,

   Sorry, I put this in the wrong thread before - here is my 2c

   Hi,

  There are a few examples on the www about sending Bitmap data to the 
server Mario's is a good starting point - 
http://www.quasimondo.com/archives/000572.php  Anyway, there are 
other examples about which do compression/decompression on your data so 
you could save it into your DB too..


  Hope this is useful

  Glen
--

Glen Pike
01326 218440
www.glenpike.co.uk http://www.glenpike.co.uk

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Binary Data Question

2008-08-15 Thread Omar Fouad
I see, all those tutorials shows how to save the image on the Hard Drive
(now with flash player is possible to do this without any server side
script).

But considering my question, what I should be putting in my database row,
the byteArray encoded by JPGEncoder?
Is there a method into this class that takes the ByteArray from the database
back, and translates it into a bitmap to be shown in the swf?

On Fri, Aug 15, 2008 at 12:42 PM, Glen Pike [EMAIL PROTECTED]wrote:

 Hi,

   Sorry, I put this in the wrong thread before - here is my 2c

   Hi,

  There are a few examples on the www about sending Bitmap data to the
 server Mario's is a good starting point -
 http://www.quasimondo.com/archives/000572.php  Anyway, there are other
 examples about which do compression/decompression on your data so you could
 save it into your DB too..

  Hope this is useful

  Glen
 --

 Glen Pike
 01326 218440
 www.glenpike.co.uk http://www.glenpike.co.uk


 __
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




-- 
Omar M. Fouad - Digital Emotions
http://www.omarfouad.net

This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Binary Data Question

2008-08-15 Thread Glen Pike

Hi,

   You can't save an image from Flash without a server side script...

   Mario's example sends an image to the server, then uses 
FileReference to download it, or something similar.  If you want to 
store the image data, you would need to have 2 scripts - one to format 
it nicely and then put it in the database - Mario's script saves to a 
temporary file, you need to save the data to your DB here and get the id 
back.  The other one which takes in an ID of the data in the database 
and then echoes out headers and the data which means your browser / 
Flash will see an image.


   Mario's example PHP script is pretty chunky and not very easy to see 
where you would split the two bits of functionality, but instead of 
writing a temporary image file, you would store your data in a database 
and return the mysql_insert_id() to Flash, or similar.


   Then you can use this ID to retrieve the image using a second 
script.  Provided you have encoded your JPG nicely, you can splurge it 
out - here are some searches that may help, but the basic principle is 
that you can do something like this:


   ?php
 
   ob_start();

  $error = false;
  $data = null;
  //You would need to write these functions the ob_start  ob_end 
stops you getting errors...
  $id = sanitizeUserInput($_REQUEST['imageid']);  // should return 
a nice number for your database ID, or FALSE if you have a problem

  if(FALSE === $id) {
 $error = true;
   } else {
  $data = readDataFromDB($id);  //should output your data as an 
entire JPEG file or return FALSE if you have a problem.

}
  if(FALSE === $data) {
 $error = true;
   }
  ob_end_clean();
  if(false == $error) {
  header(Content-type: image/jpeg);
  echo $data;
  } else {
 header(HTTP/1.0 404 Not Found);
  }
  exit();
   ?

   Some searches that might help you find some examples...

   
http://www.google.co.uk/search?hl=enq=php+echo+image+from+databasebtnG=Google+Searchmeta= 
http://www.google.co.uk/search?hl=enq=php+echo+image+from+databasebtnG=Google+Searchmeta=


   
http://www.google.co.uk/search?hl=ensa=Xoi=spellresnum=0ct=resultcd=1q=php+read+image+from+database+blobspell=1 
http://www.google.co.uk/search?hl=ensa=Xoi=spellresnum=0ct=resultcd=1q=php+read+image+from+database+blobspell=1


   Hope this helps a bit - it's a long time since I did any image 
manipulation in PHP, so apologies if the answers are a bit vague, but 
there are loads of examples out there for this.


   Glen

  


Omar Fouad wrote:

I see, all those tutorials shows how to save the image on the Hard Drive
(now with flash player is possible to do this without any server side
script).

But considering my question, what I should be putting in my database row,
the byteArray encoded by JPGEncoder?
Is there a method into this class that takes the ByteArray from the database
back, and translates it into a bitmap to be shown in the swf?

On Fri, Aug 15, 2008 at 12:42 PM, Glen Pike [EMAIL PROTECTED]wrote:

  

Hi,

  Sorry, I put this in the wrong thread before - here is my 2c

  Hi,

 There are a few examples on the www about sending Bitmap data to the
server Mario's is a good starting point -
http://www.quasimondo.com/archives/000572.php  Anyway, there are other
examples about which do compression/decompression on your data so you could
save it into your DB too..

 Hope this is useful

 Glen
--

Glen Pike
01326 218440
www.glenpike.co.uk http://www.glenpike.co.uk


__
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders






  


--

Glen Pike
01326 218440
www.glenpike.co.uk http://www.glenpike.co.uk

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Binary Data Question

2008-08-15 Thread Omar Fouad
I mean that You can save files to HDD now without using server side script
with the new flash player 10.

On Fri, Aug 15, 2008 at 6:16 PM, Glen Pike [EMAIL PROTECTED]wrote:

 Hi,

   You can't save an image from Flash without a server side script...

   Mario's example sends an image to the server, then uses FileReference to
 download it, or something similar.  If you want to store the image data, you
 would need to have 2 scripts - one to format it nicely and then put it in
 the database - Mario's script saves to a temporary file, you need to save
 the data to your DB here and get the id back.  The other one which takes in
 an ID of the data in the database and then echoes out headers and the data
 which means your browser / Flash will see an image.

   Mario's example PHP script is pretty chunky and not very easy to see
 where you would split the two bits of functionality, but instead of writing
 a temporary image file, you would store your data in a database and return
 the mysql_insert_id() to Flash, or similar.

   Then you can use this ID to retrieve the image using a second script.
  Provided you have encoded your JPG nicely, you can splurge it out - here
 are some searches that may help, but the basic principle is that you can do
 something like this:

   ?php
   ob_start();
  $error = false;
  $data = null;
  //You would need to write these functions the ob_start  ob_end stops
 you getting errors...
  $id = sanitizeUserInput($_REQUEST['imageid']);  // should return a
 nice number for your database ID, or FALSE if you have a problem
  if(FALSE === $id) {
 $error = true;
   } else {
  $data = readDataFromDB($id);  //should output your data as an
 entire JPEG file or return FALSE if you have a problem.
}
  if(FALSE === $data) {
 $error = true;
   }
  ob_end_clean();
  if(false == $error) {
  header(Content-type: image/jpeg);
  echo $data;
  } else {
 header(HTTP/1.0 404 Not Found);
  }
  exit();
   ?

   Some searches that might help you find some examples...


 http://www.google.co.uk/search?hl=enq=php+echo+image+from+databasebtnG=Google+Searchmeta=
 http://www.google.co.uk/search?hl=enq=php+echo+image+from+databasebtnG=Google+Searchmeta=
 


 http://www.google.co.uk/search?hl=ensa=Xoi=spellresnum=0ct=resultcd=1q=php+read+image+from+database+blobspell=1
 http://www.google.co.uk/search?hl=ensa=Xoi=spellresnum=0ct=resultcd=1q=php+read+image+from+database+blobspell=1
 

   Hope this helps a bit - it's a long time since I did any image
 manipulation in PHP, so apologies if the answers are a bit vague, but there
 are loads of examples out there for this.

   Glen



 Omar Fouad wrote:

 I see, all those tutorials shows how to save the image on the Hard Drive
 (now with flash player is possible to do this without any server side
 script).

 But considering my question, what I should be putting in my database row,
 the byteArray encoded by JPGEncoder?
 Is there a method into this class that takes the ByteArray from the
 database
 back, and translates it into a bitmap to be shown in the swf?

 On Fri, Aug 15, 2008 at 12:42 PM, Glen Pike [EMAIL PROTECTED]
 wrote:



 Hi,

  Sorry, I put this in the wrong thread before - here is my 2c

  Hi,

  There are a few examples on the www about sending Bitmap data to the
 server Mario's is a good starting point -
 http://www.quasimondo.com/archives/000572.php  Anyway, there are
 other
 examples about which do compression/decompression on your data so you
 could
 save it into your DB too..

  Hope this is useful

  Glen
 --

 Glen Pike
 01326 218440
 www.glenpike.co.uk http://www.glenpike.co.uk


 __
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders









 --

 Glen Pike
 01326 218440
 www.glenpike.co.uk http://www.glenpike.co.uk

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




-- 
Omar M. Fouad - Digital Emotions
http://www.omarfouad.net

This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Binary Data Question

2008-08-15 Thread Omar Fouad
Glen, thanks for your help, I actually wanna store the Image in a mysql
database and not uploading it somewhere in my server.

On Fri, Aug 15, 2008 at 6:48 PM, Omar Fouad [EMAIL PROTECTED] wrote:

 I mean that You can save files to HDD now without using server side script
 with the new flash player 10.


 On Fri, Aug 15, 2008 at 6:16 PM, Glen Pike [EMAIL PROTECTED]wrote:

 Hi,

   You can't save an image from Flash without a server side script...

   Mario's example sends an image to the server, then uses FileReference to
 download it, or something similar.  If you want to store the image data, you
 would need to have 2 scripts - one to format it nicely and then put it in
 the database - Mario's script saves to a temporary file, you need to save
 the data to your DB here and get the id back.  The other one which takes in
 an ID of the data in the database and then echoes out headers and the data
 which means your browser / Flash will see an image.

   Mario's example PHP script is pretty chunky and not very easy to see
 where you would split the two bits of functionality, but instead of writing
 a temporary image file, you would store your data in a database and return
 the mysql_insert_id() to Flash, or similar.

   Then you can use this ID to retrieve the image using a second script.
  Provided you have encoded your JPG nicely, you can splurge it out - here
 are some searches that may help, but the basic principle is that you can do
 something like this:

   ?php
   ob_start();
  $error = false;
  $data = null;
  //You would need to write these functions the ob_start  ob_end stops
 you getting errors...
  $id = sanitizeUserInput($_REQUEST['imageid']);  // should return a
 nice number for your database ID, or FALSE if you have a problem
  if(FALSE === $id) {
 $error = true;
   } else {
  $data = readDataFromDB($id);  //should output your data as an
 entire JPEG file or return FALSE if you have a problem.
}
  if(FALSE === $data) {
 $error = true;
   }
  ob_end_clean();
  if(false == $error) {
  header(Content-type: image/jpeg);
  echo $data;
  } else {
 header(HTTP/1.0 404 Not Found);
  }
  exit();
   ?

   Some searches that might help you find some examples...


 http://www.google.co.uk/search?hl=enq=php+echo+image+from+databasebtnG=Google+Searchmeta=
 http://www.google.co.uk/search?hl=enq=php+echo+image+from+databasebtnG=Google+Searchmeta=
 


 http://www.google.co.uk/search?hl=ensa=Xoi=spellresnum=0ct=resultcd=1q=php+read+image+from+database+blobspell=1
 http://www.google.co.uk/search?hl=ensa=Xoi=spellresnum=0ct=resultcd=1q=php+read+image+from+database+blobspell=1
 

   Hope this helps a bit - it's a long time since I did any image
 manipulation in PHP, so apologies if the answers are a bit vague, but there
 are loads of examples out there for this.

   Glen



 Omar Fouad wrote:

 I see, all those tutorials shows how to save the image on the Hard Drive
 (now with flash player is possible to do this without any server side
 script).

 But considering my question, what I should be putting in my database row,
 the byteArray encoded by JPGEncoder?
 Is there a method into this class that takes the ByteArray from the
 database
 back, and translates it into a bitmap to be shown in the swf?

 On Fri, Aug 15, 2008 at 12:42 PM, Glen Pike [EMAIL PROTECTED]
 wrote:



 Hi,

  Sorry, I put this in the wrong thread before - here is my 2c

  Hi,

  There are a few examples on the www about sending Bitmap data to the
 server Mario's is a good starting point -
 http://www.quasimondo.com/archives/000572.php  Anyway, there are
 other
 examples about which do compression/decompression on your data so you
 could
 save it into your DB too..

  Hope this is useful

  Glen
 --

 Glen Pike
 01326 218440
 www.glenpike.co.uk http://www.glenpike.co.uk


 __
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders









 --

 Glen Pike
 01326 218440
 www.glenpike.co.uk http://www.glenpike.co.uk

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




 --
 Omar M. Fouad - Digital Emotions
 http://www.omarfouad.net

 This e-mail and any attachment is for authorised use by the intended
 recipient(s) only. It may contain proprietary material, confidential
 information and/or be subject to legal privilege. It should not be copied,
 disclosed to, retained or used by, any other party. If you are not an
 intended recipient then please promptly delete this e-mail and any
 attachment and all copies and inform the sender. Thank you.




-- 
Omar M. Fouad - Digital Emotions
http://www.omarfouad.net

This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain 

Re: [Flashcoders] Binary Data Question

2008-08-15 Thread Juan Pablo Califano
With the newest player, I think, it's possible to save data into the USER's
hard drive without a trip to the server, but you want to store the data on
the server side, you need to send it to the server...

You have to post that data using a URLLoader object, and specifying the
input as binary data.

I've wrapped up some code to do that and being able to pass variables as
well. If you want to check it out:

http://pastebin.com/f11a897cf

(Sorry, comments are in Spanish, but the indentifiers are in English)

A example of use (it's a copy  paste from some wortking code, just to give
you an idea):


import ar.com.califa010.utils.FormData;

   // getEncodedImg() is a method that returns a JPG as a byteArray

   var rawJpg:ByteArray = getEncodedImg();
   var formData:FormData = new FormData();

   var imageMimeType:String = FormData.JPG_FILE;
   var fileName:String = imageFile.jpg;

   formData.addFile(imageFile, rawJpg, fileName, imageMimeType);


   formData.addField(sFormat,imgFormat);
   formData.addField(idImagen,_idImagen);

   var req:URLRequest  = new URLRequest(url);

   req.method   = POST;
   req.contentType  = formData.contentType;
   req.data   = formData.getPostData();

   var loader:URLLoader = new URLLoader();
   configureListeners(loader);

loader.load(req);



2008/8/15, Omar Fouad [EMAIL PROTECTED]:

 I see, all those tutorials shows how to save the image on the Hard Drive
 (now with flash player is possible to do this without any server side
 script).

 But considering my question, what I should be putting in my database row,
 the byteArray encoded by JPGEncoder?
 Is there a method into this class that takes the ByteArray from the
 database
 back, and translates it into a bitmap to be shown in the swf?

 On Fri, Aug 15, 2008 at 12:42 PM, Glen Pike [EMAIL PROTECTED]
 wrote:

  Hi,
 
Sorry, I put this in the wrong thread before - here is my 2c
 
Hi,
 
   There are a few examples on the www about sending Bitmap data to the
  server Mario's is a good starting point -
  http://www.quasimondo.com/archives/000572.php  Anyway, there are
 other
  examples about which do compression/decompression on your data so you
 could
  save it into your DB too..
 
   Hope this is useful
 
   Glen
  --
 
  Glen Pike
  01326 218440
  www.glenpike.co.uk http://www.glenpike.co.uk
 
 
  __
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 



 --
 Omar M. Fouad - Digital Emotions
 http://www.omarfouad.net

 This e-mail and any attachment is for authorised use by the intended
 recipient(s) only. It may contain proprietary material, confidential
 information and/or be subject to legal privilege. It should not be copied,
 disclosed to, retained or used by, any other party. If you are not an
 intended recipient then please promptly delete this e-mail and any
 attachment and all copies and inform the sender. Thank you.
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Binary Data Question

2008-08-15 Thread Dave Watts
 Glen, thanks for your help, I actually wanna store the Image 
 in a mysql database and not uploading it somewhere in my server.

You'll still need to upload it to your server first. Your server-side script
can then send it to the database.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Binary Data Question

2008-08-15 Thread Omar Fouad
I guess I can send the ByteArray to the php that will handle its insertion
to the database. Right?

On Fri, Aug 15, 2008 at 7:07 PM, Juan Pablo Califano 
[EMAIL PROTECTED] wrote:

 With the newest player, I think, it's possible to save data into the USER's
 hard drive without a trip to the server, but you want to store the data on
 the server side, you need to send it to the server...

 You have to post that data using a URLLoader object, and specifying the
 input as binary data.

 I've wrapped up some code to do that and being able to pass variables as
 well. If you want to check it out:

 http://pastebin.com/f11a897cf

 (Sorry, comments are in Spanish, but the indentifiers are in English)

 A example of use (it's a copy  paste from some wortking code, just to give
 you an idea):


 import ar.com.califa010.utils.FormData;

   // getEncodedImg() is a method that returns a JPG as a byteArray

   var rawJpg:ByteArray = getEncodedImg();
   var formData:FormData = new FormData();

   var imageMimeType:String = FormData.JPG_FILE;
   var fileName:String = imageFile.jpg;

   formData.addFile(imageFile, rawJpg, fileName, imageMimeType);


   formData.addField(sFormat,imgFormat);
   formData.addField(idImagen,_idImagen);

   var req:URLRequest  = new URLRequest(url);

   req.method   = POST;
   req.contentType  = formData.contentType;
   req.data   = formData.getPostData();

   var loader:URLLoader = new URLLoader();
   configureListeners(loader);

loader.load(req);



 2008/8/15, Omar Fouad [EMAIL PROTECTED]:
 
  I see, all those tutorials shows how to save the image on the Hard Drive
  (now with flash player is possible to do this without any server side
  script).
 
  But considering my question, what I should be putting in my database row,
  the byteArray encoded by JPGEncoder?
  Is there a method into this class that takes the ByteArray from the
  database
  back, and translates it into a bitmap to be shown in the swf?
 
  On Fri, Aug 15, 2008 at 12:42 PM, Glen Pike [EMAIL PROTECTED]
  wrote:
 
   Hi,
  
 Sorry, I put this in the wrong thread before - here is my 2c
  
 Hi,
  
There are a few examples on the www about sending Bitmap data to the
   server Mario's is a good starting point -
   http://www.quasimondo.com/archives/000572.php  Anyway, there are
  other
   examples about which do compression/decompression on your data so you
  could
   save it into your DB too..
  
Hope this is useful
  
Glen
   --
  
   Glen Pike
   01326 218440
   www.glenpike.co.uk http://www.glenpike.co.uk
  
  
   __
   Flashcoders mailing list
   Flashcoders@chattyfig.figleaf.com
   http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  
 
 
 
  --
  Omar M. Fouad - Digital Emotions
  http://www.omarfouad.net
 
  This e-mail and any attachment is for authorised use by the intended
  recipient(s) only. It may contain proprietary material, confidential
  information and/or be subject to legal privilege. It should not be
 copied,
  disclosed to, retained or used by, any other party. If you are not an
  intended recipient then please promptly delete this e-mail and any
  attachment and all copies and inform the sender. Thank you.
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




-- 
Omar M. Fouad - Digital Emotions
http://www.omarfouad.net

This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Binary Data Question

2008-08-15 Thread Dave Watts
 I guess I can send the ByteArray to the php that will handle 
 its insertion to the database. Right?

Yes, as long as your database drivers support that.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Binary Data Question

2008-08-15 Thread Juan Pablo Califano
Yes. Using that particular class I mentioned, from the php side you'd
receive the data like a regular html form post with multipart-encode, that
means, you can retrieve the text variables you want to send with
$_POST['someVar'] and the file (or files) with $_FILES['varName'] (or the
name you choose). Treat it like if it were a html form.

To add a text field to the form use the add addField(varName,varValue)
method; to add a file, use addFile(varName, jpgByteArray,
originalFileName, imageMimeType);

For originalFileName, use whatever you want, like image.jpg, it doesn't
really matter. That's what you'll get with $_FILES['varName']['name']. For
the imageMimeType, use the constant in the class for JPG.


Cheers
Juan Pablo Califano

2008/8/15, Omar Fouad [EMAIL PROTECTED]:

 I guess I can send the ByteArray to the php that will handle its insertion
 to the database. Right?

 On Fri, Aug 15, 2008 at 7:07 PM, Juan Pablo Califano 
 [EMAIL PROTECTED] wrote:

  With the newest player, I think, it's possible to save data into the
 USER's
  hard drive without a trip to the server, but you want to store the data
 on
  the server side, you need to send it to the server...
 
  You have to post that data using a URLLoader object, and specifying the
  input as binary data.
 
  I've wrapped up some code to do that and being able to pass variables as
  well. If you want to check it out:
 
  http://pastebin.com/f11a897cf
 
  (Sorry, comments are in Spanish, but the indentifiers are in English)
 
  A example of use (it's a copy  paste from some wortking code, just to
 give
  you an idea):
 
 
  import ar.com.califa010.utils.FormData;
 
// getEncodedImg() is a method that returns a JPG as a byteArray
 
var rawJpg:ByteArray = getEncodedImg();
var formData:FormData = new FormData();
 
var imageMimeType:String = FormData.JPG_FILE;
var fileName:String = imageFile.jpg;
 
formData.addFile(imageFile, rawJpg, fileName, imageMimeType);
 
 
formData.addField(sFormat,imgFormat);
formData.addField(idImagen,_idImagen);
 
var req:URLRequest  = new URLRequest(url);
 
req.method   = POST;
req.contentType  = formData.contentType;
req.data   = formData.getPostData();
 
var loader:URLLoader = new URLLoader();
configureListeners(loader);
 
 loader.load(req);
 
 
 
  2008/8/15, Omar Fouad [EMAIL PROTECTED]:
  
   I see, all those tutorials shows how to save the image on the Hard
 Drive
   (now with flash player is possible to do this without any server side
   script).
  
   But considering my question, what I should be putting in my database
 row,
   the byteArray encoded by JPGEncoder?
   Is there a method into this class that takes the ByteArray from the
   database
   back, and translates it into a bitmap to be shown in the swf?
  
   On Fri, Aug 15, 2008 at 12:42 PM, Glen Pike [EMAIL PROTECTED]
   wrote:
  
Hi,
   
  Sorry, I put this in the wrong thread before - here is my 2c
   
  Hi,
   
 There are a few examples on the www about sending Bitmap data to the
server Mario's is a good starting point -
http://www.quasimondo.com/archives/000572.php  Anyway, there are
   other
examples about which do compression/decompression on your data so you
   could
save it into your DB too..
   
 Hope this is useful
   
 Glen
--
   
Glen Pike
01326 218440
www.glenpike.co.uk http://www.glenpike.co.uk
   
   
__
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
   
  
  
  
   --
   Omar M. Fouad - Digital Emotions
   http://www.omarfouad.net
  
   This e-mail and any attachment is for authorised use by the intended
   recipient(s) only. It may contain proprietary material, confidential
   information and/or be subject to legal privilege. It should not be
  copied,
   disclosed to, retained or used by, any other party. If you are not an
   intended recipient then please promptly delete this e-mail and any
   attachment and all copies and inform the sender. Thank you.
   ___
   Flashcoders mailing list
   Flashcoders@chattyfig.figleaf.com
   http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 



 --
 Omar M. Fouad - Digital Emotions
 http://www.omarfouad.net

 This e-mail and any attachment is for authorised use by the intended
 recipient(s) only. It may contain proprietary material, confidential
 information and/or be subject to legal privilege. It should not be copied,
 disclosed to, retained or used by, any other party. If you are not an
 intended recipient then please promptly delete this e-mail and any
 attachment and all copies and inform the sender. Thank you.
 

Re: [Flashcoders] Binary Data Question

2008-08-15 Thread Omar Fouad
Thanks.. I will try this now and feed you back.


On Sat, Aug 16, 2008 at 1:41 AM, Juan Pablo Califano 
[EMAIL PROTECTED] wrote:

 Yes. Using that particular class I mentioned, from the php side you'd
 receive the data like a regular html form post with multipart-encode, that
 means, you can retrieve the text variables you want to send with
 $_POST['someVar'] and the file (or files) with $_FILES['varName'] (or the
 name you choose). Treat it like if it were a html form.

 To add a text field to the form use the add addField(varName,varValue)
 method; to add a file, use addFile(varName, jpgByteArray,
 originalFileName, imageMimeType);

 For originalFileName, use whatever you want, like image.jpg, it doesn't
 really matter. That's what you'll get with $_FILES['varName']['name']. For
 the imageMimeType, use the constant in the class for JPG.


 Cheers
 Juan Pablo Califano

 2008/8/15, Omar Fouad [EMAIL PROTECTED]:
 
  I guess I can send the ByteArray to the php that will handle its
 insertion
  to the database. Right?
 
  On Fri, Aug 15, 2008 at 7:07 PM, Juan Pablo Califano 
  [EMAIL PROTECTED] wrote:
 
   With the newest player, I think, it's possible to save data into the
  USER's
   hard drive without a trip to the server, but you want to store the data
  on
   the server side, you need to send it to the server...
  
   You have to post that data using a URLLoader object, and specifying the
   input as binary data.
  
   I've wrapped up some code to do that and being able to pass variables
 as
   well. If you want to check it out:
  
   http://pastebin.com/f11a897cf
  
   (Sorry, comments are in Spanish, but the indentifiers are in English)
  
   A example of use (it's a copy  paste from some wortking code, just to
  give
   you an idea):
  
  
   import ar.com.califa010.utils.FormData;
  
 // getEncodedImg() is a method that returns a JPG as a byteArray
  
 var rawJpg:ByteArray = getEncodedImg();
 var formData:FormData = new FormData();
  
 var imageMimeType:String = FormData.JPG_FILE;
 var fileName:String = imageFile.jpg;
  
 formData.addFile(imageFile, rawJpg, fileName, imageMimeType);
  
  
 formData.addField(sFormat,imgFormat);
 formData.addField(idImagen,_idImagen);
  
 var req:URLRequest  = new URLRequest(url);
  
 req.method   = POST;
 req.contentType  = formData.contentType;
 req.data   = formData.getPostData();
  
 var loader:URLLoader = new URLLoader();
 configureListeners(loader);
  
  loader.load(req);
  
  
  
   2008/8/15, Omar Fouad [EMAIL PROTECTED]:
   
I see, all those tutorials shows how to save the image on the Hard
  Drive
(now with flash player is possible to do this without any server side
script).
   
But considering my question, what I should be putting in my database
  row,
the byteArray encoded by JPGEncoder?
Is there a method into this class that takes the ByteArray from the
database
back, and translates it into a bitmap to be shown in the swf?
   
On Fri, Aug 15, 2008 at 12:42 PM, Glen Pike 
 [EMAIL PROTECTED]
wrote:
   
 Hi,

   Sorry, I put this in the wrong thread before - here is my 2c

   Hi,

  There are a few examples on the www about sending Bitmap data to
 the
 server Mario's is a good starting point -
 http://www.quasimondo.com/archives/000572.php  Anyway, there
 are
other
 examples about which do compression/decompression on your data so
 you
could
 save it into your DB too..

  Hope this is useful

  Glen
 --

 Glen Pike
 01326 218440
 www.glenpike.co.uk http://www.glenpike.co.uk


 __
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

   
   
   
--
Omar M. Fouad - Digital Emotions
http://www.omarfouad.net
   
This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be
   copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
   
   ___
   Flashcoders mailing list
   Flashcoders@chattyfig.figleaf.com
   http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  
 
 
 
  --
  Omar M. Fouad - Digital Emotions
  http://www.omarfouad.net
 
  This e-mail and any attachment is for authorised use by the intended
  recipient(s) only. It may contain proprietary material, confidential
  information 

[Flashcoders] Binary Data Question

2008-08-14 Thread Omar Fouad
Hello all,
I was wondering if I can get the binary data from a bitmap data, and send it
to database (blob) or/and getting the binary data from the database and in
flash reform it to display the bitmap back.

I've been reading about the ByteArray Class but I am still confused whether
to use it or to use URLStreaming.


Thanks.

-- 
Omar M. Fouad - Digital Emotions
http://www.omarfouad.net

This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Binary Data Question

2008-08-14 Thread Juan Pablo Califano
You can use the getPixels() method of the BitmapData class to get the raw
pixel data as a ByteArray. Using setPixels() you can fill a BitmapData
object with data from a ByteArray.

You can post / retrieve that data from a server using a URLRequest object,
specifying that you want to use a binary format. The problem of this
approach, I think, is that it'd consume a lot of bandwith (unless you have
really small images). Each pixel takes 4 bytes. In a 400 x 400 image, that's
16 pixels and so 64 bytes or 625 Kb.

Cheers
Juan Pablo Califano


2008/8/14, Omar Fouad [EMAIL PROTECTED]:

 Hello all,
 I was wondering if I can get the binary data from a bitmap data, and send
 it
 to database (blob) or/and getting the binary data from the database and in
 flash reform it to display the bitmap back.

 I've been reading about the ByteArray Class but I am still confused whether
 to use it or to use URLStreaming.


 Thanks.

 --
 Omar M. Fouad - Digital Emotions
 http://www.omarfouad.net

 This e-mail and any attachment is for authorised use by the intended
 recipient(s) only. It may contain proprietary material, confidential
 information and/or be subject to legal privilege. It should not be copied,
 disclosed to, retained or used by, any other party. If you are not an
 intended recipient then please promptly delete this e-mail and any
 attachment and all copies and inform the sender. Thank you.
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Binary Data Question

2008-08-14 Thread Omar Fouad
You mean it is not the same bandwidith taken as when loading the picture
from a directory in a server?

On Thu, Aug 14, 2008 at 6:59 PM, Juan Pablo Califano 
[EMAIL PROTECTED] wrote:

 You can use the getPixels() method of the BitmapData class to get the raw
 pixel data as a ByteArray. Using setPixels() you can fill a BitmapData
 object with data from a ByteArray.

 You can post / retrieve that data from a server using a URLRequest object,
 specifying that you want to use a binary format. The problem of this
 approach, I think, is that it'd consume a lot of bandwith (unless you have
 really small images). Each pixel takes 4 bytes. In a 400 x 400 image,
 that's
 16 pixels and so 64 bytes or 625 Kb.

 Cheers
 Juan Pablo Califano


 2008/8/14, Omar Fouad [EMAIL PROTECTED]:
 
  Hello all,
  I was wondering if I can get the binary data from a bitmap data, and send
  it
  to database (blob) or/and getting the binary data from the database and
 in
  flash reform it to display the bitmap back.
 
  I've been reading about the ByteArray Class but I am still confused
 whether
  to use it or to use URLStreaming.
 
 
  Thanks.
 
  --
  Omar M. Fouad - Digital Emotions
  http://www.omarfouad.net
 
  This e-mail and any attachment is for authorised use by the intended
  recipient(s) only. It may contain proprietary material, confidential
  information and/or be subject to legal privilege. It should not be
 copied,
  disclosed to, retained or used by, any other party. If you are not an
  intended recipient then please promptly delete this e-mail and any
  attachment and all copies and inform the sender. Thank you.
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




-- 
Omar M. Fouad - Digital Emotions
http://www.omarfouad.net

This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Binary Data Question

2008-08-14 Thread Mark Winterhalder
On Thu, Aug 14, 2008 at 10:56 PM, Omar Fouad [EMAIL PROTECTED] wrote:
 You mean it is not the same bandwidith taken as when loading the picture
 from a directory in a server?

It's a different encoding. You could encode it to, say, png before
sending it back, or use zlib compression.

Mark
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Binary Data Question

2008-08-14 Thread Juan Pablo Califano
Well, that depends on the picture, but yes, generaly you'd load a jpg, png,
etc, which are compressed formats. For instance, right now I'm seeing a  466
x 468 jpg. Its size is 34 Kb. Bear in mind that the compression ratio varies
depending on the actual image and the compression rate / algorithm applied,
not only the dimensions, but definitely, the dimensions weigh in.

Taking that same image in a raw format (i.e. no compression applied),
which is basically what you're doing when you copy the bitmap data into a
ByteArray, you would need 857.352 bytes to store it (466 * 468 * 4). So,
that's 851 Kb agains 34 Kb, a really significant difference.

Probably, a more feasible approach would be encoding the raw pixel data to
jpg or png in the swf, and then send that to the server (after that, it's
just a regular jpg or png, so you can load it as any other image). It'd put
more stress on the swf side, but the download/upload times and server load
would be dramatically cut down.

Check this link, it has a tutorial for doing precisely that.
http://henryjones.us/articles/using-the-as3-jpeg-encoder

Cheers
Juan Pablo Califano


2008/8/14, Omar Fouad [EMAIL PROTECTED]:

 You mean it is not the same bandwidith taken as when loading the picture
 from a directory in a server?

 On Thu, Aug 14, 2008 at 6:59 PM, Juan Pablo Califano 
 [EMAIL PROTECTED] wrote:

  You can use the getPixels() method of the BitmapData class to get the raw
  pixel data as a ByteArray. Using setPixels() you can fill a BitmapData
  object with data from a ByteArray.
 
  You can post / retrieve that data from a server using a URLRequest
 object,
  specifying that you want to use a binary format. The problem of this
  approach, I think, is that it'd consume a lot of bandwith (unless you
 have
  really small images). Each pixel takes 4 bytes. In a 400 x 400 image,
  that's
  16 pixels and so 64 bytes or 625 Kb.
 
  Cheers
  Juan Pablo Califano
 
 
  2008/8/14, Omar Fouad [EMAIL PROTECTED]:
  
   Hello all,
   I was wondering if I can get the binary data from a bitmap data, and
 send
   it
   to database (blob) or/and getting the binary data from the database and
  in
   flash reform it to display the bitmap back.
  
   I've been reading about the ByteArray Class but I am still confused
  whether
   to use it or to use URLStreaming.
  
  
   Thanks.
  
   --
   Omar M. Fouad - Digital Emotions
   http://www.omarfouad.net
  
   This e-mail and any attachment is for authorised use by the intended
   recipient(s) only. It may contain proprietary material, confidential
   information and/or be subject to legal privilege. It should not be
  copied,
   disclosed to, retained or used by, any other party. If you are not an
   intended recipient then please promptly delete this e-mail and any
   attachment and all copies and inform the sender. Thank you.
   ___
   Flashcoders mailing list
   Flashcoders@chattyfig.figleaf.com
   http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 



 --
 Omar M. Fouad - Digital Emotions
 http://www.omarfouad.net

 This e-mail and any attachment is for authorised use by the intended
 recipient(s) only. It may contain proprietary material, confidential
 information and/or be subject to legal privilege. It should not be copied,
 disclosed to, retained or used by, any other party. If you are not an
 intended recipient then please promptly delete this e-mail and any
 attachment and all copies and inform the sender. Thank you.
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Binary Data Question

2008-08-14 Thread H
Compress it to a PNG or a JPEG - these formats will output a tidy ByteArray
for you. If you don't have AMF or trouble with writing HTTP Post headers,
you can always pack it into a Base64 encoded string.

Use Loader.loadBytes() to load it. This is in fact synchronous but occurs
asynchronously. I don't even think it's worth listening for the result.
Loader.content should be a Bitmap object...

H

On Thu, Aug 14, 2008 at 10:21 AM, Omar Fouad [EMAIL PROTECTED]wrote:

 Hello all,
 I was wondering if I can get the binary data from a bitmap data, and send
 it
 to database (blob) or/and getting the binary data from the database and in
 flash reform it to display the bitmap back.

 I've been reading about the ByteArray Class but I am still confused whether
 to use it or to use URLStreaming.


 Thanks.

 --
 Omar M. Fouad - Digital Emotions
 http://www.omarfouad.net

 This e-mail and any attachment is for authorised use by the intended
 recipient(s) only. It may contain proprietary material, confidential
 information and/or be subject to legal privilege. It should not be copied,
 disclosed to, retained or used by, any other party. If you are not an
 intended recipient then please promptly delete this e-mail and any
 attachment and all copies and inform the sender. Thank you.
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders