mako 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (391) hide show
  1. data/bin/mako +133 -0
  2. data/lib/mako/build.rb +336 -0
  3. data/lib/mako/data/flash_widget_dev_core/Dependencies.txt +10 -0
  4. data/lib/mako/data/flash_widget_dev_core/libs/Degrafa_.2.11.swc +0 -0
  5. data/lib/mako/data/flash_widget_dev_core/libs/KogneatoGraphics.swc +0 -0
  6. data/lib/mako/data/flash_widget_dev_core/libs/KogneatoSymbols.swc +0 -0
  7. data/lib/mako/data/flash_widget_dev_core/libs/flash.swc +0 -0
  8. data/lib/mako/data/flash_widget_dev_core/src/assets/images/RichTextEditor.png +0 -0
  9. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/fonts/ARLRDBD.TTF +0 -0
  10. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/fonts/FTD_____.TTF +0 -0
  11. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/fonts/verdana.ttf +0 -0
  12. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/fonts/verdanab.ttf +0 -0
  13. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/fonts/verdanai.ttf +0 -0
  14. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/fonts/verdanaz.ttf +0 -0
  15. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/DefaultError.png +0 -0
  16. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/barbgfill.png +0 -0
  17. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/barshadow.png +0 -0
  18. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/bold.png +0 -0
  19. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/bullets.png +0 -0
  20. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/center.png +0 -0
  21. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/close-x.png +0 -0
  22. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/fullscreenPopup_close.png +0 -0
  23. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/gameTypeIcons/mc.png +0 -0
  24. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/gameTypeIcons/mc2.png +0 -0
  25. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/gameTypeIcons/mc3.png +0 -0
  26. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/gameTypeIcons/qa.png +0 -0
  27. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/gameTypeIcons/so.png +0 -0
  28. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/importIcon.png +0 -0
  29. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/italic.png +0 -0
  30. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/justify.png +0 -0
  31. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/kogLogo.png +0 -0
  32. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/left.png +0 -0
  33. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/oml-href-disabled.png +0 -0
  34. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/oml-href.png +0 -0
  35. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/oml-pagelink-disabled.png +0 -0
  36. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/oml-pagelink.png +0 -0
  37. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/oml-tooltip-delete.png +0 -0
  38. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/oml-tooltip-disabled.png +0 -0
  39. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/oml-tooltip-edit.png +0 -0
  40. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/oml-tooltip.png +0 -0
  41. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/pencil.png +0 -0
  42. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/right.png +0 -0
  43. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/underline.png +0 -0
  44. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/videoPlayButton.png +0 -0
  45. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/videoPlayerPauseButton.png +0 -0
  46. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/videoPlayerPauseButton_over.png +0 -0
  47. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/videoPlayerPlayButton.png +0 -0
  48. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/videoPlayerPlayButton_over.png +0 -0
  49. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/videoPlayerSoundButton.png +0 -0
  50. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/images/videoPlayerSoundButton_over.png +0 -0
  51. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/styles/creatorStyle.css +57 -0
  52. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/styles/style.css +929 -0
  53. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/swf/embeddedfonts.swf +0 -0
  54. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/swf/helpBubble.swf +0 -0
  55. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/swf/kogneatoSymbols.swf +0 -0
  56. data/lib/mako/data/flash_widget_dev_core/src/assets/materia/swf/videobg.swf +0 -0
  57. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/LICENSE.txt +27 -0
  58. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/ac/mxeffects/CubeRotate.as +48 -0
  59. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/ac/mxeffects/Distortion.as +168 -0
  60. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/ac/mxeffects/DistortionConstants.as +16 -0
  61. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/ac/mxeffects/Door.as +57 -0
  62. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/ac/mxeffects/Flip.as +62 -0
  63. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/ac/mxeffects/Gate.as +57 -0
  64. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/ac/mxeffects/Pop.as +53 -0
  65. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/ac/mxeffects/Push.as +48 -0
  66. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/ac/mxeffects/SimpleDistortion.as +619 -0
  67. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/ac/mxeffects/effectClasses/CubeRotateInstance.as +94 -0
  68. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/ac/mxeffects/effectClasses/DistortBaseInstance.as +258 -0
  69. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/ac/mxeffects/effectClasses/DoorInstance.as +116 -0
  70. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/ac/mxeffects/effectClasses/FlipInstance.as +79 -0
  71. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/ac/mxeffects/effectClasses/GateInstance.as +163 -0
  72. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/ac/mxeffects/effectClasses/PopInstance.as +91 -0
  73. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/ac/mxeffects/effectClasses/PushInstance.as +76 -0
  74. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/ac/util/DisplayObjectBounds.as +64 -0
  75. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/ac/util/DisplayObjectBoundsUtil.as +42 -0
  76. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/ac/util/SimpleDisplayObjectBoundsUtil.as +60 -0
  77. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/crypto/HMAC.as +108 -0
  78. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/crypto/MD5.as +250 -0
  79. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/crypto/MD5Stream.as +343 -0
  80. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/crypto/SHA1.as +250 -0
  81. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/crypto/SHA224.as +226 -0
  82. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/crypto/SHA256.as +229 -0
  83. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/crypto/WSSEUsernameToken.as +100 -0
  84. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/effects/SaturationFade.as +107 -0
  85. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/effects/SaturationFadeInstance.as +178 -0
  86. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/effects/SaturationFadePopUpBlocker.as +88 -0
  87. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/errors/IllegalStateError.as +57 -0
  88. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/fileformats/vcard/Address.as +41 -0
  89. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/fileformats/vcard/Email.as +34 -0
  90. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/fileformats/vcard/Phone.as +34 -0
  91. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/fileformats/vcard/VCard.as +47 -0
  92. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/fileformats/vcard/VCardParser.as +234 -0
  93. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/images/BitString.as +34 -0
  94. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/images/JPGEncoder.as +584 -0
  95. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/images/PNGEncoder.as +133 -0
  96. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/net/DynamicURLLoader.as +48 -0
  97. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/net/IURIResolver.as +70 -0
  98. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/net/MimeTypeMap.as +192 -0
  99. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/net/URI.as +2139 -0
  100. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/net/URIEncodingBitmap.as +122 -0
  101. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/net/proxies/RFC2817Socket.as +179 -0
  102. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/protocols/dict/Database.as +55 -0
  103. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/protocols/dict/Definition.as +59 -0
  104. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/protocols/dict/Dict.as +322 -0
  105. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/protocols/dict/DictionaryServer.as +50 -0
  106. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/protocols/dict/MatchStrategy.as +55 -0
  107. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/protocols/dict/Response.as +59 -0
  108. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/protocols/dict/events/ConnectedEvent.as +44 -0
  109. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/protocols/dict/events/DatabaseEvent.as +54 -0
  110. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/protocols/dict/events/DefinitionEvent.as +55 -0
  111. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/protocols/dict/events/DefinitionHeaderEvent.as +55 -0
  112. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/protocols/dict/events/DictionaryServerEvent.as +55 -0
  113. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/protocols/dict/events/DisconnectedEvent.as +44 -0
  114. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/protocols/dict/events/ErrorEvent.as +64 -0
  115. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/protocols/dict/events/MatchEvent.as +54 -0
  116. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/protocols/dict/events/MatchStrategiesEvent.as +56 -0
  117. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/protocols/dict/events/NoMatchEvent.as +44 -0
  118. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/protocols/dict/util/CompleteResponseEvent.as +55 -0
  119. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/protocols/dict/util/SocketHelper.as +70 -0
  120. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/serialization/json/JSON.as +76 -0
  121. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/serialization/json/JSONDecoder.as +303 -0
  122. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/serialization/json/JSONEncoder.as +277 -0
  123. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/serialization/json/JSONParseError.as +79 -0
  124. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/serialization/json/JSONToken.as +79 -0
  125. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/serialization/json/JSONTokenType.as +49 -0
  126. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/serialization/json/JSONTokenizer.as +605 -0
  127. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/utils/ArrayUtil.as +166 -0
  128. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/utils/DateUtil.as +657 -0
  129. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/utils/DictionaryUtil.as +73 -0
  130. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/utils/IntUtil.as +85 -0
  131. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/utils/NumberFormatter.as +63 -0
  132. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/utils/StringUtil.as +220 -0
  133. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/utils/XMLUtil.as +148 -0
  134. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/webapis/ServiceBase.as +39 -0
  135. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/webapis/URLLoaderBase.as +93 -0
  136. data/lib/mako/data/flash_widget_dev_core/src/com/adobe/webapis/events/ServiceEvent.as +67 -0
  137. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/geom/ColorMatrix.as +1 -0
  138. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/GTween.as +1 -0
  139. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/GTweenTimeline.as +1 -0
  140. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/GTweener.as +1 -0
  141. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/easing/Back.as +1 -0
  142. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/easing/Bounce.as +1 -0
  143. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/easing/Circular.as +1 -0
  144. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/easing/Cubic.as +1 -0
  145. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/easing/Elastic.as +1 -0
  146. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/easing/Exponential.as +1 -0
  147. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/easing/Linear.as +1 -0
  148. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/easing/Quadratic.as +1 -0
  149. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/easing/Quartic.as +1 -0
  150. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/easing/Quintic.as +1 -0
  151. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/easing/Sine.as +1 -0
  152. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/plugins/AutoHidePlugin.as +1 -0
  153. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/plugins/BlurPlugin.as +1 -0
  154. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/plugins/ColorAdjustPlugin.as +1 -0
  155. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/plugins/ColorTransformPlugin.as +1 -0
  156. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/plugins/CurrentFramePlugin.as +1 -0
  157. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/plugins/IGTweenPlugin.as +1 -0
  158. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/plugins/MatrixPlugin.as +1 -0
  159. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/plugins/MotionBlurPlugin.as +1 -0
  160. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/plugins/SmartRotationPlugin.as +1 -0
  161. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/plugins/SnappingPlugin.as +1 -0
  162. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/motion/plugins/SoundTransformPlugin.as +1 -0
  163. data/lib/mako/data/flash_widget_dev_core/src/com/gskinner/utils/SWFBridgeAS3.as +83 -0
  164. data/lib/mako/data/flash_widget_dev_core/src/etc/GUID.as +82 -0
  165. data/lib/mako/data/flash_widget_dev_core/src/etc/MathExt.as +114 -0
  166. data/lib/mako/data/flash_widget_dev_core/src/gs/OverwriteManager.as +143 -0
  167. data/lib/mako/data/flash_widget_dev_core/src/gs/TweenFilterLite.as +502 -0
  168. data/lib/mako/data/flash_widget_dev_core/src/gs/TweenLite.as +512 -0
  169. data/lib/mako/data/flash_widget_dev_core/src/gs/TweenMax.as +987 -0
  170. data/lib/mako/data/flash_widget_dev_core/src/gs/easing/Back.as +14 -0
  171. data/lib/mako/data/flash_widget_dev_core/src/gs/easing/Bounce.as +22 -0
  172. data/lib/mako/data/flash_widget_dev_core/src/gs/easing/Circ.as +14 -0
  173. data/lib/mako/data/flash_widget_dev_core/src/gs/easing/Cubic.as +14 -0
  174. data/lib/mako/data/flash_widget_dev_core/src/gs/easing/Elastic.as +27 -0
  175. data/lib/mako/data/flash_widget_dev_core/src/gs/easing/Expo.as +16 -0
  176. data/lib/mako/data/flash_widget_dev_core/src/gs/easing/Linear.as +16 -0
  177. data/lib/mako/data/flash_widget_dev_core/src/gs/easing/Quad.as +14 -0
  178. data/lib/mako/data/flash_widget_dev_core/src/gs/easing/Quart.as +14 -0
  179. data/lib/mako/data/flash_widget_dev_core/src/gs/easing/Quint.as +14 -0
  180. data/lib/mako/data/flash_widget_dev_core/src/gs/easing/Sine.as +14 -0
  181. data/lib/mako/data/flash_widget_dev_core/src/gs/easing/Strong.as +14 -0
  182. data/lib/mako/data/flash_widget_dev_core/src/gs/easing/easing_readme.txt +14 -0
  183. data/lib/mako/data/flash_widget_dev_core/src/gs/events/TweenEvent.as +26 -0
  184. data/lib/mako/data/flash_widget_dev_core/src/gs/utils/tween/BevelFilterVars.as +63 -0
  185. data/lib/mako/data/flash_widget_dev_core/src/gs/utils/tween/BlurFilterVars.as +42 -0
  186. data/lib/mako/data/flash_widget_dev_core/src/gs/utils/tween/ColorMatrixFilterVars.as +86 -0
  187. data/lib/mako/data/flash_widget_dev_core/src/gs/utils/tween/DropShadowFilterVars.as +66 -0
  188. data/lib/mako/data/flash_widget_dev_core/src/gs/utils/tween/GlowFilterVars.as +57 -0
  189. data/lib/mako/data/flash_widget_dev_core/src/gs/utils/tween/TweenFilterLiteVars.as +93 -0
  190. data/lib/mako/data/flash_widget_dev_core/src/gs/utils/tween/TweenLiteVars.as +269 -0
  191. data/lib/mako/data/flash_widget_dev_core/src/gs/utils/tween/TweenMaxVars.as +103 -0
  192. data/lib/mako/data/flash_widget_dev_core/src/it/animation/TweenEvent.as +17 -0
  193. data/lib/mako/data/flash_widget_dev_core/src/it/animation/TweenObject.as +27 -0
  194. data/lib/mako/data/flash_widget_dev_core/src/it/animation/TweenSingleton.as +86 -0
  195. data/lib/mako/data/flash_widget_dev_core/src/it/animation/methods/Constant.as +7 -0
  196. data/lib/mako/data/flash_widget_dev_core/src/it/animation/methods/FastSlow.as +7 -0
  197. data/lib/mako/data/flash_widget_dev_core/src/it/animation/methods/FastSlowFast.as +8 -0
  198. data/lib/mako/data/flash_widget_dev_core/src/it/animation/methods/Shake.as +12 -0
  199. data/lib/mako/data/flash_widget_dev_core/src/it/animation/methods/SlowFast.as +7 -0
  200. data/lib/mako/data/flash_widget_dev_core/src/it/animation/methods/SlowFastSlow.as +8 -0
  201. data/lib/mako/data/flash_widget_dev_core/src/jac/image/ImageUtils.as +173 -0
  202. data/lib/mako/data/flash_widget_dev_core/src/jac/image/ResizeStyle.as +52 -0
  203. data/lib/mako/data/flash_widget_dev_core/src/materia/CreatorBase.mxml +504 -0
  204. data/lib/mako/data/flash_widget_dev_core/src/materia/CreatorConfig.as +45 -0
  205. data/lib/mako/data/flash_widget_dev_core/src/materia/CreatorEvents.as +38 -0
  206. data/lib/mako/data/flash_widget_dev_core/src/materia/Dialog.as +35 -0
  207. data/lib/mako/data/flash_widget_dev_core/src/materia/MateriaButton.as +35 -0
  208. data/lib/mako/data/flash_widget_dev_core/src/materia/PopUpAlert.mxml +271 -0
  209. data/lib/mako/data/flash_widget_dev_core/src/materia/components/GradientBackground.as +41 -0
  210. data/lib/mako/data/flash_widget_dev_core/src/materia/components/PercentField.mxml +104 -0
  211. data/lib/mako/data/flash_widget_dev_core/src/materia/components/ScrollableSizableImage.mxml +654 -0
  212. data/lib/mako/data/flash_widget_dev_core/src/materia/components/TextAreaWithDefaultText.mxml +94 -0
  213. data/lib/mako/data/flash_widget_dev_core/src/materia/components/TextInputWithDefaultText.mxml +94 -0
  214. data/lib/mako/data/flash_widget_dev_core/src/materia/components/VertCenterTextRenderer.mxml +37 -0
  215. data/lib/mako/data/flash_widget_dev_core/src/materia/components/importer/ImportEvent.as +22 -0
  216. data/lib/mako/data/flash_widget_dev_core/src/materia/components/importer/itemRenderers/CheckBoxColumn.mxml +23 -0
  217. data/lib/mako/data/flash_widget_dev_core/src/materia/components/importer/questions/QuestionDetails.mxml +68 -0
  218. data/lib/mako/data/flash_widget_dev_core/src/materia/components/importer/questions/QuestionDisplay.mxml +38 -0
  219. data/lib/mako/data/flash_widget_dev_core/src/materia/components/importer/questions/QuestionsDataGrid.mxml +247 -0
  220. data/lib/mako/data/flash_widget_dev_core/src/materia/components/importer/questions/QuestionsDataGridEvent.as +20 -0
  221. data/lib/mako/data/flash_widget_dev_core/src/materia/components/questionAnswerDataGrid/QuestionAnswerColumn.as +13 -0
  222. data/lib/mako/data/flash_widget_dev_core/src/materia/components/questionAnswerDataGrid/QuestionAnswerDataGrid.mxml +692 -0
  223. data/lib/mako/data/flash_widget_dev_core/src/materia/components/questionAnswerDataGrid/TextInputItem.mxml +584 -0
  224. data/lib/mako/data/flash_widget_dev_core/src/materia/components/questionAnswerDataGrid/TextInputObject.as +28 -0
  225. data/lib/mako/data/flash_widget_dev_core/src/materia/components/toolTips/KogneatoToolTip.as +196 -0
  226. data/lib/mako/data/flash_widget_dev_core/src/materia/components/toolTips/TipManager.as +150 -0
  227. data/lib/mako/data/flash_widget_dev_core/src/materia/help/HelpBubble.mxml +245 -0
  228. data/lib/mako/data/flash_widget_dev_core/src/materia/help/HelpDot.mxml +21 -0
  229. data/lib/mako/data/flash_widget_dev_core/src/materia/help/HelpManager.as +92 -0
  230. data/lib/mako/data/flash_widget_dev_core/src/materia/help/HelpObject.as +33 -0
  231. data/lib/mako/data/flash_widget_dev_core/src/materia/help/IHelpGuided.as +7 -0
  232. data/lib/mako/data/flash_widget_dev_core/src/materia/media/ImageCacherImage.mxml +56 -0
  233. data/lib/mako/data/flash_widget_dev_core/src/materia/media/MateriaUploader.as +61 -0
  234. data/lib/mako/data/flash_widget_dev_core/src/materia/questionStorage/Question.as +386 -0
  235. data/lib/mako/data/flash_widget_dev_core/src/materia/questionStorage/QuestionGroup.as +313 -0
  236. data/lib/mako/data/flash_widget_dev_core/src/materia/questionStorage/QuestionSet.as +21 -0
  237. data/lib/mako/data/flash_widget_dev_core/src/materia/toolTips/KogneatoToolTip.as +196 -0
  238. data/lib/mako/data/flash_widget_dev_core/src/materia/toolTips/TipManager.as +150 -0
  239. data/lib/mako/data/flash_widget_dev_core/src/materia/utils/CommonUtils.as +186 -0
  240. data/lib/mako/data/flash_widget_dev_core/src/materia/utils/DateUtils.as +273 -0
  241. data/lib/mako/data/flash_widget_dev_core/src/materia/utils/ImageCacher.as +93 -0
  242. data/lib/mako/data/flash_widget_dev_core/src/nm/arrays/Randomize.as +19 -0
  243. data/lib/mako/data/flash_widget_dev_core/src/nm/arrays/SimpleClone.as +32 -0
  244. data/lib/mako/data/flash_widget_dev_core/src/nm/draw/Color.as +102 -0
  245. data/lib/mako/data/flash_widget_dev_core/src/nm/draw/Draw.as +65 -0
  246. data/lib/mako/data/flash_widget_dev_core/src/nm/draw/lines/Dashed.as +48 -0
  247. data/lib/mako/data/flash_widget_dev_core/src/nm/draw/lines/Dotted.as +83 -0
  248. data/lib/mako/data/flash_widget_dev_core/src/nm/draw/shapes/Check.as +27 -0
  249. data/lib/mako/data/flash_widget_dev_core/src/nm/draw/shapes/Rect.as +12 -0
  250. data/lib/mako/data/flash_widget_dev_core/src/nm/draw/shapes/RectBevel.as +35 -0
  251. data/lib/mako/data/flash_widget_dev_core/src/nm/draw/shapes/RectBorder.as +39 -0
  252. data/lib/mako/data/flash_widget_dev_core/src/nm/draw/shapes/RectRound.as +33 -0
  253. data/lib/mako/data/flash_widget_dev_core/src/nm/draw/shapes/RectRoundBorder.as +62 -0
  254. data/lib/mako/data/flash_widget_dev_core/src/nm/draw/shapes/TriangleEquilateral.as +25 -0
  255. data/lib/mako/data/flash_widget_dev_core/src/nm/draw/shapes/X.as +28 -0
  256. data/lib/mako/data/flash_widget_dev_core/src/nm/errors/ScoringError.as +10 -0
  257. data/lib/mako/data/flash_widget_dev_core/src/nm/errors/StorageError.as +10 -0
  258. data/lib/mako/data/flash_widget_dev_core/src/nm/events/ButtonEvent.as +25 -0
  259. data/lib/mako/data/flash_widget_dev_core/src/nm/events/PayloadEvent.as +14 -0
  260. data/lib/mako/data/flash_widget_dev_core/src/nm/events/StandardEvent.as +26 -0
  261. data/lib/mako/data/flash_widget_dev_core/src/nm/gameServ/common/Question.as +72 -0
  262. data/lib/mako/data/flash_widget_dev_core/src/nm/gameServ/common/QuestionGroup.as +87 -0
  263. data/lib/mako/data/flash_widget_dev_core/src/nm/gameServ/common/QuestionSet.as +35 -0
  264. data/lib/mako/data/flash_widget_dev_core/src/nm/gameServ/common/WidgetSettings.as +14 -0
  265. data/lib/mako/data/flash_widget_dev_core/src/nm/gameServ/common/coms/ServerEvents.as +17 -0
  266. data/lib/mako/data/flash_widget_dev_core/src/nm/gameServ/common/coms/ServerMessageEvent.as +31 -0
  267. data/lib/mako/data/flash_widget_dev_core/src/nm/gameServ/common/logging/Log.as +92 -0
  268. data/lib/mako/data/flash_widget_dev_core/src/nm/gameServ/common/scoring/Scoring.as +87 -0
  269. data/lib/mako/data/flash_widget_dev_core/src/nm/gameServ/common/storage/StorageManager.as +91 -0
  270. data/lib/mako/data/flash_widget_dev_core/src/nm/gameServ/common/storage/StorageTable.as +72 -0
  271. data/lib/mako/data/flash_widget_dev_core/src/nm/gameServ/engines/EngineCore.as +222 -0
  272. data/lib/mako/data/flash_widget_dev_core/src/nm/geom/Dimension.as +76 -0
  273. data/lib/mako/data/flash_widget_dev_core/src/nm/respondus/Respondus.as +612 -0
  274. data/lib/mako/data/flash_widget_dev_core/src/nm/respondus/RespondusAnswer.as +11 -0
  275. data/lib/mako/data/flash_widget_dev_core/src/nm/respondus/RespondusError.as +18 -0
  276. data/lib/mako/data/flash_widget_dev_core/src/nm/respondus/RespondusQuestion.as +43 -0
  277. data/lib/mako/data/flash_widget_dev_core/src/nm/respondus/RespondusQuiz.as +68 -0
  278. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/AlertWindow.as +182 -0
  279. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/BlueButton.as +102 -0
  280. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/Button.as +88 -0
  281. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/Button_base.as +168 -0
  282. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/Component.as +98 -0
  283. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/ContentBlocker.as +38 -0
  284. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/FlexUIScaler.as +59 -0
  285. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/FormInput.as +191 -0
  286. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/GrabZoomClip.as +305 -0
  287. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/HelpLayer.as +55 -0
  288. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/Label.as +25 -0
  289. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/List.as +62 -0
  290. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/List_Base.as +644 -0
  291. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/ProcessingBar.as +112 -0
  292. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/ProgressBar.as +35 -0
  293. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/ProgressBar_base.as +69 -0
  294. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/ScrollBar.as +163 -0
  295. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/ScrollBar_base.as +378 -0
  296. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/ScrollClip.as +468 -0
  297. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/ScrollText.as +29 -0
  298. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/ScrollText_base.as +295 -0
  299. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/SimpleScrollBar.as +247 -0
  300. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/StageRef.as +34 -0
  301. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/StorageTank.as +233 -0
  302. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/StorageTankHorizontal.as +109 -0
  303. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/ToolTip.as +930 -0
  304. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/TweeningDragDropBankList.as +503 -0
  305. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/Window.as +144 -0
  306. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/Window_base.as +385 -0
  307. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/layout/CenterScale.as +27 -0
  308. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/layout/WindowManager.as +163 -0
  309. data/lib/mako/data/flash_widget_dev_core/src/nm/ui/layout/WindowStage.as +96 -0
  310. data/lib/mako/data/flash_widget_dev_core/src/nm/util/BitField.as +99 -0
  311. data/lib/mako/data/flash_widget_dev_core/src/nm/util/ObjPeek.as +148 -0
  312. data/lib/mako/data/flash_widget_dev_core/src/nm/util/Objects.as +49 -0
  313. data/lib/mako/data/flash_widget_dev_core/src/nm/util/Printer.as +548 -0
  314. data/lib/mako/data/flash_widget_dev_core/src/nm/util/StringUtil.as +12 -0
  315. data/lib/mako/data/flash_widget_dev_core/src/org/rubyamf/remoting/ssr/FaultEvent.as +37 -0
  316. data/lib/mako/data/flash_widget_dev_core/src/org/rubyamf/remoting/ssr/RemotingCall.as +211 -0
  317. data/lib/mako/data/flash_widget_dev_core/src/org/rubyamf/remoting/ssr/RemotingConnection.as +41 -0
  318. data/lib/mako/data/flash_widget_dev_core/src/org/rubyamf/remoting/ssr/RemotingService.as +214 -0
  319. data/lib/mako/data/flash_widget_dev_core/src/org/rubyamf/remoting/ssr/ResultEvent.as +36 -0
  320. data/lib/mako/data/flash_widget_dev_core/src/sandy/util/DistortImage.as +281 -0
  321. data/lib/mako/data/flash_widget_dev_core/src/sandy/util/SandyPoint.as +29 -0
  322. data/lib/mako/data/flash_widget_dev_core/src/sandy/util/Triangle.as +32 -0
  323. data/lib/mako/data/html/thistest.html +0 -0
  324. data/lib/mako/data/template_creator/src/Creator.mxml +138 -0
  325. data/lib/mako/data/template_creator/src/assets/images/RichTextEditor.png +0 -0
  326. data/lib/mako/data/template_creator/src/assets/materia/images/DefaultError.png +0 -0
  327. data/lib/mako/data/template_creator/src/assets/materia/images/barbgfill.png +0 -0
  328. data/lib/mako/data/template_creator/src/assets/materia/images/barshadow.png +0 -0
  329. data/lib/mako/data/template_creator/src/assets/materia/images/bold.png +0 -0
  330. data/lib/mako/data/template_creator/src/assets/materia/images/bullets.png +0 -0
  331. data/lib/mako/data/template_creator/src/assets/materia/images/center.png +0 -0
  332. data/lib/mako/data/template_creator/src/assets/materia/images/close-x.png +0 -0
  333. data/lib/mako/data/template_creator/src/assets/materia/images/fullscreenPopup_close.png +0 -0
  334. data/lib/mako/data/template_creator/src/assets/materia/images/importIcon.png +0 -0
  335. data/lib/mako/data/template_creator/src/assets/materia/images/italic.png +0 -0
  336. data/lib/mako/data/template_creator/src/assets/materia/images/justify.png +0 -0
  337. data/lib/mako/data/template_creator/src/assets/materia/images/left.png +0 -0
  338. data/lib/mako/data/template_creator/src/assets/materia/images/oml-href-disabled.png +0 -0
  339. data/lib/mako/data/template_creator/src/assets/materia/images/oml-href.png +0 -0
  340. data/lib/mako/data/template_creator/src/assets/materia/images/oml-pagelink-disabled.png +0 -0
  341. data/lib/mako/data/template_creator/src/assets/materia/images/oml-pagelink.png +0 -0
  342. data/lib/mako/data/template_creator/src/assets/materia/images/oml-tooltip-delete.png +0 -0
  343. data/lib/mako/data/template_creator/src/assets/materia/images/oml-tooltip-disabled.png +0 -0
  344. data/lib/mako/data/template_creator/src/assets/materia/images/oml-tooltip-edit.png +0 -0
  345. data/lib/mako/data/template_creator/src/assets/materia/images/oml-tooltip.png +0 -0
  346. data/lib/mako/data/template_creator/src/assets/materia/images/pencil.png +0 -0
  347. data/lib/mako/data/template_creator/src/assets/materia/images/right.png +0 -0
  348. data/lib/mako/data/template_creator/src/assets/materia/images/underline.png +0 -0
  349. data/lib/mako/data/template_creator/src/assets/materia/images/videoPlayButton.png +0 -0
  350. data/lib/mako/data/template_creator/src/assets/materia/images/videoPlayerPauseButton.png +0 -0
  351. data/lib/mako/data/template_creator/src/assets/materia/images/videoPlayerPauseButton_over.png +0 -0
  352. data/lib/mako/data/template_creator/src/assets/materia/images/videoPlayerPlayButton.png +0 -0
  353. data/lib/mako/data/template_creator/src/assets/materia/images/videoPlayerPlayButton_over.png +0 -0
  354. data/lib/mako/data/template_creator/src/assets/materia/images/videoPlayerSoundButton.png +0 -0
  355. data/lib/mako/data/template_creator/src/assets/materia/images/videoPlayerSoundButton_over.png +0 -0
  356. data/lib/mako/data/template_creator/src/assets/materia/styles/creatorStyle.css +63 -0
  357. data/lib/mako/data/template_creator/src/assets/materia/styles/style.css +1127 -0
  358. data/lib/mako/data/template_creator/src/assets/materia/swf/embeddedfonts.swf +0 -0
  359. data/lib/mako/data/template_creator/src/assets/materia/swf/helpBubble.swf +0 -0
  360. data/lib/mako/data/template_creator/src/assets/materia/swf/kogneatoSymbols.swf +0 -0
  361. data/lib/mako/data/template_creator/src/assets/materia/swf/videobg.swf +0 -0
  362. data/lib/mako/data/template_creator/src/components/SmallRichTextEditor.mxml +678 -0
  363. data/lib/mako/data/template_creator/src/components/SmallRichTextEditorToolbar.mxml +133 -0
  364. data/lib/mako/data/templates/html/README.md +11 -0
  365. data/lib/mako/data/templates/html/_creator/build.yaml +12 -0
  366. data/lib/mako/data/templates/html/_creator/creator.html +19 -0
  367. data/lib/mako/data/templates/html/_creator/css/creator.less +29 -0
  368. data/lib/mako/data/templates/html/_creator/js/creator.coffee +122 -0
  369. data/lib/mako/data/templates/html/_creator/test.html +0 -0
  370. data/lib/mako/data/templates/html/_engine/build.yaml +12 -0
  371. data/lib/mako/data/templates/html/_engine/css/widget.scss +18 -0
  372. data/lib/mako/data/templates/html/_engine/js/widget.coffee +143 -0
  373. data/lib/mako/data/templates/html/_engine/widget.html +21 -0
  374. data/lib/mako/data/templates/html/_icons/icon-275.png +0 -0
  375. data/lib/mako/data/templates/html/_icons/icon-394.png +0 -0
  376. data/lib/mako/data/templates/html/_icons/icon-60.png +0 -0
  377. data/lib/mako/data/templates/html/_icons/icon-92.png +0 -0
  378. data/lib/mako/data/templates/html/_score/score_module.php +48 -0
  379. data/lib/mako/data/templates/html/_score/test_score_module.php +157 -0
  380. data/lib/mako/data/templates/html/_screen-shots/1-thumb.png +0 -0
  381. data/lib/mako/data/templates/html/_screen-shots/1.png +0 -0
  382. data/lib/mako/data/templates/html/_screen-shots/2-thumb.png +0 -0
  383. data/lib/mako/data/templates/html/_screen-shots/2.png +0 -0
  384. data/lib/mako/data/templates/html/_screen-shots/3-thumb.png +0 -0
  385. data/lib/mako/data/templates/html/_screen-shots/3.png +0 -0
  386. data/lib/mako/data/templates/html/build.yaml +4 -0
  387. data/lib/mako/data/templates/html/demo.yaml +7 -0
  388. data/lib/mako/data/templates/html/install.yaml +94 -0
  389. data/lib/mako/path.rb +48 -0
  390. data/lib/mako/scaffold.rb +69 -0
  391. metadata +597 -0
@@ -0,0 +1,584 @@
1
+ /*
2
+ Copyright (c) 2008, Adobe Systems Incorporated
3
+ All rights reserved.
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are
6
+ met:
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+ * Neither the name of Adobe Systems Incorporated nor the names of its
13
+ contributors may be used to endorse or promote products derived from
14
+ this software without specific prior written permission.
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+ */
27
+ package com.adobe.images
28
+ {
29
+ import flash.geom.*;
30
+ import flash.display.*;
31
+ import flash.utils.*;
32
+ /**
33
+ * Class that converts BitmapData into a valid JPEG
34
+ */
35
+ public class JPGEncoder
36
+ {
37
+ // Static table initialization
38
+ private var ZigZag:Array = [
39
+ 0, 1, 5, 6,14,15,27,28,
40
+ 2, 4, 7,13,16,26,29,42,
41
+ 3, 8,12,17,25,30,41,43,
42
+ 9,11,18,24,31,40,44,53,
43
+ 10,19,23,32,39,45,52,54,
44
+ 20,22,33,38,46,51,55,60,
45
+ 21,34,37,47,50,56,59,61,
46
+ 35,36,48,49,57,58,62,63
47
+ ];
48
+ private var YTable:Array = new Array(64);
49
+ private var UVTable:Array = new Array(64);
50
+ private var fdtbl_Y:Array = new Array(64);
51
+ private var fdtbl_UV:Array = new Array(64);
52
+ private function initQuantTables(sf:int):void
53
+ {
54
+ var i:int;
55
+ var t:Number;
56
+ var YQT:Array = [
57
+ 16, 11, 10, 16, 24, 40, 51, 61,
58
+ 12, 12, 14, 19, 26, 58, 60, 55,
59
+ 14, 13, 16, 24, 40, 57, 69, 56,
60
+ 14, 17, 22, 29, 51, 87, 80, 62,
61
+ 18, 22, 37, 56, 68,109,103, 77,
62
+ 24, 35, 55, 64, 81,104,113, 92,
63
+ 49, 64, 78, 87,103,121,120,101,
64
+ 72, 92, 95, 98,112,100,103, 99
65
+ ];
66
+ for (i = 0; i < 64; i++) {
67
+ t = Math.floor((YQT[i]*sf+50)/100);
68
+ if (t < 1) {
69
+ t = 1;
70
+ } else if (t > 255) {
71
+ t = 255;
72
+ }
73
+ YTable[ZigZag[i]] = t;
74
+ }
75
+ var UVQT:Array = [
76
+ 17, 18, 24, 47, 99, 99, 99, 99,
77
+ 18, 21, 26, 66, 99, 99, 99, 99,
78
+ 24, 26, 56, 99, 99, 99, 99, 99,
79
+ 47, 66, 99, 99, 99, 99, 99, 99,
80
+ 99, 99, 99, 99, 99, 99, 99, 99,
81
+ 99, 99, 99, 99, 99, 99, 99, 99,
82
+ 99, 99, 99, 99, 99, 99, 99, 99,
83
+ 99, 99, 99, 99, 99, 99, 99, 99
84
+ ];
85
+ for (i = 0; i < 64; i++) {
86
+ t = Math.floor((UVQT[i]*sf+50)/100);
87
+ if (t < 1) {
88
+ t = 1;
89
+ } else if (t > 255) {
90
+ t = 255;
91
+ }
92
+ UVTable[ZigZag[i]] = t;
93
+ }
94
+ var aasf:Array = [
95
+ 1.0, 1.387039845, 1.306562965, 1.175875602,
96
+ 1.0, 0.785694958, 0.541196100, 0.275899379
97
+ ];
98
+ i = 0;
99
+ for (var row:int = 0; row < 8; row++)
100
+ {
101
+ for (var col:int = 0; col < 8; col++)
102
+ {
103
+ fdtbl_Y[i] = (1.0 / (YTable [ZigZag[i]] * aasf[row] * aasf[col] * 8.0));
104
+ fdtbl_UV[i] = (1.0 / (UVTable[ZigZag[i]] * aasf[row] * aasf[col] * 8.0));
105
+ i++;
106
+ }
107
+ }
108
+ }
109
+ private var YDC_HT:Array;
110
+ private var UVDC_HT:Array;
111
+ private var YAC_HT:Array;
112
+ private var UVAC_HT:Array;
113
+ private function computeHuffmanTbl(nrcodes:Array, std_table:Array):Array
114
+ {
115
+ var codevalue:int = 0;
116
+ var pos_in_table:int = 0;
117
+ var HT:Array = new Array();
118
+ for (var k:int=1; k<=16; k++) {
119
+ for (var j:int=1; j<=nrcodes[k]; j++) {
120
+ HT[std_table[pos_in_table]] = new BitString();
121
+ HT[std_table[pos_in_table]].val = codevalue;
122
+ HT[std_table[pos_in_table]].len = k;
123
+ pos_in_table++;
124
+ codevalue++;
125
+ }
126
+ codevalue*=2;
127
+ }
128
+ return HT;
129
+ }
130
+ private var std_dc_luminance_nrcodes:Array = [0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0];
131
+ private var std_dc_luminance_values:Array = [0,1,2,3,4,5,6,7,8,9,10,11];
132
+ private var std_ac_luminance_nrcodes:Array = [0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d];
133
+ private var std_ac_luminance_values:Array = [
134
+ 0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,
135
+ 0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,
136
+ 0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08,
137
+ 0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,
138
+ 0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,
139
+ 0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28,
140
+ 0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,
141
+ 0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,
142
+ 0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59,
143
+ 0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,
144
+ 0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,
145
+ 0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89,
146
+ 0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,
147
+ 0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,
148
+ 0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6,
149
+ 0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,
150
+ 0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,
151
+ 0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2,
152
+ 0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,
153
+ 0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,
154
+ 0xf9,0xfa
155
+ ];
156
+ private var std_dc_chrominance_nrcodes:Array = [0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0];
157
+ private var std_dc_chrominance_values:Array = [0,1,2,3,4,5,6,7,8,9,10,11];
158
+ private var std_ac_chrominance_nrcodes:Array = [0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77];
159
+ private var std_ac_chrominance_values:Array = [
160
+ 0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,
161
+ 0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,
162
+ 0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91,
163
+ 0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,
164
+ 0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,
165
+ 0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26,
166
+ 0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38,
167
+ 0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,
168
+ 0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,
169
+ 0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,
170
+ 0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,
171
+ 0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87,
172
+ 0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96,
173
+ 0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,
174
+ 0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,
175
+ 0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,
176
+ 0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,
177
+ 0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,
178
+ 0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,
179
+ 0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,
180
+ 0xf9,0xfa
181
+ ];
182
+ private function initHuffmanTbl():void
183
+ {
184
+ YDC_HT = computeHuffmanTbl(std_dc_luminance_nrcodes,std_dc_luminance_values);
185
+ UVDC_HT = computeHuffmanTbl(std_dc_chrominance_nrcodes,std_dc_chrominance_values);
186
+ YAC_HT = computeHuffmanTbl(std_ac_luminance_nrcodes,std_ac_luminance_values);
187
+ UVAC_HT = computeHuffmanTbl(std_ac_chrominance_nrcodes,std_ac_chrominance_values);
188
+ }
189
+ private var bitcode:Array = new Array(65535);
190
+ private var category:Array = new Array(65535);
191
+ private function initCategoryNumber():void
192
+ {
193
+ var nrlower:int = 1;
194
+ var nrupper:int = 2;
195
+ var nr:int;
196
+ for (var cat:int=1; cat<=15; cat++) {
197
+ //Positive numbers
198
+ for (nr=nrlower; nr<nrupper; nr++) {
199
+ category[32767+nr] = cat;
200
+ bitcode[32767+nr] = new BitString();
201
+ bitcode[32767+nr].len = cat;
202
+ bitcode[32767+nr].val = nr;
203
+ }
204
+ //Negative numbers
205
+ for (nr=-(nrupper-1); nr<=-nrlower; nr++) {
206
+ category[32767+nr] = cat;
207
+ bitcode[32767+nr] = new BitString();
208
+ bitcode[32767+nr].len = cat;
209
+ bitcode[32767+nr].val = nrupper-1+nr;
210
+ }
211
+ nrlower <<= 1;
212
+ nrupper <<= 1;
213
+ }
214
+ }
215
+ // IO functions
216
+ private var byteout:ByteArray;
217
+ private var bytenew:int = 0;
218
+ private var bytepos:int = 7;
219
+ private function writeBits(bs:BitString):void
220
+ {
221
+ var value:int = bs.val;
222
+ var posval:int = bs.len-1;
223
+ while ( posval >= 0 ) {
224
+ if (value & uint(1 << posval) ) {
225
+ bytenew |= uint(1 << bytepos);
226
+ }
227
+ posval--;
228
+ bytepos--;
229
+ if (bytepos < 0) {
230
+ if (bytenew == 0xFF) {
231
+ writeByte(0xFF);
232
+ writeByte(0);
233
+ }
234
+ else {
235
+ writeByte(bytenew);
236
+ }
237
+ bytepos=7;
238
+ bytenew=0;
239
+ }
240
+ }
241
+ }
242
+ private function writeByte(value:int):void
243
+ {
244
+ byteout.writeByte(value);
245
+ }
246
+ private function writeWord(value:int):void
247
+ {
248
+ writeByte((value>>8)&0xFF);
249
+ writeByte((value )&0xFF);
250
+ }
251
+ // DCT & quantization core
252
+ private function fDCTQuant(data:Array, fdtbl:Array):Array
253
+ {
254
+ var tmp0:Number, tmp1:Number, tmp2:Number, tmp3:Number, tmp4:Number, tmp5:Number, tmp6:Number, tmp7:Number;
255
+ var tmp10:Number, tmp11:Number, tmp12:Number, tmp13:Number;
256
+ var z1:Number, z2:Number, z3:Number, z4:Number, z5:Number, z11:Number, z13:Number;
257
+ var i:int;
258
+ /* Pass 1: process rows. */
259
+ var dataOff:int=0;
260
+ for (i=0; i<8; i++) {
261
+ tmp0 = data[dataOff+0] + data[dataOff+7];
262
+ tmp7 = data[dataOff+0] - data[dataOff+7];
263
+ tmp1 = data[dataOff+1] + data[dataOff+6];
264
+ tmp6 = data[dataOff+1] - data[dataOff+6];
265
+ tmp2 = data[dataOff+2] + data[dataOff+5];
266
+ tmp5 = data[dataOff+2] - data[dataOff+5];
267
+ tmp3 = data[dataOff+3] + data[dataOff+4];
268
+ tmp4 = data[dataOff+3] - data[dataOff+4];
269
+ /* Even part */
270
+ tmp10 = tmp0 + tmp3; /* phase 2 */
271
+ tmp13 = tmp0 - tmp3;
272
+ tmp11 = tmp1 + tmp2;
273
+ tmp12 = tmp1 - tmp2;
274
+ data[dataOff+0] = tmp10 + tmp11; /* phase 3 */
275
+ data[dataOff+4] = tmp10 - tmp11;
276
+ z1 = (tmp12 + tmp13) * 0.707106781; /* c4 */
277
+ data[dataOff+2] = tmp13 + z1; /* phase 5 */
278
+ data[dataOff+6] = tmp13 - z1;
279
+ /* Odd part */
280
+ tmp10 = tmp4 + tmp5; /* phase 2 */
281
+ tmp11 = tmp5 + tmp6;
282
+ tmp12 = tmp6 + tmp7;
283
+ /* The rotator is modified from fig 4-8 to avoid extra negations. */
284
+ z5 = (tmp10 - tmp12) * 0.382683433; /* c6 */
285
+ z2 = 0.541196100 * tmp10 + z5; /* c2-c6 */
286
+ z4 = 1.306562965 * tmp12 + z5; /* c2+c6 */
287
+ z3 = tmp11 * 0.707106781; /* c4 */
288
+ z11 = tmp7 + z3; /* phase 5 */
289
+ z13 = tmp7 - z3;
290
+ data[dataOff+5] = z13 + z2; /* phase 6 */
291
+ data[dataOff+3] = z13 - z2;
292
+ data[dataOff+1] = z11 + z4;
293
+ data[dataOff+7] = z11 - z4;
294
+ dataOff += 8; /* advance pointer to next row */
295
+ }
296
+ /* Pass 2: process columns. */
297
+ dataOff = 0;
298
+ for (i=0; i<8; i++) {
299
+ tmp0 = data[dataOff+ 0] + data[dataOff+56];
300
+ tmp7 = data[dataOff+ 0] - data[dataOff+56];
301
+ tmp1 = data[dataOff+ 8] + data[dataOff+48];
302
+ tmp6 = data[dataOff+ 8] - data[dataOff+48];
303
+ tmp2 = data[dataOff+16] + data[dataOff+40];
304
+ tmp5 = data[dataOff+16] - data[dataOff+40];
305
+ tmp3 = data[dataOff+24] + data[dataOff+32];
306
+ tmp4 = data[dataOff+24] - data[dataOff+32];
307
+ /* Even part */
308
+ tmp10 = tmp0 + tmp3; /* phase 2 */
309
+ tmp13 = tmp0 - tmp3;
310
+ tmp11 = tmp1 + tmp2;
311
+ tmp12 = tmp1 - tmp2;
312
+ data[dataOff+ 0] = tmp10 + tmp11; /* phase 3 */
313
+ data[dataOff+32] = tmp10 - tmp11;
314
+ z1 = (tmp12 + tmp13) * 0.707106781; /* c4 */
315
+ data[dataOff+16] = tmp13 + z1; /* phase 5 */
316
+ data[dataOff+48] = tmp13 - z1;
317
+ /* Odd part */
318
+ tmp10 = tmp4 + tmp5; /* phase 2 */
319
+ tmp11 = tmp5 + tmp6;
320
+ tmp12 = tmp6 + tmp7;
321
+ /* The rotator is modified from fig 4-8 to avoid extra negations. */
322
+ z5 = (tmp10 - tmp12) * 0.382683433; /* c6 */
323
+ z2 = 0.541196100 * tmp10 + z5; /* c2-c6 */
324
+ z4 = 1.306562965 * tmp12 + z5; /* c2+c6 */
325
+ z3 = tmp11 * 0.707106781; /* c4 */
326
+ z11 = tmp7 + z3; /* phase 5 */
327
+ z13 = tmp7 - z3;
328
+ data[dataOff+40] = z13 + z2; /* phase 6 */
329
+ data[dataOff+24] = z13 - z2;
330
+ data[dataOff+ 8] = z11 + z4;
331
+ data[dataOff+56] = z11 - z4;
332
+ dataOff++; /* advance pointer to next column */
333
+ }
334
+ // Quantize/descale the coefficients
335
+ for (i=0; i<64; i++) {
336
+ // Apply the quantization and scaling factor & Round to nearest integer
337
+ data[i] = Math.round((data[i]*fdtbl[i]));
338
+ }
339
+ return data;
340
+ }
341
+ // Chunk writing
342
+ private function writeAPP0():void
343
+ {
344
+ writeWord(0xFFE0); // marker
345
+ writeWord(16); // length
346
+ writeByte(0x4A); // J
347
+ writeByte(0x46); // F
348
+ writeByte(0x49); // I
349
+ writeByte(0x46); // F
350
+ writeByte(0); // = "JFIF",'\0'
351
+ writeByte(1); // versionhi
352
+ writeByte(1); // versionlo
353
+ writeByte(0); // xyunits
354
+ writeWord(1); // xdensity
355
+ writeWord(1); // ydensity
356
+ writeByte(0); // thumbnwidth
357
+ writeByte(0); // thumbnheight
358
+ }
359
+ private function writeSOF0(width:int, height:int):void
360
+ {
361
+ writeWord(0xFFC0); // marker
362
+ writeWord(17); // length, truecolor YUV JPG
363
+ writeByte(8); // precision
364
+ writeWord(height);
365
+ writeWord(width);
366
+ writeByte(3); // nrofcomponents
367
+ writeByte(1); // IdY
368
+ writeByte(0x11); // HVY
369
+ writeByte(0); // QTY
370
+ writeByte(2); // IdU
371
+ writeByte(0x11); // HVU
372
+ writeByte(1); // QTU
373
+ writeByte(3); // IdV
374
+ writeByte(0x11); // HVV
375
+ writeByte(1); // QTV
376
+ }
377
+ private function writeDQT():void
378
+ {
379
+ writeWord(0xFFDB); // marker
380
+ writeWord(132); // length
381
+ writeByte(0);
382
+ var i:int;
383
+ for (i=0; i<64; i++) {
384
+ writeByte(YTable[i]);
385
+ }
386
+ writeByte(1);
387
+ for (i=0; i<64; i++) {
388
+ writeByte(UVTable[i]);
389
+ }
390
+ }
391
+ private function writeDHT():void
392
+ {
393
+ writeWord(0xFFC4); // marker
394
+ writeWord(0x01A2); // length
395
+ var i:int;
396
+ writeByte(0); // HTYDCinfo
397
+ for (i=0; i<16; i++) {
398
+ writeByte(std_dc_luminance_nrcodes[i+1]);
399
+ }
400
+ for (i=0; i<=11; i++) {
401
+ writeByte(std_dc_luminance_values[i]);
402
+ }
403
+ writeByte(0x10); // HTYACinfo
404
+ for (i=0; i<16; i++) {
405
+ writeByte(std_ac_luminance_nrcodes[i+1]);
406
+ }
407
+ for (i=0; i<=161; i++) {
408
+ writeByte(std_ac_luminance_values[i]);
409
+ }
410
+ writeByte(1); // HTUDCinfo
411
+ for (i=0; i<16; i++) {
412
+ writeByte(std_dc_chrominance_nrcodes[i+1]);
413
+ }
414
+ for (i=0; i<=11; i++) {
415
+ writeByte(std_dc_chrominance_values[i]);
416
+ }
417
+ writeByte(0x11); // HTUACinfo
418
+ for (i=0; i<16; i++) {
419
+ writeByte(std_ac_chrominance_nrcodes[i+1]);
420
+ }
421
+ for (i=0; i<=161; i++) {
422
+ writeByte(std_ac_chrominance_values[i]);
423
+ }
424
+ }
425
+ private function writeSOS():void
426
+ {
427
+ writeWord(0xFFDA); // marker
428
+ writeWord(12); // length
429
+ writeByte(3); // nrofcomponents
430
+ writeByte(1); // IdY
431
+ writeByte(0); // HTY
432
+ writeByte(2); // IdU
433
+ writeByte(0x11); // HTU
434
+ writeByte(3); // IdV
435
+ writeByte(0x11); // HTV
436
+ writeByte(0); // Ss
437
+ writeByte(0x3f); // Se
438
+ writeByte(0); // Bf
439
+ }
440
+ // Core processing
441
+ private var DU:Array = new Array(64);
442
+ private function processDU(CDU:Array, fdtbl:Array, DC:Number, HTDC:Array, HTAC:Array):Number
443
+ {
444
+ var EOB:BitString = HTAC[0x00];
445
+ var M16zeroes:BitString = HTAC[0xF0];
446
+ var i:int;
447
+ var DU_DCT:Array = fDCTQuant(CDU, fdtbl);
448
+ //ZigZag reorder
449
+ for (i=0;i<64;i++) {
450
+ DU[ZigZag[i]]=DU_DCT[i];
451
+ }
452
+ var Diff:int = DU[0] - DC; DC = DU[0];
453
+ //Encode DC
454
+ if (Diff==0) {
455
+ writeBits(HTDC[0]); // Diff might be 0
456
+ } else {
457
+ writeBits(HTDC[category[32767+Diff]]);
458
+ writeBits(bitcode[32767+Diff]);
459
+ }
460
+ //Encode ACs
461
+ var end0pos:int = 63;
462
+ for (; (end0pos>0)&&(DU[end0pos]==0); end0pos--) {
463
+ };
464
+ //end0pos = first element in reverse order !=0
465
+ if ( end0pos == 0) {
466
+ writeBits(EOB);
467
+ return DC;
468
+ }
469
+ i = 1;
470
+ while ( i <= end0pos ) {
471
+ var startpos:int = i;
472
+ for (; (DU[i]==0) && (i<=end0pos); i++) {
473
+ }
474
+ var nrzeroes:int = i-startpos;
475
+ if ( nrzeroes >= 16 ) {
476
+ for (var nrmarker:int=1; nrmarker <= nrzeroes/16; nrmarker++) {
477
+ writeBits(M16zeroes);
478
+ }
479
+ nrzeroes = int(nrzeroes&0xF);
480
+ }
481
+ writeBits(HTAC[nrzeroes*16+category[32767+DU[i]]]);
482
+ writeBits(bitcode[32767+DU[i]]);
483
+ i++;
484
+ }
485
+ if ( end0pos != 63 ) {
486
+ writeBits(EOB);
487
+ }
488
+ return DC;
489
+ }
490
+ private var YDU:Array = new Array(64);
491
+ private var UDU:Array = new Array(64);
492
+ private var VDU:Array = new Array(64);
493
+ private function RGB2YUV(img:BitmapData, xpos:int, ypos:int):void
494
+ {
495
+ var pos:int=0;
496
+ for (var y:int=0; y<8; y++) {
497
+ for (var x:int=0; x<8; x++) {
498
+ var P:uint = img.getPixel32(xpos+x,ypos+y);
499
+ var R:Number = Number((P>>16)&0xFF);
500
+ var G:Number = Number((P>> 8)&0xFF);
501
+ var B:Number = Number((P )&0xFF);
502
+ YDU[pos]=((( 0.29900)*R+( 0.58700)*G+( 0.11400)*B))-128;
503
+ UDU[pos]=(((-0.16874)*R+(-0.33126)*G+( 0.50000)*B));
504
+ VDU[pos]=((( 0.50000)*R+(-0.41869)*G+(-0.08131)*B));
505
+ pos++;
506
+ }
507
+ }
508
+ }
509
+ /**
510
+ * Constructor for JPEGEncoder class
511
+ *
512
+ * @param quality The quality level between 1 and 100 that detrmines the
513
+ * level of compression used in the generated JPEG
514
+ * @langversion ActionScript 3.0
515
+ * @playerversion Flash 9.0
516
+ * @tiptext
517
+ */
518
+ public function JPGEncoder(quality:Number = 50)
519
+ {
520
+ if (quality <= 0) {
521
+ quality = 1;
522
+ }
523
+ if (quality > 100) {
524
+ quality = 100;
525
+ }
526
+ var sf:int = 0;
527
+ if (quality < 50) {
528
+ sf = int(5000 / quality);
529
+ } else {
530
+ sf = int(200 - quality*2);
531
+ }
532
+ // Create tables
533
+ initHuffmanTbl();
534
+ initCategoryNumber();
535
+ initQuantTables(sf);
536
+ }
537
+ /**
538
+ * Created a JPEG image from the specified BitmapData
539
+ *
540
+ * @param image The BitmapData that will be converted into the JPEG format.
541
+ * @return a ByteArray representing the JPEG encoded image data.
542
+ * @langversion ActionScript 3.0
543
+ * @playerversion Flash 9.0
544
+ * @tiptext
545
+ */
546
+ public function encode(image:BitmapData):ByteArray
547
+ {
548
+ // Initialize bit writer
549
+ byteout = new ByteArray();
550
+ bytenew=0;
551
+ bytepos=7;
552
+ // Add JPEG headers
553
+ writeWord(0xFFD8); // SOI
554
+ writeAPP0();
555
+ writeDQT();
556
+ writeSOF0(image.width,image.height);
557
+ writeDHT();
558
+ writeSOS();
559
+ // Encode 8x8 macroblocks
560
+ var DCY:Number=0;
561
+ var DCU:Number=0;
562
+ var DCV:Number=0;
563
+ bytenew=0;
564
+ bytepos=7;
565
+ for (var ypos:int=0; ypos<image.height; ypos+=8) {
566
+ for (var xpos:int=0; xpos<image.width; xpos+=8) {
567
+ RGB2YUV(image, xpos, ypos);
568
+ DCY = processDU(YDU, fdtbl_Y, DCY, YDC_HT, YAC_HT);
569
+ DCU = processDU(UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT);
570
+ DCV = processDU(VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT);
571
+ }
572
+ }
573
+ // Do the bit alignment of the EOI marker
574
+ if ( bytepos >= 0 ) {
575
+ var fillbits:BitString = new BitString();
576
+ fillbits.len = bytepos+1;
577
+ fillbits.val = (1<<(bytepos+1))-1;
578
+ writeBits(fillbits);
579
+ }
580
+ writeWord(0xFFD9); //EOI
581
+ return byteout;
582
+ }
583
+ }
584
+ }
@@ -0,0 +1,133 @@
1
+ /*
2
+ Copyright (c) 2008, Adobe Systems Incorporated
3
+ All rights reserved.
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are
6
+ met:
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+ * Neither the name of Adobe Systems Incorporated nor the names of its
13
+ contributors may be used to endorse or promote products derived from
14
+ this software without specific prior written permission.
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+ */
27
+ package com.adobe.images
28
+ {
29
+ import flash.geom.*;
30
+ import flash.display.Bitmap;
31
+ import flash.display.BitmapData;
32
+ import flash.utils.ByteArray;
33
+ /**
34
+ * Class that converts BitmapData into a valid PNG
35
+ */
36
+ public class PNGEncoder
37
+ {
38
+ /**
39
+ * Created a PNG image from the specified BitmapData
40
+ *
41
+ * @param image The BitmapData that will be converted into the PNG format.
42
+ * @return a ByteArray representing the PNG encoded image data.
43
+ * @langversion ActionScript 3.0
44
+ * @playerversion Flash 9.0
45
+ * @tiptext
46
+ */
47
+ public static function encode(img:BitmapData):ByteArray {
48
+ // Create output byte array
49
+ var png:ByteArray = new ByteArray();
50
+ // Write PNG signature
51
+ png.writeUnsignedInt(0x89504e47);
52
+ png.writeUnsignedInt(0x0D0A1A0A);
53
+ // Build IHDR chunk
54
+ var IHDR:ByteArray = new ByteArray();
55
+ IHDR.writeInt(img.width);
56
+ IHDR.writeInt(img.height);
57
+ IHDR.writeUnsignedInt(0x08060000); // 32bit RGBA
58
+ IHDR.writeByte(0);
59
+ writeChunk(png,0x49484452,IHDR);
60
+ // Build IDAT chunk
61
+ var IDAT:ByteArray= new ByteArray();
62
+ for(var i:int=0;i < img.height;i++) {
63
+ // no filter
64
+ IDAT.writeByte(0);
65
+ var p:uint;
66
+ var j:int;
67
+ if ( !img.transparent ) {
68
+ for(j=0;j < img.width;j++) {
69
+ p = img.getPixel(j,i);
70
+ IDAT.writeUnsignedInt(
71
+ uint(((p&0xFFFFFF) << 8)|0xFF));
72
+ }
73
+ } else {
74
+ for(j=0;j < img.width;j++) {
75
+ p = img.getPixel32(j,i);
76
+ IDAT.writeUnsignedInt(
77
+ uint(((p&0xFFFFFF) << 8)|
78
+ (p>>>24)));
79
+ }
80
+ }
81
+ }
82
+ IDAT.compress();
83
+ writeChunk(png,0x49444154,IDAT);
84
+ // Build IEND chunk
85
+ writeChunk(png,0x49454E44,null);
86
+ // return PNG
87
+ return png;
88
+ }
89
+ private static var crcTable:Array;
90
+ private static var crcTableComputed:Boolean = false;
91
+ private static function writeChunk(png:ByteArray,
92
+ type:uint, data:ByteArray):void {
93
+ if (!crcTableComputed) {
94
+ crcTableComputed = true;
95
+ crcTable = [];
96
+ var c:uint;
97
+ for (var n:uint = 0; n < 256; n++) {
98
+ c = n;
99
+ for (var k:uint = 0; k < 8; k++) {
100
+ if (c & 1) {
101
+ c = uint(uint(0xedb88320) ^
102
+ uint(c >>> 1));
103
+ } else {
104
+ c = uint(c >>> 1);
105
+ }
106
+ }
107
+ crcTable[n] = c;
108
+ }
109
+ }
110
+ var len:uint = 0;
111
+ if (data != null) {
112
+ len = data.length;
113
+ }
114
+ png.writeUnsignedInt(len);
115
+ var p:uint = png.position;
116
+ png.writeUnsignedInt(type);
117
+ if ( data != null ) {
118
+ png.writeBytes(data);
119
+ }
120
+ var e:uint = png.position;
121
+ png.position = p;
122
+ c = 0xffffffff;
123
+ for (var i:int = 0; i < (e-p); i++) {
124
+ c = uint(crcTable[
125
+ (c ^ png.readUnsignedByte()) &
126
+ uint(0xff)] ^ uint(c >>> 8));
127
+ }
128
+ c = uint(c^uint(0xffffffff));
129
+ png.position = e;
130
+ png.writeUnsignedInt(c);
131
+ }
132
+ }
133
+ }