【发布时间】:2014-02-10 04:25:08
【问题描述】:
我正在使用iTextG jar 创建数字签名应用程序,在签名字段上添加水印,iText 的
appearance.setImage(Image.getInstance(signedImagePath));
需要水印图像的路径,我想使用android的drawable文件夹中的图像,请建议我没有得到如何从drawable创建图像实例,建议是否有其他选项?
【问题讨论】:
我正在使用iTextG jar 创建数字签名应用程序,在签名字段上添加水印,iText 的
appearance.setImage(Image.getInstance(signedImagePath));
需要水印图像的路径,我想使用android的drawable文件夹中的图像,请建议我没有得到如何从drawable创建图像实例,建议是否有其他选项?
【问题讨论】:
你使用 ImageInstance 这样的东西。
Bitmap bitmap = BitmapFactory.decodeResource(getBaseContext().getResources(),R.drawable.yourimage);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100 , stream);
Image myImg = Image.getInstance(stream.toByteArray());
希望这会有所帮助。
【讨论】:
http://developer.android.com/reference/android/graphics/BitmapFactory.html#decodeResource(android.content.res.Resources, int, android.graphics.BitmapFactory.Options)
【讨论】: