I have a rest server hosted in Amazon written in Delphi with a method returning a jpg Stream image.
I need download the image and show in webview.
The method Rest Server method is something as:
//delphi code
function TSrvServerMetodos.ImagePac(pront:integer): TStream;
var blob:TStream;
begin
...
Result := CreateBlobStream(fieldbyname('PHOTO'),bmRead);
end;
where the Result is a jpeg Stream with a image.
To access the remote rest method I am trying to use the next:
String url = Common.getServerUrl() +"/"+ "\"ImagePac\"";
String URL=url+"/"+"23";
webView.loadUrl(URL);
But no Image is showing in webview.
My image is comming from a rest server and no a website. I have no way to call something as webview.loadUrl("http://www.myserver.com/myimage.jpg");
Is possible load that image with webview?
Regards, Luiz
Yes, It is. To solve the problem I had to save the image to sdcard and create a html string to load the image with webview.
For the new offspring with the same trouble. Just encode image in base64 and place it in src attribute of img tag
Related
I am developing story feature app like instagram or whatsapp but I got stuck somewhere. I am getting image thumbnail from server as URL but when I try to use it . It take some time to load that image.So I want to Load add thumbnail images from url in previous activity and then set that thumbnail from cache.How I can store url images in cache Hashmap or arraylist to use them in next activity.Please help.I am in trouble right now.
You can use Glide for catching the image from URL.
I am trying to display an image in an activity after parsing it's URL in JSON format from the web. The image string thus obtained has a cms file extention. I know that Volley's image loader toolbox can be used to display jpg images but with this extention it is unable to inflate the view. What should i do?
Try replacing .cms with .jpeg in the url itsel. It worked for me.
For example, how to make the following HTML page actually display the image, in an Android WebView?
<html>
<body>
<img src="http://www.alternatiff.com/sample.tif">
</body>
</html>
Any (hacking) suggestion is appreciated. I am only an app developer and cannot control the whole system, so modifying the OS source code is not applicable.
I haven't tried this, but this is what I would do:
Make a subclass of WebViewClient
Override shouldInterceptRequest() to check the URL and see if a TIFF was requested. If it was not a TIFF, return null to tell the WebView to handle the request itself.
If a TIFF was requested, open HttpURLConnection to the TIFF url and read the data, convert the TIFF to a JPEG or PNG ex. How to convert TIFF to JPEG/PNG in java and set up an InputStream to read the JPEG/PNG image bytes.
Return a WebResourceResponse with the mime type (i.e. image/jpeg) and the InputStream you created to read the image data.
Call setWebViewClient on the webview with an instance of your WebViewClient subclass.
Rather than converting on the device using a JNI library, I think I would convert the image on a server and open the HttpURLConnection to the pre-converted image stream, i.e. http://example.com/convert_tiff?url=http%3A%2F%2Fwww.alternatiff.com%2Fsample.tif&fmt=JPEG and then return that InputStream in the WebResourceResponse. I guess it depends on how cheap the bandwidth and server resources are for you.
I just tested AQuery's image loading based on this tutorial. It works well, when I use on an URL like example.com/xy.jpg. But what if I want to load an image that is displayed by a page (for example a php page)?
If my url is like this: example.com/showimage.php, I get a message of this: SkImageDecoder::Factory returned null.
Does AQuery support deferred image loading?
Yes it can if the PHP page redirects to a valid image.
How can i use JSOUP to display images in Image view using the URL. Any sample code is available for that. I searched but i couldn't find out.
Please help me with any link.
Thanks.
fir make the connection with provided link then you can get the image with
imagesRec = document.select("img[src~=(?i)\\.(png|jpe?g|gif)]");
then
String imgSrcUrl = img.attr("abs:src"); // imagePath
the you will use the Picasso lib for displaying the url as image in imageView
Picasso.with(MainActivity.this).load(imgSrcUrl).into(logo);
and thats it
you would have to parse the url of the image from the tag and then put into a string or similar. this string you can then use to load your image into an imageView.