Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Export JPEG
Viking board game
3D controller example
FAQ Page
Print Formatted and HTML Text Using a Browser
Super Debugging
Fake-3D Motion
123 Flash Menu
DirectInteraction Xtra
Macromedia Director Workshop
 

 

 

Behavior Copy matching Pixels

Added on 11/20/2000

 

Compatibilities:
behavior D8 Mac PC Shockwave

Rating:

Author: HasanKazmi (website)

Progressive Copy Of All matching Pixels Of specified color in one image to another Attach to any bitmap Sprite (Source Image), when clicked upon a certain point on the sprite all the pixels of the same color will be copied into another image. The size of the bitmap to which pix are being copied should be lagrer than or equal to the source. There is only one parameter in the behaviour... just fill in the Destination bitmap member number. Place both the images on stage and click on any point on the source bitmap sprite....No unnecessary checking and other code has been added for simplicity.

Download PC Source    Download Mac Source
--786

--Behaviour: Copy matching Pix
--Use: Progressive Copy Of All matching Pixels Of specified color in one image to another
--Programmer: Hasan Yasar Kazmi
-- Hamdard University Islamabad Pakistan.
-- dir@37.com
--14/Nov/2000.
--Instructions:

--Attach to any bitmap Sprite (Source Image), when clicked upon a certain point on the sprite all the pixels of the same color
--will be copied into another image. The size of the bitmap to which pix are being copied should be lagrer than the source
--. There is only one parameter field in the behaviour... just fill in the Destination bitmap member number.
--place both the images on stage and click on any point on the source bitmap sprite....
-- No unnecessary checking and other code has been added for simplicity.

--Code:

property spritenum, memref,copymem
on getPropertyDescriptionList
  set description = [:]
  addProp description, #copymem, [#default:1,#format:#integer,#comment:"Select Bitmap Member to Copy image to:"]
  return description
end

on beginsprite me
  spritenum = the spritenum of me
  memref = sprite(spritenum).membernum
end  

on mouseup me
put "0" into member("status")
  set mempt=  mapStageToMember(sprite (spritenum), the mouseloc)
  ImageCopy = member(memref).image.duplicate()
  ColRef=member(memref).image.getPixel(mempt)
  repeat with i = 0 to member(memref).height
    repeat with k = 0 to member(memref).width
      if ImageCopy.getPixel(k, i) = ColRef  then
        set pixcol = ImageCopy.getPixel(k, i)
        member(copymem).image.setPixel(k, i, pixcol)
        member("status").text = string(value(member("status").text) + 1)
        updatestage
      end if
    end repeat
  end repeat
  
end -- End of Code

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail