Actionscript 3 :: BitmapData To ByteArray?
Jul 28, 2010I am trying to serialize a Bitmap to store in an XML file. My plan is to turn the BitmapData into a byteArray, but I haven't been able to fine an example of this.
View 1 RepliesI am trying to serialize a Bitmap to store in an XML file. My plan is to turn the BitmapData into a byteArray, but I haven't been able to fine an example of this.
View 1 Repliesi want to do some cryptographic routines in my flash. I've encrypted .jpg files on my server, so I can't use simple Loader class, to download that data as Bitmap. I'm thinking to:
1) download it with URLLoader as BINARY data in ByteArray class.
2) decrypt the data
3) convert to BitmapData. (..., is this possible ?
how could I do image crypting in fl.
I need a function to change an ByteArray to BitmapData in 1 function:
makeBitmapData(bytes:ByteArray):BitmapData
Is this possible? Cause all I can find about this is first put the bytes in a loader. add listener to the complete event and then call a function that make the bitmap/bitmapdata. can this also be done in 1 function?
is there anything that will take a very large png (even larger then the total pixel limit of BitmapData) and load in the png as raw bytes into a bytearray and then take that array and grab only portions of the image to be able to generate a grid of usable bitmaps to render the very large png..I got to the point where I was able to get the png as a bytearray but from there I don't know how to grab a portion of the bytearray and attempt to load the partial bytes in a loader via loadBytes()..basically I think I need a decoder to decode the partial bytes to a bitmapdata.
View 2 RepliesI'm trying to grab the BitMapData from an Image, convert it to JPG, and send it to a server where it will be written to a file. It "looks" like it works, the resulting .jpg is the right size and displays in an image viewer, but there is no picture... just an off-white background. Here's a code snippet:
imgTemp.addEventListener(FlexEvent.UPDATE_COMPLETE , imageLoadedHandler);
...
private function imageLoadedHandler(event:Event):void {
if (imgTemp.width == 0) return;
[Code].....
Then send "ba" to the server where it's written as a .jpg.
The data "looks" right when I receive it on the server, correct length, bits look the same.
I am using [code]...
In the 4th line in the code above i am getting "Error: Error #2030: End of file was encountered." I checked the length of the pixels object which is 4 times the width*height of the rect object. Given that setPixels() functions reads unsigned int from bytearray and sets that value to pixels, I think it should work.
But I have no clue why this wont work. The pixels object is filled after RLE decoding of the data which i get from a server.
Is there any work around or any other method which I could try to use. The loader class wont work as the data that I get from the server is not in any of the recognized format.
i am rendering a BitmapData from my webcam and sending the rendered ByteArray(i cant compress using ZLIB because its not running on AIR) file as binary to a server side. problem is each JPEG picture is around 40kb and it needs to be compressed a bit.now i am not talking about resizing the image, just making the file size smaller. anyone know how to do this?
View 2 RepliesError #2030: End of file was encountered.
This method is not working
I am using it like this
var ba:ByteArray = new ByteArray();
ba = bmd.getPixels(bmd.rect);
bmd.setPixels(srcRect, ba);
bm.bitmapData = bmd;
img.source = bm;
I am working on a game, made with Flash (using AS3) The game has a fast ball and when this ball hits an object it has to make a sound... but the sound starts with delay (so the ball is far away when the sound is played).This sound is edited by me and it hasn't got any silences at the beginning.The method i'm currently using is the simplest one:
public var sonidoPuntos1:sonidopunto1 = new sonidopunto1()
and then...
sonidoPuntos1.play()
I am trying to introduce the file into a ByteArray and then playing it from there...
I know its a true Pain but does anyone know any way to convert wav ByteArray to mp3 ByteArray.
View 1 RepliesI'm using Flash 8, with this code in the first frame:
import flash.display.BitmapData;
rissa._x=Stage.width/2;
rissa._y=Stage.height/2;[code].....
When I publish the file, I'm getting the following error message in the Output panel:
**Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 7: The class or interface 'BitmapData.loadBitmap' could not be loaded.
var plaid:BitmapData.loadBitmap("plaid");
Total ActionScript Errors: 1 Reported Errors: 1
I am trying to use the reflect class from "http://pixelfumes.blogspot.com/2007/03/reflection-class-v3-with-source .html" but I keep getting this error:
ArgumentError: Error #2015: Invalid BitmapData.
at flash.display::BitmapData()
at Reflect()
at Site_fla::GalleryPage_29/loadThumbs()
at Site_fla::GalleryPage_29/sortXML()
[Code]...
btw, first I used assigned thumbContainer as the mc argument (outside the loadThumbs() function) and it worked but not exactly what I wanted... because I thought it is supposed to update when the movieclip is animated but it actually didn't... when I use a scroller, only the thumbs that are first loaded to the stage get the reflection..
I've been using BitmapData.copyPixels() to draw graphics onto a canvas (Bitmap).I need to rotate the resulting graphics without the use of draw() because it's vastly slower.How can I rotate the target graphic? I'm assuming that there might be a formula or library that I can use which will first reorganize the pixels that make up a graphic based on an origin (point) and radians.I'm pretty certain that I'm not capable of creating such logic, so if there are any known libraries that do this, that would be awesome.I'd like to achieve something similar to XNA's SpriteBatch.Draw() method, which accepts rotation as its 5th argument.
View 3 Replieshow to use the bitmapData collision method. Now I'm trying to figure out if there is a way to see at what angle or coordinate of the bitmapData the collision happens? I need it in order to figure the accurate bounce angle after the collision occurs.
View 2 RepliesI'm currently working on a flash game and I need to know how to addChild a BitmapData or draw a BitmapData to screen. If I can't than how can I give a DisplayObject my BitmapData?
View 2 RepliesI've made a mobile version of my software, with low-res images and such, and I can now fully buffer all my content (including a 360 frame animation which is buffered to memory). Problem is, that everytime I update the view, more memory is used.When I write image = new BitmapData();, does it store the previously created BitmapData's in memory? Do I have to flush the memory somehow before I draw my second picture in BitmapData?Example:
ActionScript Code:
// In this example I draw using the same bitmapData several times, also
//overwriting the first image. Do I have to somehow delete the data first, to
[code].....
I am having an issue with using BitmapData.draw(stage). I am getting the following error:
SecurityError: Error #2123: Security sandbox violation: BitmapData.draw: file:///C|/Documents%20and%20Settings/bla...bla...bla.swf cannot access null. No policy files granted access. Here is a portion of my code:
var bd:BitmapData = new BitmapData(2800, 2100); bd.draw(stage);//this is where the error happens All of the files referenced (.xml/.jpg/.swf) are located in the same local folder as the main .swf. How do I get around this error? The main objective is to print the stage using PrintJob(). I am using Flash Professional CS5.5 and publishing to Flash 10.0/10.1. Let me know if I need to supply any more info.
The title might be a little misleading. Look at my code and I will explain
public static function loadTile(tileDir:String = "empty"):void
{
if(tileDir != "empty")
{
tPoint = new Point(0,0);
tRect = new Rectangle(0,0,30,30);
[Code]...
I am trying to do tiling with sprites. I want my tiles to be interactive, so that is why I am using the sprite object instead of using regular bitMaps to represent my tiles. You might be wondering why I wouldnt just use graphics.beginBitmapFill(tImage); and graphics.drawRect(0, 0,tWidth ,tHeight ); to pick out the tiles I want to use. Well reason being is because it turns out that drawRect() first and second parameters actually alter the location of where the actual sprite sits at.
So if I set the x and y properties of the sprite to x = 20, and y = 20. then I set my drawRect(20,20). it actually adds an extra 20 pixels to my x and y coords of my sprite. And I know the reason why, I just need to know a better way.
Who knows how to send a ByteArray to FMS?
View 1 RepliesI am trying to create a new swf with AIR and Flash CS3. All I want to do is push a button and have a new swf saved to the desktop with a line of actionscript in it. The actionscript can be anything stop(); - for instance.I have been messing around with ByteArray and I can save an image to a swf but I can't find any information on what I want to do.
View 2 Repliesat the current status of my project i must write an application (With AIR or ZINC) who its job is:
1st-getting some files from user. 2nd-modify them with an algorithm (encryption or encoding or changing byteArray) to simply corrupt the file and make it impossible for other applications to read the corrupted file!
[Code]...
Is there a way to write a UTF-16 string into a ByteArray in Flash/AS3? Basically I have a string (var test:String="allan"; for example) and I would like to write that into a ByteArray with UTF-16LE encoding. In this case it would be "61 00 6C 00 6C 00 61 00 6E 00".
I've tried using utf16le.writeMultiByte( clipText, "utf-16" ); but it just comes out with what appears to be UTF8 (or just straight ASCII given the test string).
The use case is to save a UTF-16LE file using FileReference.save(), which I understand I can do by passing it a ByteArray with the correct character encoding in it. Passing just a string saves as UTF-8. Hence the need to convert and store into a UTF-16LE representation in a ByteArray.
I get Index out of bounds when trying to readObject on my Byte array into the XML object.
private var fr:FileReference;
private var data:ByteArray = new ByteArray();
[Bindable]
private var dataXML:XML = new XML();[code]....
The Byte array is created by loading a file using FileReference
i'm using AMFPHP to stream content from my server to my Flex application, since Flash is a clientside technology i would like to make it harder for people to grab protected files, so i created a system that streams swf file to another flash player, i've done all the testing on URL stream, now i want to pass the swf file to the player as bytearray .. since i think it's safer and harder to break and in the future i even might do some encryption of my own if i became more familiar with bytes and bits .. anyways is my method the best one? (SWF to ByteArray?) or is there a better one? if the bytearray method is the best, i am facing a problem in outputing the swf file in the right format, i'm using a very primitive method .
[Code]...
We have requirement with the AIR application which loads the flex generated swf which inturn loads the flash generated swf using SWFLoader. This is not working as desired.This gives the following error: SecurityError: Error #3226: Cannot import a SWF file when LoaderContext.allowCodeImport is false.
[Code]...
The BLOB field (pic) is turning out as 0 Bytes when trying to send ByteArray through as3 to PHP, so i assume the PHP script or the HTTP_RAW_POST_DATA isn't working.I think the Flash part is working, I have set a trace() to see if the bitmapdata is coming through and it seems it is, so I'm assuming its my php side.3
private function export():void
{
var bmd:BitmapData = new BitmapData(600, 290);
[code].....
I want to make a flash application in which i will load 3-4 different mp3 files of different instrumental music. After loading it I want play all files. Further I want to save or create a merged mp3, from all mp3s sound files in a single mp3 file.
Is it possible to convert different mp3 sound track in to different ByteArray and later using any other technology like PHP or C# can we merge all byteArray in a single byteArray to create a single mp3 file.
So that we can listen all instrument playing in a single mp3 file.
I have a load of information in a swf that I'm loading at runtime. From that swf I need to get raw vector data out of some MovieClips, and other MovieClips I need to instantiate and put on the stage.Currently I can get at the vector data by loading the swf as a ByteArray using a URLLoader and parsing it with a bit of help from as3swf.
However, if I want to instantiate one of the MovieClips directly I would usually load it with a Loader and get at the MovieClip via loaderInfo.applicationDomain.My question is: can I either load the swf as a ByteArray with URLLoader and somehow instantiate MovieClips from that, or can I load the swf as a DisplayObject using a Loader, get the MovieClips and then convert the swf to a ByteArray before giving it to as3swf for parsing?
Summary: is there usually a lag when recording audio from the mic? I am using Thibault Imbert 'micrecorder' library on google code to record audio from the mic into a ByteArray. I am instructing my users to speak two seconds after the recorder starts. I know its two seconds after the recorder starts, rather than two seconds after the user presses the record button, because micrecorder issues time adjusted events of the recorder progress.
When I get the finished ByteArray the actual floats inside it that record the user speaking seem to be 2.5 seconds worth of samples into the ByteArray! So my question, as this is the first time I have recorded audio, is it usual to find a lag like this when recording? Or do you think I am getting something wrong with my math when indexing into the ByteArray?
Any way to load an FLV into a ByteArray, modify it (maybe add a water mark) and pass it to the Video Object for display?
View 2 Replies