Calendar

March 2007
S M T W T F S
« Feb   Apr »
 123
45678910
11121314151617
18192021222324
25262728293031

Tag Cloud

Categories

Archives

Recent Posts

Recent Comments


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

SnapIt Apollo – Source Included

By Rich Tretola | March 26, 2007
3,756 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
2
3
4
5
6
7
8
9
10
11
private function snagPic():void {
bitmapData = new BitmapData(this.width,this.height);
bitmapData.draw(this,new Matrix());
var bitmap : Bitmap = new Bitmap(bitmapData);
var jpg:JPGEncoder = new JPGEncoder();
var ba:ByteArray = jpg.encode(bitmapData);
newImage = File.appStorageDirectory.resolve("Images/" + fileName.text + ".jpg");
fileStream = new FileStream();
fileStream.open(newImage, FileMode.UPDATE);
fileStream.writeBytes(ba);
}

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

Topics: Adobe AIR, Tutorials | 1 Comment »

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

    Reply to this comment

Comments