Calendar

March 2007
M T W T F S S
« Feb   Apr »
 1234
567891011
12131415161718
19202122232425
262728293031  

Tag Cloud

Categories

Archives

Highest Rated

Most Viewed

Recent Posts

Recent Comments


« Tutorials - Apollo (Community) | Main | CS3 Prices leaked »

SnapIt Apollo - Source Included

By Rich Tretola | March 26, 2007Print This Post Print This Post
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
232 views

I have had requests on how to take snap shot and save it to disk. So here is a vary basic example that takes a picture of itself and saves it to disk using the file name provided. Here is the guts of the function that saves the image:

snapit.jpg

  1. private function snagPic():void {
  2. bitmapData = new BitmapData(this.width,this.height);
  3. bitmapData.draw(this,new Matrix());
  4. var bitmap : Bitmap = new Bitmap(bitmapData);
  5. var jpg:JPGEncoder = new JPGEncoder();
  6. var ba:ByteArray = jpg.encode(bitmapData);
  7. newImage = File.appStorageDirectory.resolve("Images/" + fileName.text + ".jpg");
  8. fileStream = new FileStream();
  9. fileStream.open(newImage, FileMode.UPDATE);
  10. fileStream.writeBytes(ba);
  11. }

Please note you will need the core lib for the image encoders if you want to compile it yourself.

Download the application

Download source code

Share/Save/Bookmark

Topics: Adobe AIR, Tutorials |

One Response to “SnapIt Apollo - Source Included”

  1. Ashish Jha Says:
    October 6th, 2007 at 3:53 am

    are these codes only for adobe products.
    i don’t have kanowledge of flex but got the idea from thecodes.
    lets hope i can implement these ideas in xml and php

Comments