This content has been marked as final. Show 14 replies
your first one is reading libImgByteArray.length*(libImgByteArray.length+1)/2 array elements: check readByte().
Sorry I am confused.
How would you write the first test case to be faster than the second case?
Ah.. I see what you were getting at.
//BODY CODE - TEST 1
pixel = libImgByteArray.readInt();
pixAlpha = pixel >> 24 & 0xFF;
pixRed = pixel >> 16 & 0xFF;
pixGreen = pixel >> 8 & 0xFF;
pixBlue = pixel & 0xFF;
//Timed results in milliseconds
TOTAL TIME: 1482ms Average:296.4ms for 5 passes.
Versus the second test
TOTAL TIME: 1924ms Average:384.8ms for 5 passes.
So hence it is faster than I first thought. Thanks for the info. Can it be made even faster however is the question. By removing the bytesAvailable test in the while statement I was able to speed it up a little more. (about 30 milliseconds)
Can anyone suggest any faster ways of running through pixel data? Currently MOST of the time is taken to simply read the int from the bytearray. Any other tweaks that could be made to run even quicker? It is still only slightly faster than test 2. I still would have thought readByte / readInt would have been miles faster than test 2.
Am I still missing something or is this as fast as we can go in flashplayer 9?
this should be slightly faster:
I'm going to have to give this a try. I was doing something with 256 x 256 images where I needed to read just the red channel (they are grey-scale so it could be any of the three color channels really). I dabbled with byteArray a bit, but I didn't try this way of getting at it.
I also haven't tried using lock() with just the regular getPixel to see if that will speed things up. I guess I've got some work to do!
If you are going to handle gray scale, use the green channel. It presents a better toned image. Red is always to bright and yellow always to dark. A problem with digital camera chipsets but none the less. green always works better.
Thanks for the tip. Actually they are already grey scale. R=G=B so it doesn't matter. I have run into this issue in the past when converting to grey scale.
I want to download an image from a webservice. What would i potentially need in flash to get it working?
I came up with the following strategy:
Use a Bytearray to read in byte data of the image from the webservice. Each webservice call would return a different set of bytes, use these bytes to build the image in flash.
I am not too sure about the specifics either, (i also need help on this). For example, I believe i need to use the ByteArray class and do I need to get a raw socket hooked up to the server or is just using the return data from the webservice and making another call sufficient?
Any help is much appreciated.
where's the webservice (relative to your flash html) and what webservice is serving the image?
The webservice is located on another server machine relative to my flash file. They do not share the same network. The server is running a .NET webservice.
Thank you for your assistance.
so, you'll have a security issue that you will need to resolve before you can get data from that other server to the server hosting your swf. can you add files (like a cross-domain policy file) to the server that will supply the data?
Yes, i will be able to put a crossdomain.xml file on the server. (Curious, is there any other way of permitting the sandbox access without using crossdomain.xml or the allowDomain property internally?)
thank you for your continuing assitance.
i don't know of any other way to access data from a cross-domain.
but you should be ok using your xml file.
from there you need to load your bytearray data and create a bitmapdata object (using setPixels() ) and then create a bitmap from your bitmapdata object and finally add your bitmap to the display list.