Flash and Silverlight: Mystery Magic Background Flash and Silverlight: Fish Eye Menu
Aug 31

This is an advanced image rotator effect. If you always use fade in/out effect only, you probably have to look into this one. It included both Flash and Silverlight version with complete source codes. This is just one of the rotator effects in my hand, I will continue to post more in the coming days.

The images used in the example below were taken in 2007 during my trip to Mongolia.

Comparison

Flash implementation: 45 minutes
Silverlight implementation: 1.5 hour
Blog writing: 20 minutes
Code variation in the source code:

  • Image Cropping: copyPixels [AS3] vs Image.clip [C#]

Source codes

Flash

Silverlight

Image Cropping: copyPixels [AS3] vs Image.clip [C#]

In the above example, the explosion effect is created by breaking the image source into many tiny bitmap objects. It’s not too difficult to achieve this. Once you got the idea, you can create many amazing animation effect after breaking the image apart. Let’s take a look how I implement this.

// AS3
// define the width and height of each tiny objects
var gridWidth:Number = IMAGE_WIDTH / NUM_COLUMN;
var gridHeight:Number = IMAGE_HEIGHT / NUM_ROW;

for (var i:int = 0; i < NUM_COLUMN; i++)
{
    for (var j:int = 0; j < NUM_ROW; j++)
    {
        var offsetX:Number = i * gridWidth;
        var offsetY:Number = j * gridHeight;

        var newBitmapData:BitmapData = new BitmapDatagridWidth, gridHeight);
        var rectangle : Rectangle = new Rectangle(offsetX, offsetY, gridWidth, gridHeight);
        newBitmapData.copyPixels(bitmapSourceData, rectangle, new Point(0, 0));

        var bitmap:Bitmap = new Bitmap(newBitmapData);
        bitmap.x = offsetX;
        bitmap.y = offsetY;
        addChild(bitmap);
    }
}

However, in the case of C#, it seems that it doesn’t have Bitmap library for Silverlight (If you know there is any, please let me know). Therefore, I used another approach. I didn’t break the image part, in stead, I created many image objects and use the clipping property to achieve the same goal. However, I think this method is quite resource consuming since each time a whole image is created again.

// C#
for (int i = 0; i < NUM_COLUMN; i++)
{
    for (int j = 0; j < NUM_ROW; j++)
    {
        double offsetX = (double) i * gridWidth;
        double offsetY = (double) j * gridHeight;

        Image image = new Image();
        image.Source = new BitmapImage(new Uri(url, UriKind.Relative));

        // clip the image
        RectangleGeometry r = new RectangleGeometry();
        r.Rect = new Rect(offsetX, offsetY, gridWidth, gridHeight);
        image.Clip = r;

        // please note that we don't have to set the position in this case
        // However, please be careful about the position perspective
        this.Children.Add(image);
    }
}

Shares and Enjoy~

Did you like this post?

Subscribe here:  

16 Responses to “Flash and Silverlight: Explode Image Rotator”

  1. Ruurd Boeke Says:

    Yes, you can use the fjcore library (open source) to read a jpg and decode it. Then there is an ‘editable image’ implementation somewhere (sorry, no link here) that will allow you to create new images.

    I would agree that that is a better approach!

    nice work though!

  2. Image Clipping Says:

    Very useful update. Very helpful tools for Image editing and image clipping.

    Regards
    Image clipping services India

  3. Bill Reiss Says:

    You can use an ImageBrush in Silverlight and make each piece a Rectangle, probably more efficient than making each an image and clipping.

  4. admin Says:

    Bill, you are right. I will try to test over it in coming posts. Thank you very much for the suggestion.

  5. Flash Tutorials | Flash and Silverlight Effect | Lemlinh.com Says:

    [...] Read more [...]

  6. hdake velocsqd Says:

    pixu myulrfg sqftiv wcuiyrvn xrfeibwd ezdgiqtks gryzcd

  7. Peter Loebel Says:

    To use the ImageBrush sounds better. But I have no experiance with it. Therfore I will wait. ;-)

    Peter

  8. admin Says:

    Peter, you may referece the releated post of this. Those samples are implmented using ImageBrush.

  9. Silverlight Cream for October 09, 2008 -- #392 Says:

    [...] been asking about when RTW hits, what happens when people hit my site… good question and answer! Flash and Silverlight: Explode Image Rotator Using the way-back machine, I got this article from August for Terence Tsang on an exploding [...]

  10. AciseFesinvolinly Says:

    hello it is test. WinRAR provides the full RAR and ZIP file support, can decompress CAB, GZIP, ACE and other archive formats.
    zgxyoqryybsetxdvzronyhahkhpnefntlufhello

  11. Let’s Join Mix 09 - 10K challenge!! Says:

    [...] of rotators. Those rotators will includes my previous implementation like Grid Transition Rotator, Exploded Image Rotator, [...]

  12. Henry Says:

    Why you took longer writing the implementation in silverlight?

  13. 6 New Silverlight Image Rotators Says:

    [...] Explode Rotator [...]

  14. New Silverlight Image Rotators · News Says:

    [...] Explode Rotator [...]

  15. Mobile Phone Prices in India Says:

    It is Fun. Really a great example i like it very much. Thanks or your effort

  16. Flash ve Silverlight karşılaştırması | AdobeHaber Says:

    [...] Flash Silverlight Download [...]

Leave a Reply