質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Q&A

0回答

1421閲覧

NyARToolkit撮影機能の拡張

jigokunoiruka

総合スコア8

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

0グッド

0クリップ

投稿2016/07/07 13:56

今、NyARToolkitのsampleSimpleLiteを拡張して、タッチすると写真を撮れるようにしたいと考えています。
getDrawingCacheを使って撮影しようと考えたのですが、どうしてもちゃんと撮れず、真っ黒の画像が保存されます。原因と解決法、または違う方法を知ってたら教えていただきたいです。

java

1public class SimpleLiteActivity extends AndSketch implements AndGLView.IGLFunctionEvent { 2 //private Camera camera; 3 CameraPreview _camera_preview; 4 AndGLView _glv; 5 6 Camera.Size _cap_size; 7 8 /** 9 * ATTENTION: This was auto-generated to implement the App Indexing API. 10 * See https://g.co/AppIndexing/AndroidStudio for more information. 11 */ 12 private GoogleApiClient client; 13 14 /** 15 * onStartでは、Viewのセットアップをしてください。 16 */ 17 @Override 18 public void onStart() { 19 super.onStart(); 20 // ATTENTION: This was auto-generated to implement the App Indexing API. 21 // See https://g.co/AppIndexing/AndroidStudio for more information. 22 client.connect(); 23 FrameLayout fr = ((FrameLayout) this.findViewById(R.id.sketchLayout)); 24 //カメラの取得 25 this._camera_preview = new CameraPreview(this); 26 this._cap_size = this._camera_preview.getRecommendPreviewSize(320, 240); 27 //画面サイズの計算 28 int h = this.getWindowManager().getDefaultDisplay().getHeight(); 29 int w = this.getWindowManager().getDefaultDisplay().getWidth(); 30 int screen_w, screen_h; 31 screen_w = w; 32 screen_h = h; 33 //camera 34 fr.addView(this._camera_preview, 0, new LayoutParams(screen_w, screen_h)); 35 //GLview 36 this._glv = new AndGLView(this); 37 fr.addView(this._glv, 0, new LayoutParams(screen_w, screen_h)); 38 // ATTENTION: This was auto-generated to implement the App Indexing API. 39 // See https://g.co/AppIndexing/AndroidStudio for more information. 40 Action viewAction = Action.newAction( 41 Action.TYPE_VIEW, // TODO: choose an action type. 42 "SimpleLite Page", // TODO: Define a title for the content shown. 43 // TODO: If you have web page content that matches this app activity's content, 44 // make sure this auto-generated web page URL is correct. 45 // Otherwise, set the URL to null. 46 Uri.parse("http://host/path"), 47 // TODO: Make sure this auto-generated app URL is correct. 48 Uri.parse("android-app://jp.nyatla.nyartoolkit.and/http/host/path") 49 ); 50 AppIndex.AppIndexApi.start(client, viewAction); 51 } 52 53 54 NyARAndSensor _ss; 55 NyARAndMarkerSystem _ms; 56 private int _mid; 57 AndGLTextLabel text; 58 AndGLBox box; 59 AndGLFpsLabel fps; 60 61 public void setupGL(GL10 gl) { 62 try { 63 AssetManager assetMng = getResources().getAssets(); 64 //create sensor controller. 65 this._ss = new NyARAndSensor(this._camera_preview, this._cap_size.width, this._cap_size.height, 30); 66 //create marker system 67 this._ms = new NyARAndMarkerSystem(new NyARMarkerSystemConfig(this._cap_size.width, this._cap_size.height)); 68 this._mid = this._ms.addARMarker(assetMng.open("AR/data/neomoto.pat"), 16, 25, 80); 69 this._ss.start(); 70 //setup openGL Camera Frustum 71 gl.glMatrixMode(GL10.GL_PROJECTION); 72 gl.glLoadMatrixf(this._ms.getGlProjectionMatrix(), 0); 73 this.text = new AndGLTextLabel(this._glv); 74 this.box = new AndGLBox(this._glv, 40); 75 this._debug = new AndGLDebugDump(this._glv); 76 this.fps = new AndGLFpsLabel(this._glv, "MarkerPlaneActivity"); 77 this.fps.prefix = this._cap_size.width + "x" + this._cap_size.height + ":"; 78 79 } catch (Exception e) { 80 // TODO Auto-generated catch block 81 e.printStackTrace(); 82 this.finish(); 83 } 84 } 85 86 AndGLDebugDump _debug = null; 87 88 /** 89 * 継承したクラスで表示したいものを実装してください 90 * 91 * @param gl 92 */ 93 public void drawGL(GL10 gl) { 94 try { 95 //背景塗り潰し色の指定 96 gl.glClearColor(0, 0, 0, 0); 97 //背景塗り潰し 98 gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); 99 if (ex != null) { 100 _debug.draw(ex); 101 return; 102 } 103 fps.draw(0, 0); 104 synchronized (this._ss) { 105 this._ms.update(this._ss); 106 if (this._ms.isExistMarker(this._mid)) { 107 this.text.draw("found" + this._ms.getConfidence(this._mid), 0, 16); 108 gl.glMatrixMode(GL10.GL_MODELVIEW); 109 gl.glLoadMatrixf(this._ms.getGlMarkerMatrix(this._mid), 0); 110 this.box.draw(0, 0, 20); 111 } 112 } 113 } catch (Exception e) { 114 ex = e; 115 } 116 } 117 118 Exception ex = null; 119 120 @Override 121 protected void onCreate(Bundle savedInstanceState) { 122 super.onCreate(savedInstanceState); 123 //setContentView(R.layout.main); 124 125 // ATTENTION: This was auto-generated to implement the App Indexing API. 126 // See https://g.co/AppIndexing/AndroidStudio for more information. 127 client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); 128 } 129 130 @Override 131 public void onStop() { 132 super.onStop(); 133 134 // ATTENTION: This was auto-generated to implement the App Indexing API. 135 // See https://g.co/AppIndexing/AndroidStudio for more information. 136 Action viewAction = Action.newAction( 137 Action.TYPE_VIEW, // TODO: choose an action type. 138 "SimpleLite Page", // TODO: Define a title for the content shown. 139 // TODO: If you have web page content that matches this app activity's content, 140 // make sure this auto-generated web page URL is correct. 141 // Otherwise, set the URL to null. 142 Uri.parse("http://host/path"), 143 // TODO: Make sure this auto-generated app URL is correct. 144 Uri.parse("android-app://jp.nyatla.nyartoolkit.and/http/host/path") 145 ); 146 AppIndex.AppIndexApi.end(client, viewAction); 147 client.disconnect(); 148 } 149 150 151 @Override 152 public boolean onTouchEvent(MotionEvent event) { 153 if (event.getAction() == MotionEvent.ACTION_DOWN) { 154 // 読み書きするファイル名を指定 155 SimpleDateFormat format = new SimpleDateFormat("'IMG'_yyyyMMdd_HHmmss'.jpeg'", Locale.getDefault()); 156 String fileName = format.format(new Date(System.currentTimeMillis())); 157 158 File file = new File(Environment.getExternalStorageDirectory() + "/"+fileName); 159 // 指定したファイル名が無ければ作成する。 160 file.getParentFile().mkdir(); 161 saveCapture(findViewById(android.R.id.content),file); 162 } 163 return true; 164 } 165 166 public void saveCapture(View view, File file) { 167 // キャプチャを撮る 168 Bitmap capture = getViewCapture(view); 169 FileOutputStream fos = null; 170 try { 171 fos = new FileOutputStream(file, false); 172 // 画像のフォーマットと画質と出力先を指定して保存 173 capture.compress(Bitmap.CompressFormat.JPEG, 100, fos); 174 toast("撮影完了1"); 175 fos.flush(); 176 } catch (Exception e) { 177 e.printStackTrace(); 178 } finally { 179 if (fos != null) { 180 try { 181 fos.close(); 182 } catch (IOException ie) { 183 fos = null; 184 } 185 } 186 } 187 } 188 189 190 public Bitmap getViewCapture(View view) { 191 view.setDrawingCacheEnabled(false); 192 view.setDrawingCacheEnabled(true); 193 view.destroyDrawingCache(); 194 195 // Viewのキャプチャを取得 196 Bitmap cache = view.getDrawingCache(); 197 if(cache == null){ 198 toast("null"); 199 return null; 200 } 201 Bitmap screenShot = Bitmap.createBitmap(cache); 202 view.setDrawingCacheEnabled(false); 203 return screenShot; 204 } 205 206 private void toast(String s) { 207 Toast.makeText(getApplicationContext(), s, Toast.LENGTH_LONG).show(); 208 } 209 210}

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問