Я хочу установить изображение в pdf. Я использую iText для установки изображения в pdf. Я успешно отображаю изображение из папки Assets. Но я хочу отображать изображение с пути SD-карты. Ниже приведен код для отображения изображения из папки ресурсов.
try
{
InputStream ims = con.getAssets().open("prof_image.png");
Bitmap bmp = BitmapFactory.decodeStream(ims);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
Image image = Image.getInstance(stream.toByteArray());
image.setAlignment(Image.ALIGN_RIGHT);
cell.addElement(image);
//cell.setHorizontalAlignment(Element.ALIGN_CENTER); //alignment
//cell.setBackgroundColor(new GrayColor(0.75f)); //cell background color
cell.setFixedHeight(60); //cell height
table.addCell(cell);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
У меня нет ошибки, но я не знаю, как отображать изображение с SD-карты
try
{
String photoPath = Environment.getExternalStorageDirectory()+"/gtu.png";
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bmp = BitmapFactory.decodeFile(photoPath, options);
//InputStream ims = con.getAssets().open("prof_image.png");
//Bitmap bmp = BitmapFactory.decodeStream(ims);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
Image image = Image.getInstance(stream.toByteArray());
image.setAlignment(Image.ALIGN_RIGHT);
cell.addElement(image);
//cell.setHorizontalAlignment(Element.ALIGN_CENTER); //alignment
//cell.setBackgroundColor(new GrayColor(0.75f)); //cell background color
cell.setFixedHeight(60); //cell height
table.addCell(cell);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
какое сообщение об ошибке вы получаете ?? разместите свой логарифм здесь