2 |
2 |
|
3 |
3 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
4 |
4 |
|
|
5 |
import android.graphics.Bitmap;
|
|
6 |
import android.opengl.GLES20;
|
|
7 |
|
|
8 |
import java.io.BufferedOutputStream;
|
|
9 |
import java.io.FileOutputStream;
|
|
10 |
import java.io.IOException;
|
|
11 |
import java.nio.ByteBuffer;
|
|
12 |
import java.nio.ByteOrder;
|
|
13 |
|
5 |
14 |
class EffectQueueOther extends EffectQueue
|
6 |
15 |
{
|
7 |
16 |
private static final int NUM_UNIFORMS = 0;
|
... | ... | |
28 |
37 |
}
|
29 |
38 |
|
30 |
39 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
40 |
// runs on the graphics thread
|
31 |
41 |
|
32 |
42 |
synchronized void send()
|
33 |
43 |
{
|
... | ... | |
35 |
45 |
{
|
36 |
46 |
if (mType[i] == EffectNames.SAVE_PNG.ordinal() )
|
37 |
47 |
{
|
38 |
|
// TODO: Implement SAVE_PNG HERE
|
|
48 |
ByteBuffer buf = ByteBuffer.allocateDirect( (int)(mObjHalfX * mObjHalfY * 16) );
|
|
49 |
buf.order(ByteOrder.LITTLE_ENDIAN);
|
|
50 |
GLES20.glReadPixels(0, 0, (int)(2*mObjHalfX), (int)(2*mObjHalfY) , GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, buf);
|
|
51 |
|
|
52 |
buf.rewind();
|
|
53 |
|
|
54 |
BufferedOutputStream bos = null;
|
|
55 |
|
|
56 |
try
|
|
57 |
{
|
|
58 |
bos = new BufferedOutputStream(new FileOutputStream(mFilename[i]));
|
|
59 |
Bitmap bmp = Bitmap.createBitmap( (int)(2*mObjHalfX), (int)(2*mObjHalfY), Bitmap.Config.ARGB_8888);
|
|
60 |
bmp.copyPixelsFromBuffer(buf);
|
|
61 |
bmp.compress(Bitmap.CompressFormat.PNG, 90, bos);
|
|
62 |
bmp.recycle();
|
|
63 |
|
|
64 |
for(int j=0; j<mNumListeners; j++)
|
|
65 |
EffectMessageSender.newMessage( mListeners.elementAt(j),
|
|
66 |
EffectMessage.EFFECT_FINISHED,
|
|
67 |
(mID[i]<<EffectTypes.LENGTH)+EffectTypes.OTHER.type,
|
|
68 |
mType[i],
|
|
69 |
mBitmapID);
|
|
70 |
}
|
|
71 |
catch(Exception e)
|
|
72 |
{
|
|
73 |
for(int j=0; j<mNumListeners; j++)
|
|
74 |
EffectMessageSender.newMessage( mListeners.elementAt(j),
|
|
75 |
EffectMessage.EFFECT_FAILED,
|
|
76 |
(mID[i]<<EffectTypes.LENGTH)+EffectTypes.OTHER.type,
|
|
77 |
mType[i],
|
|
78 |
mBitmapID);
|
|
79 |
}
|
|
80 |
finally
|
|
81 |
{
|
|
82 |
if (bos != null)
|
|
83 |
{
|
|
84 |
try {bos.close();}
|
|
85 |
catch(IOException io ) {}
|
|
86 |
}
|
|
87 |
}
|
|
88 |
|
|
89 |
remove(i);
|
|
90 |
i--;
|
|
91 |
continue;
|
39 |
92 |
}
|
40 |
93 |
else if (mType[i] == EffectNames.SAVE_MP4.ordinal() )
|
41 |
94 |
{
|
Implement SAVE_PNG