Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create dynamic user face model in android?

Hello I want to create the dynamic user face model in android and display to the user.

I have searched and found that I need user different angles face frames (Images) like 14 to 16 images and for displaying purpose need to change images (frame) using opengl (for smoothness) on user finger swipe so it look like 3D Image.
But I want like some editing like(wear earing) in each frame and display to the user as like https://lh3.googleusercontent.com/WLu3hm0nIhW5Ps9GeMS9PZiuc3n2B8xySKs1LfNTU1drOIqJ-iEvdiz-7Ww0ZX3ZtLk=h900

Please give me some suggestion or example on it.

like image 725
Hits Avatar asked Dec 22 '15 10:12

Hits


1 Answers

I expect that your images fit in the memory.
You can add ImageView for every image to a FrameLayout and let just one ImageView be visible. Then you can even use fade in / fade out animation to improve the effect when switching to next image.

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));

anim/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>

anim/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>

About hardware acceleration, I think in this case Android can handle it for you. From Android 3.0 you can define it in the manifest for application or activity:

android:hardwareAccelerated="true"

Alternatively you can set it just for specific views.

Using XML:

android:layerType="hardware"

Using Java:

view.setLayerType(View.LAYER_TYPE_HARDWARE, null);

Here you can find more information about Hardware Acceleration

like image 198
Milos Fec Avatar answered Nov 04 '22 14:11

Milos Fec