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
Explode Image Rotator [Flash 9, AS3] (263.8 KiB, 3,284 hits)
Explode Image Rotator [Silverlight 2, C#] (706.3 KiB, 3,133 hits)
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);
}
}

September 2nd, 2008 at 12:55 am
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!
September 3rd, 2008 at 5:34 pm
Very useful update. Very helpful tools for Image editing and image clipping.
Regards
Image clipping services India
September 3rd, 2008 at 7:04 pm
You can use an ImageBrush in Silverlight and make each piece a Rectangle, probably more efficient than making each an image and clipping.
September 3rd, 2008 at 11:46 pm
Bill, you are right. I will try to test over it in coming posts. Thank you very much for the suggestion.
September 4th, 2008 at 9:50 pm
[...] Read more [...]
September 12th, 2008 at 5:29 pm
pixu myulrfg sqftiv wcuiyrvn xrfeibwd ezdgiqtks gryzcd
October 11th, 2008 at 12:36 am
To use the ImageBrush sounds better. But I have no experiance with it. Therfore I will wait. ;-)
Peter
October 11th, 2008 at 11:18 am
Peter, you may referece the releated post of this. Those samples are implmented using ImageBrush.
October 17th, 2008 at 6:26 am
[...] 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 [...]
January 4th, 2009 at 11:22 am
hello it is test. WinRAR provides the full RAR and ZIP file support, can decompress CAB, GZIP, ACE and other archive formats.
zgxyoqryybsetxdvzronyhahkhpnefntlufhello
January 15th, 2009 at 3:33 am
[...] of rotators. Those rotators will includes my previous implementation like Grid Transition Rotator, Exploded Image Rotator, [...]
January 24th, 2009 at 7:12 am
Why you took longer writing the implementation in silverlight?
June 20th, 2009 at 11:54 am
[...] Explode Rotator [...]
June 22nd, 2009 at 3:40 pm
[...] Explode Rotator [...]
June 7th, 2010 at 6:07 am
It is Fun. Really a great example i like it very much. Thanks or your effort
July 13th, 2010 at 9:29 am
[...] Flash Silverlight Download [...]
October 8th, 2010 at 10:06 am
Music at times is more like perfume than mathematics. Gabriel Marcel