Comments (3)
Original comment by mikechambers
on 2 Jul 2008 at 4:52
- Added labels: Priority-Low
- Removed labels: Priority-Medium
from as3corelib.
Original comment by mikechambers
on 22 Sep 2009 at 8:17
- Changed state: Accepted
- Added labels: Priority-High
- Removed labels: Priority-Low
from as3corelib.
I was working with high resolution images at one point, and Actionscript kept
timing
out on the encode() method. As a result, I created an asynchronous version of
encode, which takes a callback function after the encoding is done. It doesn't
do
anything to speed it up, but it prevents Flash from crashing when encoding a
hi-res
image. There are probably better ways to do this than a timer, but it worked:
public function encodeAsync(image:BitmapData, fn:Function,
progressFn:Function=null):void {
var img:BitmapData = image.clone();
img.applyFilter(img, img.rect, orgn, fltrRGB2YUV);
var height:int = img.height;
var width:int = img.width;
// Initialize bit writer
byteout = new ByteArray();
bytenew=0;
bytepos=7;
// Add JPEG headers
writeWord(0xFFD8); // SOI
writeAPP0();
writeDQT();
writeSOF0(width,height);
writeDHT();
writeSOS();
// Encode 8x8 macroblocks
var DCY:int=0;
var DCU:int=0;
var DCV:int=0;
var t:Timer = new Timer(10, 0);
var ypos:int = 0;
var xpos:int = 0;
t.addEventListener(TimerEvent.TIMER, function(e:TimerEvent):void
{
for (var xpos:int=0; xpos<width; xpos+=8) {
RGB2YUV(img, xpos, ypos);
DCY = processDU(YDUBlock, fdtbl_YList, DCY, YDC_HT, YAC_HT);
DCU = processDU(UDUBlock, fdtbl_UVList, DCU, UVDC_HT, UVAC_HT);
DCV = processDU(VDUBlock, fdtbl_UVList, DCV, UVDC_HT, UVAC_HT);
}
ypos += 8;
if (ypos >= height)
{
img.dispose();
if ( bytepos >= 0 ) {
writeBits(new BitString((1<<(bytepos+1))-1, bytepos+1));
}
writeWord(0xFFD9);
t.stop();
fn(byteout);
}
if (progressFn) progressFn(Math.min(ypos/height, 1));
});
t.start();
}
Original comment by [email protected]
on 3 Mar 2010 at 4:48
from as3corelib.
Related Issues (20)
- BSD License
- PSD parser
- JSONEncoder bug on UTF-8 chars
- Request for StringUtil.contains
- Bug: JSONDecoder does not accept string ending in \u-escape sequence HOT 2
- Enhancement: Use a timer to close the FileTarget log stream. More efficient during heavy logging
- Escaped single quote is not correctly decoded
- Use "valueOf()" to customize JSON object
- Add line numbers to parse errors HOT 2
- JSONParseError: Unexpected c encountered
- After unwatch() is called in FileMonitor, eventListener is removed but is never re-added on watch().
- JSONDecoder fails with token null reference when closing right brace is missing
- FileMonitor onTimerEvent does not fire
- URI.makeAbsoluteURI does not handle local windows filepaths properly HOT 1
- JSON doesn't encode ObjectProxy and ManagedObjectProxy correctly
- JSON Object Problem within ArrayCollection
- JSONParseError: Unexpected e encountered HOT 1
- JSONParseError: Unexpected c encountered
- The HMAC-SHA1 signature generated is different for Ubuntu JAUNTY
- [deleted issue]
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from as3corelib.