Results 1 to 4 of 4

Thread: BitmapData.graphics implementation

Hybrid View

  1. #1
    236
    posts
    Artist/Programmer

    BitmapData.graphics implementation

    I've extended the BitmapData class to enable the following type of coding. All graphics calls are supported. Haven't done any performance testing but if anyone wants to test it - feel free.

    Code:
    // EXAMPLE USAGE
    
    import BitmapDataEx;  // BitmapDataEx extends flash.display.BitmapData
    
    // create a BitmapDataEx object in exactly the same way 
    // as you would create a BitmapData object 
    
    var bmd = new BitmapDataEx(100, 100, true, 0xFFaabbcc);
    
    // convert such to a displayable bitmap
    
    var bitmap = new Bitmap(bmd);
    
    // add the bitmap to the display list so it will be visible
    
    addChild(bitmap);
    
    // position the bitmap
    
    bitmap.x = 100;
    bitmap.y = 100;
    
    // use graphics calls on the bitmap 
    
    bmd.graphics.clear();
    bmd.graphics.lineStyle(1,0xFF0000);
    bmd.graphics.beginFill(0xffbbaa);
    bmd.graphics.drawCircle(50,50,40);
    bmd.graphics.endFill();
    
    // drawings are not actually drawn until you call draw 
    
    bmd.graphics.draw();
    Attached Files Attached Files

  2. #2
    Yeh it would be interesting to see if draw() on a shape would be faster than draw on that bitmapData class.

    If someone tests it please tell us how it goes

  3. #3
    236
    posts
    Artist/Programmer
    Quote Originally Posted by Dazzer View Post
    Yeh it would be interesting to see if draw() on a shape would be faster than draw on that bitmapData class.
    It won't be any faster. That's a certainty.

    The class is based on the following assumptions:

    1. Drawing using a Shape object is already the most efficient way of using the drawing API.

    2. Drawing to BitmapData (using the drawing API) - by passing a Shape object to the draw method of a BitmapData object - is already the most efficient way of doing such drawing.

    The class, if you have a look at the code, does no more than use it's own private Shape object to facilitate drawing into itself.

    The real question is whether it is slower (or by how much).

    Carl

  4. #4

    new option for slideshow, preload only when needed

    Hello everyone.

    First off, kudos to Josh for making a gallery that everyone loves so much and is so great.

    I have read all of the 28 pages and i decided to combine a few things.

    i added the code so that, when in slideshow mode, the thumbnails travel with the appropriate section(meaning the thumbnail of the main image is always in view).
    I added something of my own so that when the slideshow reaches the end, it automatically cycles back to the front for ever (this works no matter how many sections there are in the thumb preview bar).

    Now i wanted to add something else but i cannot figure out if it works or not. From all the reading i did, since the inception of the new thumb gallery which i think is the best of all in terms of scalling( it works for a gallery of a few images as well as for one of hundreds), there was an issue with the slideshow function. You would have to wait for all the images to load at the moment of the slideshow. This was the main strength of the first version that preloaded the thumbs as the actual image, so NO WAITING.

    For this reason i added some code (but i was fiddling so i am not sure if it works or not) that loads in another container (called scroller2.container2) the images that will appear next int he slideshow so there is not need to wait while they load.

    I made sure it did not start from the first image in case the viewer starts the slideshow on the image number 15. I also made it so that when it cycles, it loads the images that were not loaded before the start of that particular one.

    I do not know if i am making any sense but here is the sample:

    http://www.nicolaszein.com/DELETE/xm...deshow%20test/

    please click on the swf file. There is the fla for you guys to check the code.

    Because the connection here is too fast i cannot see if it actually preloads the images or tucks it somewhere not to retrieve it again. I am suspicious because in simulate download on flash, once the images are loaded, the slideshow still preloads the next image everytime.

    I appreciate any help you guys can offer. Thanks again for Josh, phoenix68 (bon boulot en tout cas, and waywoodr for all your very hard work and mods.

    cheers.

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