Revision f26ab2fd
Added by Leszek Koltunski over 9 years ago
| src/main/AndroidManifest.xml | ||
|---|---|---|
| 23 | 23 |
<activity android:name=".listener.ListenerActivity" /> |
| 24 | 24 |
<activity android:name=".dynamic.DynamicActivity" /> |
| 25 | 25 |
<activity android:name=".girl.GirlActivity" /> |
| 26 |
<activity android:name=".macroblock.MacroblockActivity" />
|
|
| 26 |
<activity android:name=".catanddog.CatAndDogActivity" />
|
|
| 27 | 27 |
<activity android:name=".movingeffects.MovingEffectsActivity" /> |
| 28 | 28 |
<activity android:name=".differenteffects.DifferentEffectsActivity" /> |
| 29 | 29 |
<activity android:name=".differentbitmaps.DifferentBitmapsActivity" /> |
| src/main/java/org/distorted/examples/TableOfContents.java | ||
|---|---|---|
| 41 | 41 |
import org.distorted.examples.listener.ListenerActivity; |
| 42 | 42 |
import org.distorted.examples.dynamic.DynamicActivity; |
| 43 | 43 |
import org.distorted.examples.girl.GirlActivity; |
| 44 |
import org.distorted.examples.macroblock.MacroblockActivity;
|
|
| 44 |
import org.distorted.examples.catanddog.CatAndDogActivity;
|
|
| 45 | 45 |
import org.distorted.examples.movingeffects.MovingEffectsActivity; |
| 46 | 46 |
import org.distorted.examples.olimpic.OlimpicActivity; |
| 47 | 47 |
import org.distorted.examples.differenteffects.DifferentEffectsActivity; |
| ... | ... | |
| 158 | 158 |
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_macroblock)); |
| 159 | 159 |
item.put(ITEM_SUBTITLE, getText(R.string.example_macroblock_subtitle)); |
| 160 | 160 |
data.add(item); |
| 161 |
activityMapping.put(i++, MacroblockActivity.class);
|
|
| 161 |
activityMapping.put(i++, CatAndDogActivity.class);
|
|
| 162 | 162 |
} |
| 163 | 163 |
|
| 164 | 164 |
{
|
| src/main/java/org/distorted/examples/catanddog/CatAndDogActivity.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2016 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Distorted. // |
|
| 5 |
// // |
|
| 6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Distorted is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.examples.catanddog; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.Distorted; |
|
| 23 |
|
|
| 24 |
import android.app.Activity; |
|
| 25 |
import android.os.Bundle; |
|
| 26 |
|
|
| 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 28 |
|
|
| 29 |
public class CatAndDogActivity extends Activity |
|
| 30 |
{
|
|
| 31 |
private CatAndDogSurfaceView mView; |
|
| 32 |
|
|
| 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 34 |
|
|
| 35 |
@Override |
|
| 36 |
protected void onCreate(Bundle icicle) |
|
| 37 |
{
|
|
| 38 |
super.onCreate(icicle); |
|
| 39 |
mView = new CatAndDogSurfaceView(this); |
|
| 40 |
setContentView(mView); |
|
| 41 |
} |
|
| 42 |
|
|
| 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 44 |
|
|
| 45 |
@Override |
|
| 46 |
protected void onPause() |
|
| 47 |
{
|
|
| 48 |
mView.onPause(); |
|
| 49 |
super.onPause(); |
|
| 50 |
} |
|
| 51 |
|
|
| 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 53 |
|
|
| 54 |
@Override |
|
| 55 |
protected void onResume() |
|
| 56 |
{
|
|
| 57 |
super.onResume(); |
|
| 58 |
mView.onResume(); |
|
| 59 |
} |
|
| 60 |
|
|
| 61 |
/////////////////////////////////////////////////////////////////// |
|
| 62 |
@Override |
|
| 63 |
public void onDestroy() |
|
| 64 |
{
|
|
| 65 |
Distorted.onDestroy(); |
|
| 66 |
super.onDestroy(); |
|
| 67 |
} |
|
| 68 |
|
|
| 69 |
} |
|
| src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2016 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Distorted. // |
|
| 5 |
// // |
|
| 6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Distorted is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.examples.catanddog; |
|
| 21 |
|
|
| 22 |
import java.io.IOException; |
|
| 23 |
import java.io.InputStream; |
|
| 24 |
|
|
| 25 |
import javax.microedition.khronos.egl.EGLConfig; |
|
| 26 |
import javax.microedition.khronos.opengles.GL10; |
|
| 27 |
|
|
| 28 |
import org.distorted.examples.R; |
|
| 29 |
import org.distorted.library.Distorted; |
|
| 30 |
import org.distorted.library.DistortedBitmap; |
|
| 31 |
import org.distorted.library.EffectTypes; |
|
| 32 |
import org.distorted.library.type.Dynamic1D; |
|
| 33 |
import org.distorted.library.type.Dynamic3D; |
|
| 34 |
import org.distorted.library.type.Static1D; |
|
| 35 |
import org.distorted.library.type.Static3D; |
|
| 36 |
import org.distorted.library.type.Static4D; |
|
| 37 |
|
|
| 38 |
import android.graphics.Bitmap; |
|
| 39 |
import android.graphics.BitmapFactory; |
|
| 40 |
import android.opengl.GLES20; |
|
| 41 |
import android.opengl.GLSurfaceView; |
|
| 42 |
|
|
| 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 44 |
|
|
| 45 |
class CatAndDogRenderer implements GLSurfaceView.Renderer |
|
| 46 |
{
|
|
| 47 |
private GLSurfaceView mView; |
|
| 48 |
private DistortedBitmap catanddog; |
|
| 49 |
private Static4D chromaRegion, alphaRegion; |
|
| 50 |
private int bmpHeight, bmpWidth; |
|
| 51 |
|
|
| 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 53 |
|
|
| 54 |
public CatAndDogRenderer(GLSurfaceView v) |
|
| 55 |
{
|
|
| 56 |
mView = v; |
|
| 57 |
|
|
| 58 |
chromaRegion= new Static4D( 530, 200,100,100); |
|
| 59 |
alphaRegion = new Static4D( 230, 200,100,100); |
|
| 60 |
} |
|
| 61 |
|
|
| 62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 63 |
|
|
| 64 |
public void onDrawFrame(GL10 glUnused) |
|
| 65 |
{
|
|
| 66 |
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
|
| 67 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
|
| 68 |
|
|
| 69 |
catanddog.draw(System.currentTimeMillis()); |
|
| 70 |
} |
|
| 71 |
|
|
| 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 73 |
|
|
| 74 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
|
| 75 |
{
|
|
| 76 |
InputStream is = mView.getContext().getResources().openRawResource(R.raw.cat_and_dog); |
|
| 77 |
Bitmap bitmap; |
|
| 78 |
|
|
| 79 |
try |
|
| 80 |
{
|
|
| 81 |
bitmap = BitmapFactory.decodeStream(is); |
|
| 82 |
} |
|
| 83 |
finally |
|
| 84 |
{
|
|
| 85 |
try |
|
| 86 |
{
|
|
| 87 |
is.close(); |
|
| 88 |
} |
|
| 89 |
catch(IOException e) { }
|
|
| 90 |
} |
|
| 91 |
|
|
| 92 |
bmpHeight = bitmap.getHeight(); |
|
| 93 |
bmpWidth = bitmap.getWidth(); |
|
| 94 |
|
|
| 95 |
catanddog = new DistortedBitmap(bitmap, 30); |
|
| 96 |
|
|
| 97 |
Dynamic1D chromaDyn = new Dynamic1D(3000,0.0f); |
|
| 98 |
chromaDyn.add(new Static1D(1)); |
|
| 99 |
chromaDyn.add(new Static1D(0)); |
|
| 100 |
|
|
| 101 |
catanddog.chroma(chromaDyn, new Static3D(1,0,0), chromaRegion ,true); |
|
| 102 |
|
|
| 103 |
Dynamic1D alphaDyn = new Dynamic1D(3000,0.0f); |
|
| 104 |
alphaDyn.add(new Static1D(1)); |
|
| 105 |
alphaDyn.add(new Static1D(0)); |
|
| 106 |
|
|
| 107 |
catanddog.alpha( alphaDyn, alphaRegion, false ); |
|
| 108 |
|
|
| 109 |
try |
|
| 110 |
{
|
|
| 111 |
Distorted.onSurfaceCreated(mView.getContext()); |
|
| 112 |
} |
|
| 113 |
catch(Exception ex) |
|
| 114 |
{
|
|
| 115 |
android.util.Log.e("Renderer", ex.getMessage() );
|
|
| 116 |
} |
|
| 117 |
} |
|
| 118 |
|
|
| 119 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 120 |
|
|
| 121 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
|
| 122 |
{
|
|
| 123 |
int duration = 10000; |
|
| 124 |
|
|
| 125 |
Dynamic3D diMove = new Dynamic3D(duration,0.0f); |
|
| 126 |
diMove.add(new Static3D(width-bmpWidth,height-bmpHeight,0)); |
|
| 127 |
diMove.add(new Static3D(0,0,0)); |
|
| 128 |
|
|
| 129 |
Dynamic3D diScale = new Dynamic3D(duration,0.0f); |
|
| 130 |
diScale.add(new Static3D(1,1,1)); |
|
| 131 |
diScale.add(new Static3D(0.33f,0.33f,1)); |
|
| 132 |
|
|
| 133 |
Dynamic1D diRotate = new Dynamic1D(duration,0.0f); |
|
| 134 |
diRotate.add(new Static1D( 0)); |
|
| 135 |
diRotate.add(new Static1D(360)); |
|
| 136 |
|
|
| 137 |
catanddog.abortEffects(EffectTypes.MATRIX); |
|
| 138 |
|
|
| 139 |
catanddog.move(diMove); |
|
| 140 |
catanddog.scale(diScale); |
|
| 141 |
catanddog.rotate( diRotate, new Static3D(0,0,1), new Static3D(bmpWidth/2,bmpHeight/2,0) ); |
|
| 142 |
|
|
| 143 |
Distorted.onSurfaceChanged(width, height); |
|
| 144 |
} |
|
| 145 |
} |
|
| src/main/java/org/distorted/examples/catanddog/CatAndDogSurfaceView.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2016 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Distorted. // |
|
| 5 |
// // |
|
| 6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Distorted is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.examples.catanddog; |
|
| 21 |
|
|
| 22 |
import android.content.Context; |
|
| 23 |
import android.opengl.GLSurfaceView; |
|
| 24 |
import android.os.Build; |
|
| 25 |
|
|
| 26 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 27 |
|
|
| 28 |
class CatAndDogSurfaceView extends GLSurfaceView |
|
| 29 |
{
|
|
| 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 31 |
|
|
| 32 |
public CatAndDogSurfaceView(Context context) |
|
| 33 |
{
|
|
| 34 |
super(context); |
|
| 35 |
setEGLContextClientVersion(2); |
|
| 36 |
|
|
| 37 |
if( Build.FINGERPRINT.startsWith("generic") )
|
|
| 38 |
{
|
|
| 39 |
setEGLConfigChooser(8, 8, 8, 8, 16, 0); |
|
| 40 |
} |
|
| 41 |
|
|
| 42 |
setRenderer(new CatAndDogRenderer(this)); |
|
| 43 |
} |
|
| 44 |
} |
|
| 45 |
|
|
| src/main/java/org/distorted/examples/macroblock/MacroblockActivity.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2016 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Distorted. // |
|
| 5 |
// // |
|
| 6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Distorted is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.examples.macroblock; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.Distorted; |
|
| 23 |
|
|
| 24 |
import android.app.Activity; |
|
| 25 |
import android.os.Bundle; |
|
| 26 |
|
|
| 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 28 |
|
|
| 29 |
public class MacroblockActivity extends Activity |
|
| 30 |
{
|
|
| 31 |
private MacroblockSurfaceView mView; |
|
| 32 |
|
|
| 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 34 |
|
|
| 35 |
@Override |
|
| 36 |
protected void onCreate(Bundle icicle) |
|
| 37 |
{
|
|
| 38 |
super.onCreate(icicle); |
|
| 39 |
mView = new MacroblockSurfaceView(this); |
|
| 40 |
setContentView(mView); |
|
| 41 |
} |
|
| 42 |
|
|
| 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 44 |
|
|
| 45 |
@Override |
|
| 46 |
protected void onPause() |
|
| 47 |
{
|
|
| 48 |
mView.onPause(); |
|
| 49 |
super.onPause(); |
|
| 50 |
} |
|
| 51 |
|
|
| 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 53 |
|
|
| 54 |
@Override |
|
| 55 |
protected void onResume() |
|
| 56 |
{
|
|
| 57 |
super.onResume(); |
|
| 58 |
mView.onResume(); |
|
| 59 |
} |
|
| 60 |
|
|
| 61 |
/////////////////////////////////////////////////////////////////// |
|
| 62 |
@Override |
|
| 63 |
public void onDestroy() |
|
| 64 |
{
|
|
| 65 |
Distorted.onDestroy(); |
|
| 66 |
super.onDestroy(); |
|
| 67 |
} |
|
| 68 |
|
|
| 69 |
} |
|
| src/main/java/org/distorted/examples/macroblock/MacroblockRenderer.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2016 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Distorted. // |
|
| 5 |
// // |
|
| 6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Distorted is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.examples.macroblock; |
|
| 21 |
|
|
| 22 |
import java.io.IOException; |
|
| 23 |
import java.io.InputStream; |
|
| 24 |
|
|
| 25 |
import javax.microedition.khronos.egl.EGLConfig; |
|
| 26 |
import javax.microedition.khronos.opengles.GL10; |
|
| 27 |
|
|
| 28 |
import org.distorted.examples.R; |
|
| 29 |
import org.distorted.library.Distorted; |
|
| 30 |
import org.distorted.library.DistortedBitmap; |
|
| 31 |
import org.distorted.library.EffectTypes; |
|
| 32 |
import org.distorted.library.type.Dynamic1D; |
|
| 33 |
import org.distorted.library.type.Dynamic3D; |
|
| 34 |
import org.distorted.library.type.Static1D; |
|
| 35 |
import org.distorted.library.type.Static3D; |
|
| 36 |
import org.distorted.library.type.Static4D; |
|
| 37 |
|
|
| 38 |
import android.graphics.Bitmap; |
|
| 39 |
import android.graphics.BitmapFactory; |
|
| 40 |
import android.opengl.GLES20; |
|
| 41 |
import android.opengl.GLSurfaceView; |
|
| 42 |
|
|
| 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 44 |
|
|
| 45 |
class MacroblockRenderer implements GLSurfaceView.Renderer |
|
| 46 |
{
|
|
| 47 |
private GLSurfaceView mView; |
|
| 48 |
private DistortedBitmap macroblock; |
|
| 49 |
private Static4D macRegion, alphaRegion; |
|
| 50 |
private int bmpHeight, bmpWidth; |
|
| 51 |
|
|
| 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 53 |
|
|
| 54 |
public MacroblockRenderer(GLSurfaceView v) |
|
| 55 |
{
|
|
| 56 |
mView = v; |
|
| 57 |
|
|
| 58 |
macRegion = new Static4D( 530, 200,100,100); |
|
| 59 |
alphaRegion = new Static4D( 230, 200,100,100); |
|
| 60 |
} |
|
| 61 |
|
|
| 62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 63 |
|
|
| 64 |
public void onDrawFrame(GL10 glUnused) |
|
| 65 |
{
|
|
| 66 |
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
|
| 67 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
|
| 68 |
|
|
| 69 |
macroblock.draw(System.currentTimeMillis()); |
|
| 70 |
} |
|
| 71 |
|
|
| 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 73 |
|
|
| 74 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
|
| 75 |
{
|
|
| 76 |
InputStream is = mView.getContext().getResources().openRawResource(R.raw.cat_and_dog); |
|
| 77 |
Bitmap bitmap; |
|
| 78 |
|
|
| 79 |
try |
|
| 80 |
{
|
|
| 81 |
bitmap = BitmapFactory.decodeStream(is); |
|
| 82 |
} |
|
| 83 |
finally |
|
| 84 |
{
|
|
| 85 |
try |
|
| 86 |
{
|
|
| 87 |
is.close(); |
|
| 88 |
} |
|
| 89 |
catch(IOException e) { }
|
|
| 90 |
} |
|
| 91 |
|
|
| 92 |
bmpHeight = bitmap.getHeight(); |
|
| 93 |
bmpWidth = bitmap.getWidth(); |
|
| 94 |
|
|
| 95 |
macroblock = new DistortedBitmap(bitmap, 30); |
|
| 96 |
|
|
| 97 |
Dynamic1D macroblockDyn = new Dynamic1D(3000,0.0f); |
|
| 98 |
macroblockDyn.add(new Static1D( 1)); |
|
| 99 |
macroblockDyn.add(new Static1D(30)); |
|
| 100 |
|
|
| 101 |
macroblock.macroblock(macroblockDyn, macRegion); |
|
| 102 |
|
|
| 103 |
Dynamic1D alphaDyn = new Dynamic1D(3000,0.0f); |
|
| 104 |
alphaDyn.add(new Static1D(1)); |
|
| 105 |
alphaDyn.add(new Static1D(0)); |
|
| 106 |
|
|
| 107 |
macroblock.alpha( alphaDyn, alphaRegion, false ); |
|
| 108 |
|
|
| 109 |
try |
|
| 110 |
{
|
|
| 111 |
Distorted.onSurfaceCreated(mView.getContext()); |
|
| 112 |
} |
|
| 113 |
catch(Exception ex) |
|
| 114 |
{
|
|
| 115 |
android.util.Log.e("Renderer", ex.getMessage() );
|
|
| 116 |
} |
|
| 117 |
} |
|
| 118 |
|
|
| 119 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 120 |
|
|
| 121 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
|
| 122 |
{
|
|
| 123 |
int duration = 10000; |
|
| 124 |
|
|
| 125 |
Dynamic3D diMove = new Dynamic3D(duration,0.0f); |
|
| 126 |
diMove.add(new Static3D(width-bmpWidth,height-bmpHeight,0)); |
|
| 127 |
diMove.add(new Static3D(0,0,0)); |
|
| 128 |
|
|
| 129 |
Dynamic3D diScale = new Dynamic3D(duration,0.0f); |
|
| 130 |
diScale.add(new Static3D(1,1,1)); |
|
| 131 |
diScale.add(new Static3D(0.33f,0.33f,1)); |
|
| 132 |
|
|
| 133 |
Dynamic1D diRotate = new Dynamic1D(duration,0.0f); |
|
| 134 |
diRotate.add(new Static1D( 0)); |
|
| 135 |
diRotate.add(new Static1D(360)); |
|
| 136 |
|
|
| 137 |
macroblock.abortEffects(EffectTypes.MATRIX); |
|
| 138 |
|
|
| 139 |
macroblock.move(diMove); |
|
| 140 |
macroblock.scale(diScale); |
|
| 141 |
macroblock.rotate( diRotate, new Static3D(0,0,1), new Static3D(bmpWidth/2,bmpHeight/2,0) ); |
|
| 142 |
|
|
| 143 |
Distorted.onSurfaceChanged(width, height); |
|
| 144 |
} |
|
| 145 |
} |
|
| src/main/java/org/distorted/examples/macroblock/MacroblockSurfaceView.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2016 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Distorted. // |
|
| 5 |
// // |
|
| 6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Distorted is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.examples.macroblock; |
|
| 21 |
|
|
| 22 |
import android.content.Context; |
|
| 23 |
import android.opengl.GLSurfaceView; |
|
| 24 |
import android.os.Build; |
|
| 25 |
|
|
| 26 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 27 |
|
|
| 28 |
class MacroblockSurfaceView extends GLSurfaceView |
|
| 29 |
{
|
|
| 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 31 |
|
|
| 32 |
public MacroblockSurfaceView(Context context) |
|
| 33 |
{
|
|
| 34 |
super(context); |
|
| 35 |
setEGLContextClientVersion(2); |
|
| 36 |
|
|
| 37 |
if( Build.FINGERPRINT.startsWith("generic") )
|
|
| 38 |
{
|
|
| 39 |
setEGLConfigChooser(8, 8, 8, 8, 16, 0); |
|
| 40 |
} |
|
| 41 |
|
|
| 42 |
setRenderer(new MacroblockRenderer(this)); |
|
| 43 |
} |
|
| 44 |
} |
|
| 45 |
|
|
| src/main/res/values/strings.xml | ||
|---|---|---|
| 72 | 72 |
<string name="example_girl">Girl</string> |
| 73 | 73 |
<string name="example_girl_subtitle">Distort, Sink and Swirl effects all in one.</string> |
| 74 | 74 |
<string name="example_macroblock">Cat and Dog</string> |
| 75 |
<string name="example_macroblock_subtitle">Macroblock, Transparency and Rotation effects.</string>
|
|
| 75 |
<string name="example_macroblock_subtitle">Chroma, Transparency and Rotation effects.</string>
|
|
| 76 | 76 |
<string name="example_movingeffects">Moving Effects</string> |
| 77 | 77 |
<string name="example_movingeffects_subtitle">Use the Interpolator to move effects around.</string> |
| 78 | 78 |
<string name="example_differenteffects">Different Effects</string> |
Also available in: Unified diff
Fix the 'Macroblock' app.