从Flash CS3保存JPG图像

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从Flash CS3保存JPG图像相关的知识,希望对你有一定的参考价值。

This snipped is split in two sections: Actionescript 3 and php
  1. /**
  2. ** @prototype : 0.0.1
  3. ** @author : =undo=
  4. ** @email : [email protected]
  5. ** @web : http://www.undolog.com
  6. **
  7. ** @params :
  8. **
  9. ** __bitmap : puntatore alla nostra bitmap
  10. ** __width : larghezza in pixel
  11. ** __height : altezza in pixel
  12. **
  13. */
  14. // copia per la lettura - questo potrebbe essere evitato
  15. var sbmp:BitmapData = new BitmapData(__width, __height);
  16. sbmp.draw ( __bitmap );
  17. //
  18. var pixels:Array = new Array();
  19. for (var xx:uint = 0; xx <= __width; xx++) {
  20. for (var yy:uint = 0; yy <= __height; yy++) {
  21. pixels.push( sbmp.getPixel32(xx, yy).toString(16) );
  22. }
  23. }
  24. //
  25. var urlreq:URLRequest = new URLRequest( "http://miodominio.com/savebitmap.php" );
  26. var urlpar:URLVariables = new URLVariables();
  27. var urlldr:URLLoader = new URLLoader();
  28. //
  29. urlldr.addEventListener( Event.COMPLETE,
  30. function (e:Event):void {
  31. trace( ' Completato' );
  32. }
  33. );
  34. //
  35. urlpar.pixels = pixels.toString();
  36. urlpar.height = __height;
  37. urlpar.width = __width;
  38. urlreq.data = urlpar;
  39. urlreq.method = URLRequestMethod.POST;
  40. urlldr.load( urlreq );
  41.  
  42.  
  43. --- PHP ---
  44.  
  45. /**
  46. ** @prototype : 0.0.1
  47. ** @author : =undo=
  48. ** @email : [email protected]
  49. ** @web : http://www.undolog.com
  50. **
  51. ** @params :
  52. **
  53. ** __bitmap : puntatore alla nostra bitmap
  54. ** __width : larghezza in pixel
  55. ** __height : altezza in pixel
  56. **
  57. */
  58. // $pixels diventa un array con i valori dei singoli pixel
  59. $pixels = explode(",", $_POST['pixels']);
  60. $width = $_POST['width'];
  61. $height = $_POST['height'];
  62. // creo l'immagine - @evitando di emettere errori
  63. $image = @imagecreatetruecolor( $width ,$height );
  64. // Scrivo i pixel per tutta la lunghezza e altezza
  65. $index = 0;
  66. for($x=0; $x<=$width; $x++){
  67. for($y=0; $y<=$height; $y++){
  68. $r = hexdec("0x".substr( $pixels[$index] , 2 , 2 ));
  69. $g = hexdec("0x".substr( $pixels[$index] , 4 , 2 ));
  70. $b = hexdec("0x".substr( $pixels[$index] , 6 , 2 ));
  71. $color = imagecolorallocate($image, $r, $g, $b);
  72. imagesetpixel ($image,$x,$y,$color);
  73. $index++;
  74. }
  75. }
  76. // scrivo immagine (in JPG - ma potete usare un diverso formato) sul disco/server
  77. imagejpeg( $image, "immagine.jpg" );
  78. imagedestroy( $image ); // libero tutto

以上是关于从Flash CS3保存JPG图像的主要内容,如果未能解决你的问题,请参考以下文章

PHP/Flash 保存图像停止工作

Flash CS3 是不是导出 SVG?

如何在 Flash CS3 中访问组成员

如何在Adobe Flash CS3中更改Adobe Flash Player版本

在 Adob​​e Flash CS3 Actionscript 中拖动多个项目

Flash CS3 AS3 影片剪辑转移到其他帧