Hit*_*its 16 android opengl-es image-processing
您好我想在android中创建动态用户面部模型并显示给用户.
我搜索并发现我需要用户不同角度的面部框架(图像),如14到16个图像,并且为了显示目的,需要使用opengl(用于平滑度)在用户手指滑动上更改图像(框架),使其看起来像3D图像.
但是我希望像每个框架中的一些编辑(佩戴耳朵)并向用户显示,如
https://lh3.googleusercontent.com/WLu3hm0nIhW5Ps9GeMS9PZiuc3n2B8xySKs1LfNTU1drOIqJ-iEvdiz-7Ww0ZX3ZtLk=h900
请给我一些建议或示例.
我希望你的图像能够融入记忆。
您可以将每张图像的 ImageView 添加到 FrameLayout 中,并只让一个 ImageView 可见。然后,您甚至可以使用淡入/淡出动画来改善切换到下一张图像时的效果。
ImageView[] imageViews;
int currentView = 0;
...
// fill imageViews
...
ImageView image1 = imageViews[currentView];
if (moveRight) {
if (++currentView >= imageViews.length) currentView = 0;
} else {
if (--currentView < 0) currentView = imageViews.length - 1;
}
ImageView image2 = imageViews[currentView];
image1.setVisibility(View.INVISIBLE);
image1.startAnimation(AnimationUtils.loadAnimation(context, R.anim.fade_out));
image2.setVisibility(View.VISIBLE);
image2.startAnimation(AnimationUtils.loadAnimation(context, R.anim.fade_in));
Run Code Online (Sandbox Code Playgroud)
动画/fade_in.xml
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<alpha
android:duration="150"
android:fromAlpha="0.0"
android:toAlpha="1.0"/>
</set>
Run Code Online (Sandbox Code Playgroud)
动画/fade_out.xml
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<alpha
android:duration="150"
android:fromAlpha="1.0"
android:toAlpha="0.0"/>
</set>
Run Code Online (Sandbox Code Playgroud)
关于硬件加速,我认为在这种情况下Android可以为你处理。从 Android 3.0 开始,您可以在应用程序或活动的清单中定义它:
android:hardwareAccelerated="true"
Run Code Online (Sandbox Code Playgroud)
或者,您可以仅针对特定视图进行设置。
使用 XML:
android:layerType="hardware"
Run Code Online (Sandbox Code Playgroud)
使用Java:
view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
Run Code Online (Sandbox Code Playgroud)
在这里您可以找到有关硬件加速的更多信息