2

この写真にテキストを書き込む方法、いくつかの情報を追加します。

YuvImage image = new YuvImage(data, ImageFormat.NV21, maxwidth, maxheight, null);
Rect rectangle = new Rect();
rectangle.bottom = maxheight;
rectangle.top = 0;
rectangle.left = 0;
rectangle.right = maxwidth;
ByteArrayOutputStream output = new ByteArrayOutputStream();
image.compressToJpeg(rectangle, 95, output);
4

1 に答える 1

2

画像にテキストを追加することがEXIF情報を追加することを意図している場合は
、次のリンクを参照してください: Android での書き込み/ジオタグ JPEG (EXIF データ)

画像にテキストを描画する場合は、次の方法が役立つ場合があります。
次のコードを の後に配置しimage.compressToJpeg(rectangle, 95, output);ます。描画時の画質を向上させるために、
この線を に変更することをお勧めします。image.compressToJpeg(rectangle, 100, output);

// Decode the JPEG byte array from 'output' to 'Bitmap' object
Bitmap bmp = BitmapFactory.decodeByteArray(output.toByteArray(), 0, output.size());

// Use 'Canvas' to draw text ont 'Bitmap'
Canvas cv = new Canvas(bmp);

// Prepare 'Paint' for text drawing
Paint mPaint = new Paint();
mPaint.setColor( Color.RED );
mPaint.setStyle( Style.STROKE );
mPaint.setTextSize(20);

// Draw text on the 'Bitmap' image
cv.drawText("TEXT To SHOW", 10, 10, mPaint);

// Reset the stream of 'output' for output writing.
output.reset();

// Compress current 'Bitmap' to 'output' as JPEG format
bmp.compress(CompressFormat.JPEG, 95, output);

次に、出力を使用して必要なことを行うことができます。

于 2013-05-16T02:53:08.687 に答える