Closed arunramya closed 6 years ago
I do not understand your needs, please elaborate
i got stream from file, through this stream how can i get bitmap?
FileInputStream initialStream44 = new FileInputStream(new File(Environment.getExternalStorageDirectory() + "/output.jpg")); byte[] bufferr = new byte[initialStream44.available()]; initialStream44.read(bufferr);
Here how can i get bitmap by passing initialStream44. Please Help me.
Does not support reading bitmap directly from the input stream, if you know the path to the file, use the file path
i know file path. but the file content contains two images. but i have got second image contents via stream. but now i want to get bitmap for the stream..
You can solve this problem by custom UriModel, refer to https://github.com/panpf/sketch/blob/master/sample/src/main/java/me/panpf/sketch/sample/util/XpkIconUriModel.java
You need to customize two UriModel, respectively, used to read different pictures in the same file
I have implemented what you told.
How can i call that custom uri model while display bitmap?
private class XpkIconUriModel extends AbsStreamDiskCacheUriModel {
private ByteArrayInputStream myInputStream;
@NonNull
@Override
protected InputStream getContent(@NonNull Context context, @NonNull String uri) throws GetDataSourceException
{
FileInputStream strem = null;
try
{
strem = new FileInputStream(uri);
byte[] xxxx = new byte[strem.available()];
strem.read(xxxx,0,xxxx.length);
} catch (Exception e)
{
e.printStackTrace();
Log.e("Exception Here","oh sorry");
}
return strem;
}
@Override
protected boolean match(@NonNull String uri)
{
return false;
}
}
An introduction to uri mode and a custom tutorial here https://github.com/panpf/sketch/blob/master/docs/wiki/uri_model.md
You can translate it to see
Get bitmap from inputstream. Please help me how to call via Sketch.