本文整理了Java中android.graphics.Movie
类的一些代码示例,展示了Movie
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Movie
类的具体详情如下:
包路径:android.graphics.Movie
类名称:Movie
暂无
代码示例来源:origin: Rajawali/Rajawali
public void update() throws TextureException
{
if(mMovie == null || mMovie.duration() == 0) return;
long now = SystemClock.uptimeMillis();
int relTime = (int)((now - mStartTime) % mMovie.duration());
mMovie.setTime(relTime);
mGIFBitmap.eraseColor(Color.TRANSPARENT);
mMovie.draw(mCanvas, 0, 0);
mBitmap = Bitmap.createScaledBitmap(mGIFBitmap, mTextureSize, mTextureSize, false);
TextureManager.getInstance().replaceTexture(this);
replace();
}
代码示例来源:origin: Rajawali/Rajawali
private void loadGIF() {
Context context = TextureManager.getInstance().getContext();
mMovie = Movie.decodeStream(context.getResources().openRawResource(mResourceId));
mWidth = mMovie.width();
mHeight = mMovie.height();
mGIFBitmap = Bitmap.createBitmap(mWidth, mHeight, Config.ARGB_8888);
mCanvas = new Canvas(mGIFBitmap);
mMovie.draw(mCanvas, 0, 0);
mBitmap = Bitmap.createScaledBitmap(mGIFBitmap, mTextureSize, mTextureSize, false);
}
代码示例来源:origin: Cutta/GifView
/**
* Draw current GIF frame
*/
private void drawMovieFrame(Canvas canvas) {
movie.setTime(mCurrentAnimationTime);
canvas.save(Canvas.MATRIX_SAVE_FLAG);
canvas.scale(mScale, mScale);
movie.draw(canvas, mLeft / mScale, mTop / mScale);
canvas.restore();
}
代码示例来源:origin: qiubiteme/android_api_demos
@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(0xFFCCCCCC);
Paint p = new Paint();
p.setAntiAlias(true);
canvas.drawBitmap(mBitmap, 10, 10, null);
canvas.drawBitmap(mBitmap2, 10, 170, null);
canvas.drawBitmap(mBitmap3, 110, 170, null);
canvas.drawBitmap(mBitmap4, 210, 170, null);
mDrawable.draw(canvas);
long now = android.os.SystemClock.uptimeMillis();
if (mMovieStart == 0) { // first time
mMovieStart = now;
}
if (mMovie != null) {
int dur = mMovie.duration();
if (dur == 0) {
dur = 1000;
}
int relTime = (int)((now - mMovieStart) % dur);
mMovie.setTime(relTime);
mMovie.draw(canvas, getWidth() - mMovie.width(),
getHeight() - mMovie.height());
invalidate();
}
}
}
代码示例来源:origin: huxq17/XRefreshView
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (mMovie != null) {
int movieWidth = mMovie.width();
int movieHeight = mMovie.height();
int maximumWidth = MeasureSpec.getSize(widthMeasureSpec);
float scaleW = (float) movieWidth / (float) maximumWidth;
mScale = 1f / scaleW;
mMeasuredMovieWidth = maximumWidth;
mMeasuredMovieHeight = (int) (movieHeight * mScale);
setMeasuredDimension(mMeasuredMovieWidth, mMeasuredMovieHeight);
} else {
setMeasuredDimension(getSuggestedMinimumWidth(), getSuggestedMinimumHeight());
}
}
代码示例来源:origin: andforce/iBeebo
mMovie = Movie.decodeByteArray(array, 0, array.length);
bRet = true;
} catch (FileNotFoundException e) {
mMovieDuration = mMovie.duration();
mGifw = mMovie.width();
mGifh = mMovie.height();
代码示例来源:origin: cxMax/FloatingView
movie = Movie.decodeStream(is);//gif小电影
if (movie == null) {
throw new IllegalArgumentException("Illegal gif file");
if (movie.width() <= 0 || movie.height() <= 0) {
return;
bitmap = null;
bitmap = Bitmap.createBitmap(movie.width(), movie.height(), Bitmap.Config.RGB_565);
canvas = new Canvas(bitmap);
handler.post(runnable);
代码示例来源:origin: square/assertj-android
public MovieAssert hasDuration(int duration) {
isNotNull();
int actualDuration = actual.duration();
assertThat(actualDuration) //
.overridingErrorMessage("Expected duration <%s> but was <%s>.", duration, actualDuration) //
.isEqualTo(duration);
return this;
}
代码示例来源:origin: huxq17/XRefreshView
@SuppressLint("NewApi")
private void setViewAttributes(Context context, AttributeSet attrs, int defStyle) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
// 从描述文件中读出gif的值,创建出Movie实例
final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.GifView, defStyle,
R.style.Widget_GifView);
mMovieResourceId = array.getResourceId(R.styleable.GifView_gif, -1);
mPaused = array.getBoolean(R.styleable.GifView_paused, false);
array.recycle();
if (mMovieResourceId != -1) {
mMovie = Movie.decodeStream(getResources().openRawResource(mMovieResourceId));
}
}
代码示例来源:origin: pili-engineering/PLDroidShortVideo
private PLComposeItem createGIFImageItem(String path) {
PLComposeItem item = new PLComposeItem(path);
item.setItemType(PLComposeItem.ItemType.GIF);
FileInputStream fileInputStream;
try {
fileInputStream = new FileInputStream(item.getFilePath());
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
}
Movie movie = Movie.decodeStream(fileInputStream);
item.setDurationMs(movie.duration());
long transitionTimeMs = movie.duration() / 2;
transitionTimeMs = transitionTimeMs > 1000 ? 1000 : transitionTimeMs;
item.setTransitionTimeMs(transitionTimeMs);
return item;
}
代码示例来源:origin: brarcher/video-transcoder
private static MediaInfo mediaInfoFixup(MediaInfo info)
{
if(info.container != null && info.container == MediaContainer.GIF)
{
// ffprobe will not report the duration of GIF files. The duration will
// need to be determined another way
Movie gifMovie = Movie.decodeFile(info.file.getAbsolutePath());
int durationMs = gifMovie.duration();
info = new MediaInfo(info.file, durationMs, info.container, info.videoCodec, info.videoResolution,
info.videoBitrateK, info.videoFramerate, info.audioCodec, info.audioSampleRate, info.audioBitrateK, info.audioChannels);
}
return info;
}
代码示例来源:origin: square/assertj-android
public MovieAssert hasWidth(int width) {
isNotNull();
int actualHeight = actual.width();
assertThat(actualHeight) //
.overridingErrorMessage("Expected width <%s> but was <%s>.", width, actualHeight) //
.isEqualTo(width);
return this;
}
}
代码示例来源:origin: square/assertj-android
public MovieAssert hasHeight(int height) {
isNotNull();
int actualHeight = actual.height();
assertThat(actualHeight) //
.overridingErrorMessage("Expected height <%s> but was <%s>.", height, actualHeight) //
.isEqualTo(height);
return this;
}
代码示例来源:origin: renjianan/GifView
public void setPercent(float percent) {
if (movie != null && movieDuration > 0) {
this.percent = percent;
movie.setTime((int) (movieDuration * percent));
invalidateView();
if (mOnPlayListener != null) {
mOnPlayListener.onPlaying(percent);
}
}
}
代码示例来源:origin: renjianan/GifView
/**
* 画出gif帧
*/
private void drawMovieFrame(Canvas canvas) {
canvas.save();
canvas.scale(1 / mScale, 1 / mScale);
movie.draw(canvas, 0.0f, 0.0f);
canvas.restore();
}
代码示例来源:origin: THEONE10211024/ApiDemos
@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(0xFFCCCCCC);
Paint p = new Paint();
p.setAntiAlias(true);
canvas.drawBitmap(mBitmap, 10, 10, null);
canvas.drawBitmap(mBitmap2, 10, 170, null);
canvas.drawBitmap(mBitmap3, 110, 170, null);
canvas.drawBitmap(mBitmap4, 210, 170, null);
mDrawable.draw(canvas);
long now = android.os.SystemClock.uptimeMillis();
if (mMovieStart == 0) { // first time
mMovieStart = now;
}
if (mMovie != null) {
int dur = mMovie.duration();
if (dur == 0) {
dur = 1000;
}
int relTime = (int)((now - mMovieStart) % dur);
mMovie.setTime(relTime);
mMovie.draw(canvas, getWidth() - mMovie.width(),
getHeight() - mMovie.height());
invalidate();
}
}
}
代码示例来源:origin: Cutta/GifView
int movieWidth = movie.width();
int movieHeight = movie.height();
代码示例来源:origin: huxq17/XRefreshView
private void drawMovieFrame(Canvas canvas) {
// 设置要显示的帧,绘制即可
mMovie.setTime(mCurrentAnimationTime);
canvas.save(Canvas.MATRIX_SAVE_FLAG);
canvas.scale(mScale, mScale);
mMovie.draw(canvas, mLeft / mScale, mTop / mScale);
canvas.restore();
}
代码示例来源:origin: andforce/iBeebo
mMovie = Movie.decodeByteArray(array, 0, array.length);
bRet = true;
} catch (FileNotFoundException e) {
mMovieDuration = mMovie.duration();
mGifw = mMovie.width();
mGifh = mMovie.height();
代码示例来源:origin: JackWHLiu/jackknife
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int width = 0;
int height = 0;
try {
InputStream inputStream = getContext().getAssets().open(path);
mMovie = Movie.decodeStream(inputStream);
width = mMovie.width();
height = mMovie.height();
mHandler.post(r);
} catch(IOException e) {
e.printStackTrace();
}
setMeasuredDimension((int)(width*zoom),(int)(height*zoom));
}
内容来源于网络,如有侵权,请联系作者删除!