header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
Sunil
Points:0
Posts:0

6/2/2010 6:25:33 AM

Title: Can I take a snapshot of a main image from any X, Y position?


Hi,
I am trying to take a snap shot of my main Image “movie_mc” with the dimensions of “camera_mc”.
But snap shot starts from 0, 0 position of “movie_mc” only. How can I define the X, Y POSITION? So that, I will get exact snapshot of “movie_mc” where “camera_mc” is placed.
Can anybody tell me?
Thank you,
Sunil



var num:BitmapData = new BitmapData(camera_mc.width, camera_mc.height);
num.draw(movie_mc);
var reflectionBMP = new Bitmap(num);
addChild(reflectionBMP);




1
Kiney
Points: 530
Posts:0
6/2/2010 7:19:06 AM



you can define a rectangle to capture and draw , you can mention the starting and ending points look at this code to achieve bitmap capturing with all the defined coordinates. Your actionscript code should be like this:

var num:BitmapData = new BitmapData(camera_mc.width, camera_mc.height);
//provide the xy and width height of your bitmap
var rect:Rectangle= new Rectangle(100,100,800,800);
num.draw(movie_mc,null,null,null,rect,true);  
var reflectionBMP = new Bitmap(num);  
addChild(reflectionBMP); 

2
Sunil
Points: 0
Posts:0
6/2/2010 9:19:08 PM



Oops! Sorry again. But it creates a rectangle with the 0, 0 X and Y position only, and if I am trying to change it the rectangle not ready to move anywhere.
Thank you,
Sunil





var cameraVar:camera = new camera();
addChild(cameraVar);
cameraVar.x = 20;
cameraVar.y = 20;

var rect:Rectangle= new Rectangle(cameraVar.x,cameraVar.y,cameraVar.width,cameraVar.height); 
var num:BitmapData = new BitmapData(cameraVar.width, cameraVar.height);  

//provide the xy and width height of your bitmap  
 
num.draw(movieVar,null,null,null,rect,true);    
var reflectionBMP = new Bitmap(num);    
addChild(reflectionBMP);


3
Rayan
Points: 690
Posts:0
6/2/2010 10:37:43 PM



check this sample , simply replace the myTxt with your cameraVar. It captures only the myTxt box only where ever it is placed



<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="1024" minHeight="768" >
<mx:Script>  
	<![CDATA[  
		import flash.display.Bitmap;          
		private var capturedBitmap:Bitmap;  
		private var sp:Sprite;  
		private function init():void{                 
			var previewBM:BitmapData = new BitmapData(myTxt.width,myTxt.height);  
			previewBM.draw(myTxt);    
			capturedBitmap = new Bitmap(previewBM);  
			sp = new Sprite();  
			sp.addChild(capturedBitmap);  
			rawChildren.addChild(sp);  
			//reduce the size of preview  
			sp.scaleX=.5;  
			sp.scaleY=.5;     
		}     
	]]>  
</mx:Script>  
<mx:Label x="33" y="231" text="Capture Bitmap sample"/>  
<mx:Button x="305" y="186" click="init()" label="Capture Bitmap"/>  
<mx:TextArea id="myTxt" x="45" y="27" width="201" height="166" text="Capture Bitmap sample&#xa;Capture Bitmap sample&#xa;Capture Bitmap sample&#xa;Capture Bitmap sample&#xa;Capture Bitmap sample"/>
</mx:Application>



Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 1+4 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions