Revision 13a5c5cd
Added by Leszek Koltunski about 8 years ago
src/main/java/org/distorted/examples/save/SaveActivity.java | ||
---|---|---|
26 | 26 |
import android.opengl.GLSurfaceView; |
27 | 27 |
import android.os.Bundle; |
28 | 28 |
import android.view.View; |
29 |
import android.widget.Button; |
|
30 | 29 |
import android.widget.SeekBar; |
31 | 30 |
|
32 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
33 | 32 |
|
34 | 33 |
public class SaveActivity extends Activity implements SeekBar.OnSeekBarChangeListener |
35 | 34 |
{ |
36 |
private Button mSave; |
|
37 |
private SeekBar barSize; |
|
38 |
|
|
39 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
40 | 36 |
|
41 | 37 |
@Override |
... | ... | |
44 | 40 |
super.onCreate(icicle); |
45 | 41 |
|
46 | 42 |
setContentView(R.layout.savelayout); |
47 |
|
|
48 |
mSave = (Button)findViewById(R.id.saveButton); |
|
49 | 43 |
|
50 |
barSize = (SeekBar)findViewById(R.id.saveSeekBar); |
|
44 |
SeekBar barSize = (SeekBar)findViewById(R.id.saveSeekBar);
|
|
51 | 45 |
barSize.setOnSeekBarChangeListener(this); |
52 | 46 |
barSize.setProgress(50); |
53 | 47 |
} |
... | ... | |
57 | 51 |
@Override |
58 | 52 |
protected void onPause() |
59 | 53 |
{ |
60 |
SaveRenderer.stopThread();
|
|
54 |
SaveWorkerThread.stopSending();
|
|
61 | 55 |
|
62 |
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.saveSurfaceView);
|
|
63 |
mView.onPause();
|
|
56 |
GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.saveSurfaceView);
|
|
57 |
view.onPause();
|
|
64 | 58 |
|
65 | 59 |
super.onPause(); |
66 | 60 |
} |
... | ... | |
72 | 66 |
{ |
73 | 67 |
super.onResume(); |
74 | 68 |
|
75 |
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.saveSurfaceView);
|
|
76 |
mView.onResume();
|
|
69 |
GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.saveSurfaceView);
|
|
70 |
view.onResume();
|
|
77 | 71 |
|
78 |
SaveRenderer.startThread(this);
|
|
72 |
SaveWorkerThread.startSending(this);
|
|
79 | 73 |
} |
80 | 74 |
|
81 | 75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
91 | 85 |
|
92 | 86 |
public void Save(View v) |
93 | 87 |
{ |
94 |
SaveRenderer.Save(); |
|
88 |
SaveSurfaceView view = (SaveSurfaceView) this.findViewById(R.id.saveSurfaceView); |
|
89 |
view.getRenderer().Save(); |
|
95 | 90 |
} |
96 | 91 |
|
97 | 92 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
99 | 94 |
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) |
100 | 95 |
{ |
101 | 96 |
float s = (progress>50 ? ((progress-50)/16.0f + 1.0f):(0.015f*progress + 0.25f)); |
102 |
SaveRenderer.setSize(s); |
|
97 |
SaveSurfaceView view = (SaveSurfaceView) this.findViewById(R.id.saveSurfaceView); |
|
98 |
view.getRenderer().setSize(s); |
|
103 | 99 |
} |
104 | 100 |
|
105 | 101 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/save/SaveRenderer.java | ||
---|---|---|
39 | 39 |
import org.distorted.library.type.Static3D; |
40 | 40 |
import org.distorted.library.type.Static4D; |
41 | 41 |
|
42 |
import android.app.Activity; |
|
43 | 42 |
import android.graphics.Bitmap; |
44 | 43 |
import android.graphics.BitmapFactory; |
45 | 44 |
import android.opengl.GLES20; |
... | ... | |
51 | 50 |
class SaveRenderer implements GLSurfaceView.Renderer |
52 | 51 |
{ |
53 | 52 |
private GLSurfaceView mView; |
54 |
private static DistortedBitmap mGirl;
|
|
53 |
private DistortedBitmap mGirl; |
|
55 | 54 |
private Static2D pLeft, pRight; |
56 | 55 |
private Static4D sinkRegion; |
57 |
private static Dynamic1D diSink;
|
|
58 |
private static Static1D s0;
|
|
56 |
private Dynamic1D diSink; |
|
57 |
private Static1D s0; |
|
59 | 58 |
|
60 | 59 |
private int bmpHeight, bmpWidth; |
61 |
private static int scrHeight, scrWidth; |
|
62 |
private static float boobsSink; |
|
63 |
private static boolean isSaving = false; |
|
64 |
private static String mPath; |
|
65 |
|
|
66 |
private static SaveWorkerThread mWorkerThread =null; |
|
60 |
private int scrHeight, scrWidth; |
|
61 |
private float boobsSink; |
|
62 |
private boolean isSaving = false; |
|
63 |
private String mPath; |
|
67 | 64 |
|
68 | 65 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
69 | 66 |
|
70 |
public SaveRenderer(GLSurfaceView v)
|
|
67 |
SaveRenderer(GLSurfaceView v) |
|
71 | 68 |
{ |
72 | 69 |
mView = v; |
73 | 70 |
|
... | ... | |
86 | 83 |
|
87 | 84 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
88 | 85 |
|
89 |
public static void startThread(Activity act) |
|
90 |
{ |
|
91 |
if( mWorkerThread ==null ) mWorkerThread = new SaveWorkerThread(); |
|
92 |
|
|
93 |
mWorkerThread.startSending(act); |
|
94 |
} |
|
95 |
|
|
96 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
97 |
|
|
98 |
public static void stopThread() |
|
99 |
{ |
|
100 |
mWorkerThread.stopSending(); |
|
101 |
mWorkerThread = null; |
|
102 |
} |
|
103 |
|
|
104 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
105 |
|
|
106 |
public static void setSize(float s) |
|
86 |
void setSize(float s) |
|
107 | 87 |
{ |
108 | 88 |
boobsSink = s; |
109 | 89 |
s0.set(boobsSink); |
... | ... | |
111 | 91 |
|
112 | 92 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
113 | 93 |
|
114 |
public static void Save()
|
|
94 |
void Save() |
|
115 | 95 |
{ |
116 | 96 |
if( isSaving==false ) |
117 | 97 |
{ |
... | ... | |
147 | 127 |
buf.order(ByteOrder.LITTLE_ENDIAN); |
148 | 128 |
GLES20.glReadPixels( 0, 0, scrWidth, scrHeight , GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, buf); |
149 | 129 |
|
150 |
mWorkerThread.newBuffer(buf,scrWidth,scrHeight,mPath);
|
|
130 |
SaveWorkerThread.newBuffer(buf,scrWidth,scrHeight,mPath);
|
|
151 | 131 |
|
152 | 132 |
isSaving = false; |
153 | 133 |
} |
src/main/java/org/distorted/examples/save/SaveSurfaceView.java | ||
---|---|---|
28 | 28 |
|
29 | 29 |
class SaveSurfaceView extends GLSurfaceView |
30 | 30 |
{ |
31 |
private SaveRenderer mRenderer; |
|
32 |
|
|
33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
34 |
|
|
31 | 35 |
public SaveSurfaceView(Context c, AttributeSet attrs) |
32 | 36 |
{ |
33 | 37 |
super(c, attrs); |
... | ... | |
38 | 42 |
{ |
39 | 43 |
setEGLConfigChooser(8, 8, 8, 8, 16, 0); |
40 | 44 |
} |
41 |
|
|
42 |
setRenderer(new SaveRenderer(this)); |
|
45 |
|
|
46 |
mRenderer = new SaveRenderer(this); |
|
47 |
|
|
48 |
setRenderer(mRenderer); |
|
49 |
} |
|
50 |
|
|
51 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
52 |
|
|
53 |
SaveRenderer getRenderer() |
|
54 |
{ |
|
55 |
return mRenderer; |
|
43 | 56 |
} |
44 | 57 |
} |
45 | 58 |
|
src/main/java/org/distorted/examples/save/SaveWorkerThread.java | ||
---|---|---|
33 | 33 |
import java.nio.ByteBuffer; |
34 | 34 |
import java.util.Vector; |
35 | 35 |
|
36 |
public class SaveWorkerThread extends Thread
|
|
36 |
class SaveWorkerThread extends Thread |
|
37 | 37 |
{ |
38 | 38 |
private static Vector<WorkLoad> mBuffers; |
39 | 39 |
private static SaveWorkerThread mThis=null; |
Also available in: Unified diff
Tidy up 'Save'