转载:http://hi.baidu.com/dunwin/blog/item/26abd4ca31c9a6f652664feb.html
When looking at the Makeover demo I posted last week one might assume the
rotating wheel animation is a standard animation or gif. This is not the case
although I could have gone with that approach I chose to use a different tool to
achieve this effect.
I built an infinite progress component which displays a
rotating image as an animation, this considerably reduces JAR and heap space
usage for an animation that looks quite similar to the one produced by a static
animation (which we create from GIF). The reason for this is in the way
animations work, animations have no sense of rotation, they store the change to
the image (as lines) and when the image rotates the animation sees the entire
image as changed and produces a "key frame". Key frames are large both in
storage and in memory, to hold a 32x32 pixel animation with 8 keyframes I would
need approximately 32x32x8+1024 (1024 for palette). This might not seem big, but
with increase in resolution the size rises quite a bit...
Rotation is not
always efficient, in fact it can be just as inefficient as a keyframe since it
needs to create a new image. However, LWUIT has a special optimization on MIDP
(this doesn't not apply to LWUIT on CDC) which uses the platforms built in
rotation abilities for square angles (90, 180 & 270) hence removing
completely the overhead of the image. This isn't enough since rotating on square
angles would produce a jumpy effect, which is why I rotate once to 45 degrees
and then rotate 2 images in square angles only thus producing what seems to be 8
images but only paying the cost for 2 images.
Another significant
advantage is that unlike animations I can make full use of translucency since
the alpha channel isn't removed in these images, this allows for flowing
rotation effects.
The rotate method currently makes many assumptions and
is mostly useful for square images, however it works rather nicely for all
angles which is something that currently plain MIDP doesn't support.
public class InfiniteProgressIndicator extends com.sun.lwuit.Label {
private Image[] angles;
private int angle;
public InfiniteProgressIndicator(Image image) {
Image fourtyFiveDeg = image.rotate(45);
angles = new Image[] {image, fourtyFiveDeg, image.rotate(90), fourtyFiveDeg.rotate(90),
image.rotate(180), fourtyFiveDeg.rotate(180), image.rotate(270), fourtyFiveDeg.rotate(270)};
getStyle().setBgTransparency(0);
setIcon(image);
setAlignment(Component.CENTER);
}
public void initComponent() {
getComponentForm().registerAnimated(this);
}
public boolean animate() {
angle++;
setIcon(angles[Math.abs(angle % angles.length)]);
return true;
}
}
分享到:
相关推荐
lambda calculus related problems and about syntax and semantics of infinite lambda terms
Infinite Mixture Models with Nonparametric Bayes and the Dirichlet Process
iscroll-5-pull-to-refresh-and-infinite,可以直接拿来用的下拉刷新,上拉加载
iscroll5-pull-to-refresh-and-infinite-demo可以直接拿来用的上拉加载下拉刷新
In a final chapter the theory of adaptive inference in nonparametric models is developed, including Lepski's method, wavelet thresholding, and adaptive inference for self-similar functions.
infinite_menus 下拉菜单软件infinite_menus 下拉菜单软件
Existence of infinite conservation laws of a variable-coefficient Korteweg-de Vries equation from fluid dynamics and plasma physics via symbolic computation,张春义,李娟,Mapping the method in Refs....
UNIYT3D 2D Infinite Runner Toolkit 仅供学习用,请到商店购买最新版!
Rescuing You in the Infinite Loop(1).apk
1960s, there was the work of Btichi on automata on infinite strings and the second order theory of one successor, then Rabin's 1968 result on automata on infinite trees and the second order theory of ...
infinitescroll的下拉刷新的例子, 本人也是初学,请大家多多指教
Expanded from Tyler Akidau’s popular blog posts "Streaming 101" and "Streaming 102", this book takes you from an introductory level to a nuanced understanding of the what, where, when, and how of ...
在使用Element的InfiniteScroll 无限滚动时候出现以下错误: TypeError: Failed to execute ‘observe’ on ‘MutationObserver’: parameter 1 is not of type ‘Node’ InfiniteScroll的更多用法element官网 ...
Expanded from Tyler Akidau’s popular blog posts "Streaming 101" and "Streaming 102", this book takes you from an introductory level to a nuanced understanding of the what, where, when, and how of ...
An Introduction to Infinite-Dimensional analysis Giuseppe Da Prato
主要介绍了Element InfiniteScroll无限滚动的具体使用方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
UnityVR手势识别插件VR Infinite Gesture1.1.3HTCVIVE
CSS下拉菜单设计专家Visual _Infinite Menus 超级漂亮的下拉菜单 制件方便,做网页不可秒的工具
TE-SCATTERING FROM DENSE HOMOGENEOUS INFINITE DIELECTRIC CYLINDERS OF ARBITRARY CROSS-SECTION
Infinite-Scroll无限滚动加载数据