Re: [Flashcoders] attachbitmap and copy pixels.

2006-10-19 Thread David Buff

Hi,

Just create a fla and import a picture (jpg)  in the librairy (minimum 
150,150). Link this picture with the id: picture_id

Then try this code.

import flash.display.BitmapData;
import flash.geom.Point;
import flash.geom.Rectangle;

var picture:BitmapData = BitmapData.loadBitmap(picture_id);
_root.createEmptyMovieClip(pictureMc,1);
pictureMc.attachBitmap(picture,1);

var subPicture:BitmapData = new BitmapData(100,100,false,0xFF);
_root.createEmptyMovieClip(subPictureMc,2);
subPictureMc.attachBitmap(subPicture,1);

var xPos:Number = 50;
var yPos:Number = 50;
var borderSize:Number = 10;

subPictureMc.onRelease = function() {
subPicture.copyPixels(picture,new 
Rectangle(xPos,yPos,subPicture.width-borderSize*2,subPicture.height-borderSize*2),new 
Point(borderSize,borderSize));

}

Your picture must be displayed. A red box will appear on it. Then click on 
the red box, a part of your picture is drawed into the red box.
Change the xPos, yPos and borderSize. You'll be abble to anderstand 
copyPixels with this exemple.


(but it don't show how to use the alpha channel... another time, when you'll 
be familiar with this)


enjoy,

David Buff

- Original Message - 
From: Johnny Zen [EMAIL PROTECTED]

To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com
Sent: Thursday, October 19, 2006 10:40 AM
Subject: [Flashcoders] attachbitmap and copy pixels.



Hi all

Can anyone give me a super simple example on using copypixels to take
a snapshot of a jpg within a movie clip. I'm having trouble
understanding the examples of bitmapdata and copypixels.

It would be a great help for me.


Best wishes


Johnny
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com



___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] attachbitmap and copy pixels.

2006-10-19 Thread David Buff

Just explain a little more...

subPicture.copyPixels(picture,new 
Rectangle(xPos,yPos,subPicture.width-borderSize*2,subPicture.height-borderSize*2),new 
Point(borderSize,borderSize));


It's mean:

-subPicture is the BitmapData where you want to copy the pixels
-copyPixels is a method of BitmapData object
-picture is the BitmapData witch is the source of pixels
-new Rectangle is a flash.geom.Rectangle object, witch define the top left 
point of the part of the source picture (inside the BitmapData here called 
picture) you want to copy, and the width and the height of this rectangle
-new Point is a flash.geom.Point object witch define the top left point 
inside the destination BitmapData where you want to copy your pixels 
(usually (0,0) but you can choose something else)


David Buff

- Original Message - 
From: David Buff [EMAIL PROTECTED]

To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com
Sent: Thursday, October 19, 2006 11:05 AM
Subject: Re: [Flashcoders] attachbitmap and copy pixels.



Hi,

Just create a fla and import a picture (jpg)  in the librairy (minimum 
150,150). Link this picture with the id: picture_id

Then try this code.

import flash.display.BitmapData;
import flash.geom.Point;
import flash.geom.Rectangle;

var picture:BitmapData = BitmapData.loadBitmap(picture_id);
_root.createEmptyMovieClip(pictureMc,1);
pictureMc.attachBitmap(picture,1);

var subPicture:BitmapData = new BitmapData(100,100,false,0xFF);
_root.createEmptyMovieClip(subPictureMc,2);
subPictureMc.attachBitmap(subPicture,1);

var xPos:Number = 50;
var yPos:Number = 50;
var borderSize:Number = 10;

subPictureMc.onRelease = function() {
subPicture.copyPixels(picture,new 
Rectangle(xPos,yPos,subPicture.width-borderSize*2,subPicture.height-borderSize*2),new 
Point(borderSize,borderSize));

}

Your picture must be displayed. A red box will appear on it. Then click on 
the red box, a part of your picture is drawed into the red box.
Change the xPos, yPos and borderSize. You'll be abble to anderstand 
copyPixels with this exemple.


(but it don't show how to use the alpha channel... another time, when 
you'll be familiar with this)


enjoy,

David Buff

- Original Message - 
From: Johnny Zen [EMAIL PROTECTED]

To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com
Sent: Thursday, October 19, 2006 10:40 AM
Subject: [Flashcoders] attachbitmap and copy pixels.



Hi all

Can anyone give me a super simple example on using copypixels to take
a snapshot of a jpg within a movie clip. I'm having trouble
understanding the examples of bitmapdata and copypixels.

It would be a great help for me.


Best wishes


Johnny
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com



___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com



___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] attachbitmap and copy pixels.

2006-10-19 Thread Johnny Zen

Thanks the help everyone.

Ok i'm slowly getting my head around this bitdata.

If I wanted to mask a bg pic using setmask.

Can i then copy the visible area using copypixels? and use this a
fixed image (snapshot) ? Seem to be stuck a little

here is my code as far:-

import flash.display.BitmapData;
import flash.geom.Point;
import flash.geom.Rectangle;

//create blank movieclip, create bd object. put pic into bd object,
then put object into movieclip.
var picture:BitmapData = BitmapData.loadBitmap(rawbg);
_root.createEmptyMovieClip(pictureMc,this.getNextHighestDepth());
pictureMc.attachBitmap(picture,1);
///

//create blank mc, attach piecepic to mc.
piece_mc = this.createEmptyMovieClip(orig, this.getNextHighestDepth());
piece_mc.attachMovie(piece0,piece0,this.getNextHighestDepth());
//
// create bd for peice. draw the piece into the bd object.
piece_bd = new BitmapData (this.piece_mc.width, 
this.piece_mc.height, true);
piece_bd.draw (this.piece_mc, this.matrix);

//apply mask
pictureMc.setMask(_root.piece_mc)

//HELP HERE - I dont understand this section, althougj think i'm on
the right lines.
piece_bd.copyPixels(piece_mc,new
Rectangle(xPos,yPos,subPicture.width-borderSize*2,subPicture.height-borderSize*2),new
Point(borderSize,borderSize));


//drag the fixed snapshot piece around
piece_mc.onRelease = function() {

this.startDrag();
}
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] attachbitmap and copy pixels.

2006-10-19 Thread Johnny Zen

any help on this anyone?

thanks


Johnny
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] attachbitmap and copy pixels.

2006-10-19 Thread David Buff
My english's not so good as I would like... Would like to help you but, 
could you be a little more understandable (for a frenchy) ??


- Original Message - 
From: Johnny Zen [EMAIL PROTECTED]

To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com
Sent: Thursday, October 19, 2006 2:04 PM
Subject: Re: [Flashcoders] attachbitmap and copy pixels.



any help on this anyone?

thanks


Johnny
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com



___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com