Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Image instance from drawable images in android

i am creating digital signature app using iTextG jar, to add water mark on the signature field, iText's

appearance.setImage(Image.getInstance(signedImagePath));

Requires a path of the watermark image, i want to use image from drawable folder of android, kindly suggest me i am not getting how to create Image instance from drawable, suggest if any other option is there?

like image 223
user1987823 Avatar asked Oct 02 '22 15:10

user1987823


1 Answers

You use ImageInstance something like this.

 Bitmap bitmap = BitmapFactory.decodeResource(getBaseContext().getResources(),R.drawable.yourimage);
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100 , stream);
    Image myImg = Image.getInstance(stream.toByteArray());

Hope this helped.

like image 108
Sandeep R Avatar answered Oct 05 '22 08:10

Sandeep R