4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

processingでAndroid端末に画像保存

Last updated at Posted at 2015-10-20

最近Processingを使ってAndroid端末用のドローイングツールを
作った時に画像をギャラリーに保存する方法を調べたのでメモします。


import android.view.MotionEvent;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;
import android.app.Activity;

Intent intent;

void setup () {
	size (displayWidth, displayHeight, JAVA2D);
  	colorMode (RGB, 256);
	background (255);
	//Android端末のファイル保存環境を取得
	intent = new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()));
}

void draw () {
	fill (random (256), random (256), random (256));
	ellipse (random (width), random (height), 20, 20);
}

void mouseReleased () {
	String img_name = Environment.getExternalStorageDirectory() + "/test_image.png";
	save (img_name);
	sendBroadcast (intent);
}

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?