20 |
20 |
package org.distorted.examples.vertex3d;
|
21 |
21 |
|
22 |
22 |
import android.app.Activity;
|
|
23 |
import android.graphics.Bitmap;
|
|
24 |
import android.graphics.BitmapFactory;
|
|
25 |
import android.graphics.Canvas;
|
|
26 |
import android.graphics.Paint;
|
23 |
27 |
import android.opengl.GLSurfaceView;
|
24 |
28 |
import android.os.Bundle;
|
25 |
29 |
import android.view.Gravity;
|
... | ... | |
43 |
47 |
import org.distorted.library.type.Dynamic2D;
|
44 |
48 |
import org.distorted.library.type.Dynamic3D;
|
45 |
49 |
import org.distorted.library.type.Dynamic4D;
|
|
50 |
import org.distorted.library.type.Static3D;
|
46 |
51 |
|
|
52 |
import java.io.IOException;
|
|
53 |
import java.io.InputStream;
|
47 |
54 |
import java.util.ArrayList;
|
48 |
55 |
|
49 |
56 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
125 |
132 |
Spinner bitmapSpinner = (Spinner)findViewById(R.id.objectpicker_spinnerBitmap);
|
126 |
133 |
bitmapSpinner.setOnItemSelectedListener(this);
|
127 |
134 |
|
128 |
|
String[] objectBitmap = new String[] {"Girl", "Dog", "Cat", "Grid"};
|
|
135 |
String[] objectBitmap = new String[] { "Grid", "Girl", "Dog", "Cat", "Squares"};
|
129 |
136 |
|
130 |
137 |
ArrayAdapter<String> adapterBitmap = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, objectBitmap);
|
131 |
138 |
adapterBitmap.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
... | ... | |
187 |
194 |
|
188 |
195 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
189 |
196 |
|
190 |
|
public int getBitmap()
|
|
197 |
public Bitmap getBitmap()
|
191 |
198 |
{
|
192 |
|
return mBitmap;
|
|
199 |
Bitmap bmp;
|
|
200 |
|
|
201 |
if( mBitmap!=-1)
|
|
202 |
{
|
|
203 |
InputStream is = getResources().openRawResource(mBitmap);
|
|
204 |
|
|
205 |
try
|
|
206 |
{
|
|
207 |
bmp = BitmapFactory.decodeStream(is);
|
|
208 |
}
|
|
209 |
finally
|
|
210 |
{
|
|
211 |
try
|
|
212 |
{
|
|
213 |
is.close();
|
|
214 |
}
|
|
215 |
catch(IOException e) { }
|
|
216 |
}
|
|
217 |
}
|
|
218 |
else
|
|
219 |
{
|
|
220 |
final int W = 640;
|
|
221 |
final int H = 640;
|
|
222 |
|
|
223 |
Paint paint = new Paint();
|
|
224 |
bmp = Bitmap.createBitmap(W,H, Bitmap.Config.ARGB_8888);
|
|
225 |
Canvas canvas = new Canvas(bmp);
|
|
226 |
|
|
227 |
paint.setAntiAlias(true);
|
|
228 |
paint.setTextAlign(Paint.Align.CENTER);
|
|
229 |
paint.setColor(0xff008800);
|
|
230 |
paint.setStyle(Paint.Style.FILL);
|
|
231 |
canvas.drawRect(0, 0, W, H, paint);
|
|
232 |
paint.setColor(0xffffffff);
|
|
233 |
|
|
234 |
for(int i=0; i<=mNumCols ; i++ )
|
|
235 |
{
|
|
236 |
canvas.drawRect(W*i/mNumCols - 1, 0, W*i/mNumCols + 1, H , paint);
|
|
237 |
canvas.drawRect( 0, H *i/mNumCols -1, W , H*i/mNumCols + 1, paint);
|
|
238 |
}
|
|
239 |
}
|
|
240 |
|
|
241 |
return bmp;
|
193 |
242 |
}
|
194 |
243 |
|
195 |
244 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
315 |
364 |
break;
|
316 |
365 |
case R.id.objectpicker_spinnerBitmap: switch(pos)
|
317 |
366 |
{
|
318 |
|
case 0: mBitmap = R.raw.face; break;
|
319 |
|
case 1: mBitmap = R.raw.dog; break;
|
320 |
|
case 2: mBitmap = R.raw.cat; break;
|
321 |
|
case 3: mBitmap = R.raw.grid; break;
|
|
367 |
case 0: mBitmap = -1 ; break;
|
|
368 |
case 1: mBitmap = R.raw.face; break;
|
|
369 |
case 2: mBitmap = R.raw.dog; break;
|
|
370 |
case 3: mBitmap = R.raw.cat; break;
|
|
371 |
case 4: mBitmap = R.raw.grid; break;
|
322 |
372 |
}
|
323 |
373 |
break;
|
324 |
374 |
case R.id.vertex3dspinner : mEffectAdd = pos;
|
Vertex3D: Add the new 'Grid' bitmap option!