コード例 #1
0
        private void HandleSetupImageTexture(uint texName, out Size size)
        {
            // create bitmap
            Bitmap bitmap;

            if (!bitmapFile.Equals(global::Android.Net.Uri.Empty))
            {
                var f = new Java.IO.File(bitmapFile.Path);
                bitmap = BitmapFactory.DecodeFile(f.Path);
            }
            else
            {
                bitmap = BitmapFactory.DecodeResource(context.Resources, bitmapResource);
            }

            // set context image texture with bitmap
            GLHelper.GetError();
            GL.BindTexture(TextureTarget.Texture2D, ccContext.ImageTexName);
            GLHelper.GetError();
            GLUtils.TexImage2D(GLES30.GlTexture2d, 0, GLES30.GlRgba, bitmap, 0);
            GLHelper.GetError();
            GL.BindTexture(TextureTarget.Texture2D, 0);
            GLHelper.GetError();

            // Set size
            size = new Size(bitmap.Width, bitmap.Height);

            float radius = Math.Min(size.Width, size.Height) * 0.5f * 0.8f;

            ccContext.CountLayerContext.SetROI(new Vector2(size.Width * 0.5f, size.Height * 0.5f), radius);

            // Trigger center view
            ccContext.CenterView(viewSize);

            // recycle bitmap
            bitmap.Recycle();
        }