2
3

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-21

Processingから直接プリントジョブを送るわけではないですが、
Android用のプリントアプリを介して印刷できたのでメモします。

プリンタがEPSONだったので、以下のような流れになりました。

  1. Android端末にEPSONの無料プリントアプリ「EPSON iPrint」を入れる。

  2. Processingから画像のシェアを要求。

  3. シェアのリストから「EPSON iPrint」を選んで印刷。


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 () {
	//Android端末に画像を保存
	save_image ();
}

void save_image () {
	String img_name = Environment.getExternalStorageDirectory() + "/test_image.png";
	save (img_name);
	sendBroadcast (intent);
	//保存した後プリントアウト
	print_out (img_name);
}

void print_out (String img_path) {
	Intent shareIntent = new Intent (Intent.ACTION_SEND);
	shareIntent.setType ("image/png");
	shareIntent.putExtra (Intent.EXTRA_STREAM, Uri.fromFile (new File (img_path)));
	startActivity (shareIntent);
}

2
3
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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?