三角形のフレームを作る必要があります。そして、GestureImageViewがその三角形フレームの背景になります。実線の境界線のみの三角形。ユーザーが三角形の内側の画像をズームインおよびズームアウトできるようにします。ヘルプはありますか?
GestureImageViewを作成しました。必要なのは三角形の透明なフレームだけです。助けてください ?
以下はコードです
public class TriangleActivity extends Activity implements android.opengl.GLSurfaceView.Renderer
{
private static final String TAG = TriangleActivity.class.getSimpleName();
private static final int Coordinates_In_A_Vertex = 2;
private static final int Vertices_In_A_Triangle = 3;
private static final int Bits_In_A_Byte = 8;
private static final int Bits_In_A_Float = Float.SIZE;
private static final int Bytes_In_A_Float = Bits_In_A_Float / Bits_In_A_Byte;
private GLSurfaceView glSurfaceView;
private FloatBuffer vertices;
private int width;
private int height;
/*
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.triangle);
glSurfaceView=(GLSurfaceView)findViewById(R.id.surfaceview);
//glSurfaceView.setEGLConfigChooser(8,8,8,8,16,0);
glSurfaceView.setRenderer(this);
// glSurfaceView.getHolder().setFormat(PixelFormat.TRANSPARENT);
// glSurfaceView.setZOrderOnTop(true);
}
/*
* Called when the activity is resumed.
* The activity is resumed whenever it is being presented to user (from the background).
*/
@Override
public void onResume()
{
super.onResume();
glSurfaceView.onResume();
}
/*
* Called when the activity is paused.
* The activity is paused whenever it is placed into the background. Various things can cause this (pressing the home button, receiving a phone call, turning off the display, etc.).
*/
@Override
public void onPause()
{
glSurfaceView.onPause();
super.onPause();
}
@Override
public void onDrawFrame(GL10 gl)
{
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
gl.glColor4f(0.64313725490196f, 0.77647058823529f, 0.22352941176471f, 1);
gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vertices);
gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3);
}
@Override
public void onSurfaceChanged(GL10 gl, int width, int height)
{
Log.d(TAG, "Surface changed! width = " + String.valueOf(width) + ", height = " + String.valueOf(height));
}
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config)
{
Log.d(TAG, "Surface Created!");
width = glSurfaceView.getWidth();
height = glSurfaceView.getHeight();
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrthof(0, 1, 0, 1, 1, -1);
//New Changes
// gl.glDisable(GL10.GL_DITHER);
// gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,
// GL10.GL_FASTEST);
//gl.glClearColor(1, 1, 1, 1);
// gl.glEnable(GL10.GL_CULL_FACE);
// gl.glShadeModel(GL10.GL_SMOOTH);
// gl.glEnable(GL10.GL_DEPTH_TEST);
//End
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(Coordinates_In_A_Vertex * Vertices_In_A_Triangle * Bytes_In_A_Float);
byteBuffer.order(ByteOrder.nativeOrder());
vertices = byteBuffer.asFloatBuffer();
vertices.put(new float[]
{
0.0f, 0.0f,
0.5f, 1.0f,
1.0f, 0.0f
}
);
vertices.flip();
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
}
}