Tuesday, August 02, 2005

Fixing one bug at a time in Flash Player 8: Bitmaps!

So now that Studio 8 is announced I can talk a little more about the 'hidden' improvements we made in Flash Player 8. As things slowly wind down work wise (finally doing Burning Man this year!) I'll try to regularly post new things on a variety of subjects, from bitmaps, vectors graphics, sound and text. There is so much new stuff the 'official' sources do not mention.

As you might know, Flash Player 7 still had a myriad of bitmap drawing issues. Some more severe than others. So as I got started on Flash Player 8 my goal was to kill all of these problems. The difficult part here was not to figure what is wrong but to retrofit essentially broken code while preserving backwards compatibility. Anytime you'll load a SWF which is version 7 or lower we have to guarantee 100% backwards compatibility.

Bitmap wrapping bug: The bug from hell. Essentially any time you rotate, flipped or changed the anchor point of bitmaps it would wrap a column and/or row. Here is an example which shows the difference between Flash Player 7 (above) and Flash Player 8 (below), you'll of course need Flash Player 8 to see the difference:










Snapping bug: When you rotated a bitmap and either hit a angle of 0 or 180 degrees, the bitmap would 'snap'. If you pay close attention you can also see that in the above Flash Player 7 example. This is closely related to the bitmap wrapping problem.

Confusing smoothing rules: In Flash Player 7 there were two ways of enabling bitmap smoothing. Either have a movie with 1 frame or set _quality="BEST". This is not only confusing but also inflexible with today's projects which sometimes have 1 frame only. In Flash Player 8 smoothing is now based on the smoothing flag setting in the library and is generally enabled for medium, high and best quality mode regardless of how many frames there are. What does the best quality mode do now? Well, there is now a high quality median filter when bitmaps are scaled down. While this is very slow it will allow to create high quality thumbnails from large images directly on the client side. Perfect for applications like flickr.com.

Color banding with smoothing: Flash Player 7 uses an approximation to smooth bitmaps. While this was a sensible thing to do in the Pentium I days, nowadays it will slow down drawing since table lookups need slow memory access. So Flash Player 8 sports a completely new smoothing routine doing a real bilinear interpolation. MMX and AltiVec versions included of course. Try to zoom in and see the glorious quality!

Sub pixel rendering: Along with the new smoothing routines you can now move bitmaps by sub pixels if smoothing is turned on for a particular bitmap. That means the bitmap will correctly move along with the shape instead of the shape being ahead of the bitmap.

Overall there are still a couple of bugs in edges cases left I haven't been able to fix in this release, maybe you can spot them?

27 Comments:

Blogger Mike said...

Do you know if we are finally going to get a regular expression object in the player?

Monday, August 08, 2005 7:54:00 AM  
Blogger bunnyhero said...

wow! great work! i can't wait!

Monday, August 08, 2005 11:03:00 AM  
Blogger tomsamson said...

yeah,awesome,congrats on those achievements!
we´ve had so many workarounds to get around some of the issues you mentioned,thumbs up you fixed so many of those :)

Sunday, August 14, 2005 3:43:00 AM  
Blogger Roger Braunstein said...

incredible, fantastic work!

your posts about new features here are like finding out christmas morning that you got absolutely everything on your list, and more!

you and all the flash 8 developers have earned a teary-eyed standing ovation from this end user.

Monday, August 15, 2005 4:11:00 PM  
Anonymous Alex Lovett said...

Can you now specify the rendering quality on a per object basis?

Say I want an item to be fully anti-aliased on BEST but some other elements in a separate mc to render as LOW.

You say this is a setting in the Library, how can this be set via ActionScript (assuming you can apply per object/mc)

With regards to dynamically loaded images, it is forgoing all anti-aliasing regardless of scene quality setting. Zooming in reveals the images are not being treated in anyway and display big square pixels opposed to blurred/smoothed pixels.

This example exhibits the same behavior when zoomed in:
http://shockwaver.net/swf/fp8/test.html

Im using MAC 8,0,15,0 Viewer

Wednesday, August 31, 2005 5:45:00 PM  
Anonymous Paul Neave said...

Tinic, unfortunately dynamically loaded images cannot have their 'smoothing' property set (unlike library images where you can select an image to 'Allow smoothing') and therefore always appear aliased (pixelated) when scaled or rotated, as mention by Alex above.

This is actually *worse* than Flash Player 7 because at least in FP7 you could set the _quality property for a SWF to "BEST", but this has no effect in FP8.

There needs to be a fix for Flash Player 8 so any dynamically loaded image is automatically smoothed, otherwise this will severely impact the user experience for future picture-viewing applications such as flickr.com. It's such a simple matter to fix - please look into it!

Many thanks.

Monday, September 19, 2005 3:16:00 AM  
Anonymous Alex Lovett said...

I think I may have a workaround, with bitmap data you can effectively duplicate a loaded image to another location ( I'm still annoyed you can't copy/move loaded movieclips with actionscript)

In duplicating the movie clip with bitmap data I think you can set a smoothing tag on the bitmap itself:

some_mc.attachBitmap(bmp, 1, "auto", true);

the true flag sets smoothing where its default is false.

This sort of workaround it necessary also for setting a loaded clips properties before its displayed on stage or has time to influence the properties of its parents. By loading it off stage some place, settings its properties and then duplicating it with bitmap data into the desired location.

A lot of extra leg work there.

Monday, September 19, 2005 6:54:00 AM  
Anonymous badasspuppy said...

I can't believe Macromedia would leave such a flaw in this player. I'm trying to find a solution for this too and beginning to thing I'll have to go back to 7 on the site I'm now buinding. This sucks cause I'm using a couple of the new feats.

Has anyone tried Alex Lovett's approach to solve this? Seems too big of a workaround but if it works...

Friday, October 07, 2005 1:36:00 PM  
Anonymous dan said...

Yes, works beautifully, not difficult either.

do everything normally, except in your onLoadInit() function, do the following: (clip_a is my container for dynamic JPG)

-myBitmap = new BitmapData(clip_a._width, clip_a._height, true, 0x00FFFFFF);
-myBitmap.draw(clip_a);
-removeMovieClip(clip_a);
-createEmptyMovieClip("clip_a", getNextHighestDepth());
-clip_a.attachBitmap(myBitmap, 1, "auto", true);

Saturday, October 15, 2005 9:33:00 PM  
Anonymous dan said...

I would rather see this as an automatic feature, but hey.. this method works.. now i guess we just have to tweak this method to optimize memory use? any thoughts, anybody?

Saturday, October 15, 2005 9:35:00 PM  
Anonymous Nick said...

Tinic, I wonder if you can help with this pretty fundamentral problem I'm having with Flash 8. I use Jpeg's in a slideshow (size can vary from 400x300 to twice this size). As I zoom in on them and pan around, I have been selecting the "best" setting in the HTML under flash 7 and it's been fine (CPU 30% ish). However, when I output to Flash player 8 with the best setting, the CPU jumps to 100% and the movement in the picture is very jerky (probably due to CPU usage). When I publish to Flash 8 under "high" CPU falls to 20% ish, but smoothness of picture is not as good as in Flash 7 under best. So it's something to do with the best setting & Flash 8 conflict. Can you advise me how to be able to achieve the best possible rendering under flash 8 without crippling the CPU?
Thanks
Nick

Monday, October 17, 2005 9:19:00 AM  
Anonymous Ruth Uro said...

Hi there. I came across your site and I noticed your last name Uro!! I too am an Uro, from El Paso, Texas. I was told by my dad we have cousins in california. My grandfather Modesto is from Mexico who has family there. I wonder if we may be distant cousins. Ruth Uro. ruro1@epelectric.com

Wednesday, November 02, 2005 8:03:00 AM  
Anonymous Anonymous said...

My question is why was Flash Player 7.0 release when it was a buggy as hell?

Friday, November 04, 2005 5:07:00 AM  
Anonymous Anonymous said...

I don't know if this was discussed before but.....
On Mac with flash player 8, when I m playing movie with just rotating white and black squares bitmap (smoothing of JPG allowed)....it is not smoothening the edges!!!! When I click (in a flash player) and change the quality of playing to medium and then back to high...it is fine!!
Whatta???

Thursday, November 10, 2005 7:24:00 PM  
Anonymous Anonymous said...

I have enabled subpixelrendering several Flash versions ago by simply scaling the entire flash page to something like 99% in HTML. It fixed a whole bunch of problems.

Good luck, and I hope you can squeeze some more performance out of the mac flash player, although on that front you've done miracles! Thanks!

Wednesday, December 14, 2005 2:21:00 PM  
Anonymous Anonymous said...

Hi,
Finally i found someone who discus about bitmaps in flash. :) I have this problem and several months, no way to solve it. We are developing flash based mapping solution, with dynamic server swf generatig. One part of this is Raster layer generator. It generally take from orthophoto one portion (which is actually visible) , it cut it in smaller peaces, then it make swf with all parts of original immage. Problem is that cut lines are visible in resul visualisation. I found thet problem is antialiasing. If i set quality to LOW cut lines are invisible. But i can't put quality low due to labeling of vector part of map which is drawed over the raster. Any ideas what i can do?

You can see my problem at page:
http://topix.linkomm.net/glocalmap/

to see problem use zoom bar to zoom map for bigger detail

regars Laco

Monday, January 16, 2006 7:09:00 AM  
Anonymous Marky said...

Man, you know what i really really want to see in Flash 8.5 above all else... the ability to load images into a BitmapData from other domains, I know this is a security issue, but this should be allowed whe there is a crossdomain policy file on the other domain. I mean check flickr out. It has a crossdomain.xml on its site but you can't load in any jpgs into BitmapData objects.

Bummer

Monday, April 03, 2006 11:55:00 PM  
Blogger info said...

Im dynamically loading a jpeg into a flash movie and firefox is being odd!

Basically, in a fresh browser window, i upload file and call flash page, pass the jpeg url and it loads.

i try to upload another one, and reload the page, and its not there.

works fine in IE.

i think its a mozilla bug... do you have a work around

Monday, April 02, 2007 9:33:00 AM  
Blogger Bill Ferster said...

Is there any progress on allowing cross-domain bitmap access, so as to enable smoothing in externally loaded bitmaps?

Saturday, August 18, 2007 6:49:00 PM  
Anonymous <a href="http://m1.aol.com/phentermine4">Phentermine</a> said...

Great Article! Thank You!

Tuesday, August 28, 2007 3:08:00 PM  
Anonymous <a href="http://m1.aol.com/phentermine4">Buy Phentermine</a> said...

Thanks to author! I like articles like this, very interesting.

Wednesday, August 29, 2007 2:37:00 AM  
Anonymous <a href="http://free-metro-pcs-ringtones.blogspot.com">Free Ringtones</a> said...

nice blog!

Sunday, September 02, 2007 11:25:00 AM  
Anonymous <a href="http://buy-viagra2007.blogspot.com">buy viagra</a> said...

nice blog!Nice information

Monday, September 03, 2007 2:42:00 PM  
Anonymous <a href="http://buy-levitra--ooz.blogspot.com">Levitra</a> said...

:-) ochen\' zaebatyj blog!

Tuesday, September 04, 2007 2:41:00 AM  
Anonymous <a href="http://buy-soma--ooz.blogspot.com">Buy Soma</a> said...

soglasen s vami ochen\' zaebatyj blog!

Thursday, September 06, 2007 3:08:00 AM  
Anonymous <a href="http://search.cnn.com/search?query=site:cialis-online-2007.blogspot.com?cialis_online.html">Anonymous</a> said...

Keep up the great work. It very impressive. Enjoyed the visit!

Sunday, September 09, 2007 1:46:00 PM  
Blogger Brian said...

Hi... Ive been doing this for some while... but it seems that after Flash Player 9, this doesnt work anymore... Have you similar experiences?

Wednesday, January 30, 2008 4:02:00 AM  

Post a Comment

<< Home