The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 12 of 12

Thread: can anyone tell me how to cut a image?

  1. #1

    can anyone tell me how to cut a image?

    I need to show only a certain portion of a dynamically loaded image, that is 32x32 pixels from the top right corner of the image.... how can i do this? remember, since it will be loaded dynamically, i will not know the size of the actual image from beforehand.

    PS: please try to help me for AS2 not AS3.
    Last edited by bluemagica; April 20th, 2008 at 12:41 AM.
    MY BLOG

    I need a SPRITER who can do pixel arts for an arcade fighter project. If you can help out, please pm me.
    I also need someone who can write simple xml files.


  2. #2
    Quote Originally Posted by bluemagica View Post
    I need to show only a certain portion of a dynamically loaded image, that is 32x32 pixels from the top right corner of the image.... how can i do this? remember, since it will be loaded dynamically, i will not know the size of the actual image from beforehand.

    PS: please try to help me for AS2 not AS3.
    You ought to do this in AS3

    CopyPixels is love.
    you = function(){
    setEnabled( true );
    live();
    setEnabled( false );
    }

  3. #3

  4. Quote Originally Posted by bluemagica View Post
    I need to show only a certain portion of a dynamically loaded image, that is 32x32 pixels from the top right corner of the image.... how can i do this? remember, since it will be loaded dynamically, i will not know the size of the actual image from beforehand.

    PS: please try to help me for AS2 not AS3.
    It is actually very easy. From this I learn that you don't really know copyPixels, which is a shame, you should learn and use that

    Anyways;
    Code:
    import flash.display.BitmapData;    // we will be using bitmapdatas
    import flash.geom.Point;            // we'll need points
    import flash.geom.Rectangle;        // we'll need rectangles.
    
    var picture:BitmapData = BitmapData.loadBitmap("picture");        // just loading the picture, there are actually several ways of doing this.
    var newPicture = new BitmapData(32, 32, true, 0xff0000ff);    // creating the new picture for your 32 x 32 corner.
    var mc:MovieClip = _root.createEmptyMovieClip("jklsadf", _root.getNextHighestDepth());    // creating a movieclip that will show the bitmapdatas.
    newPicture.copyPixels(picture, new Rectangle(0, 0, 32, 32), new Point(0, 0));    // cutting out the corner
    mc.attachBitmap(newPicture, _root.mc.getNextHighestDepth());    // attaching the picture to the mc so it will show.

  5. #5
    Thanks to all of you....but i'm sorry to say, that this went completely over my head, as i have no idea about BitmapData.... please tell me where can i find more info on this?

    and nathan99 thanks for the link, and ArmoredSandwitch thanks for giving a code and commenting it so well...
    MY BLOG

    I need a SPRITER who can do pixel arts for an arcade fighter project. If you can help out, please pm me.
    I also need someone who can write simple xml files.


  6. #6
    Help files....bitmapData or copyPixels

    This is a useful tutorial:
    http://www.nwebb.co.uk/nw_htmlsite/i...apdata1&part=1
    And more here:
    http://www.adobe.com/devnet/flash/ar...ge_api_05.html - copyPixels
    http://www.adobe.com/devnet/flash/ar...image_api.html - bitmapData class
    2006-11 GlosRFC - Searching 8,168,684,336 brain cells

  7. #7
    1,839
    posts
    Registered User
    just create a square thats as big as the viewable area,convert to symbol and give it a linkage id of "mask"

    then when you load your movie
    var holder = _root.createEmptyMovieClip("holder",1)
    var h2 =holder.createEmptyMovieClip("myImage",1)
    var h3 = h2.createEmptyMovieClip("actual_image",1)
    var m =holder.attachMovie("mask",2)
    h2.setMask(m)

    and it should just work
    edit: i know its not the best method...but its simple and it works

  8. #8
    -_- Masking is not at all useful on what i am set to do here...thats why i asked about how to "cut" the image, not just show a part of it....thanks anyway!!
    MY BLOG

    I need a SPRITER who can do pixel arts for an arcade fighter project. If you can help out, please pm me.
    I also need someone who can write simple xml files.


  9. #9
    Hey i dont knw if u got the solution. But here i had made this sometime back. Find the source files in the attached .rar file.if u need any help lemme knw. Here is the link http://download.yousendit.com/8D5F96AB18271614

  10. #10
    wow, thanks acebuddy, all that code kinda confused me at first, but i have got a hang of the things now...but i have got to study more....Bitmapdata is really powerful....very powerful
    MY BLOG

    I need a SPRITER who can do pixel arts for an arcade fighter project. If you can help out, please pm me.
    I also need someone who can write simple xml files.


  11. #11
    Quote Originally Posted by bluemagica View Post
    wow, thanks acebuddy, all that code kinda confused me at first, but i have got a hang of the things now...but i have got to study more....Bitmapdata is really powerful....very powerful
    Yea using bitmaData is really neat. Am glad i could help you.

  12. #12
    To do cutouts, just use scrollRect, it's sooooo much easier!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012