How to set imageview.toImage() as html image src in webview? - android

any idea to set imageview.toImage() as img src in html of a webview.
let suppose I have an imageview (having some image in it).okay imageview.toimage() is treated as an image object in titanium. now what i need is i want to set
webview.html='<html><img src="here i want to put obove imageview.toimage()"></html>';
I tried many way anyone have experience of it please guide me.
regards:ali

save it to a file and assigne the file's url path OR base64Encode the image and provide that as the value for the src parameter

you might try to convert the image into a base64 blob text and use it as css background image data :
background-image:url('data:image/png;base64,'+Ti.Utils.base64encode(imageview.toImage()).getText()+'\');

Related

Add image name(text) on image which i am getting from camera or gallery?

I want to add image name (text) on image which I am getting from camera or gallery?, I have tried some solution like by Canvas or Using XML file, but I want more feasible solution
Here is the one of best watermark library which help you do your task
https://github.com/huangyz0918/AndroidWM
They also provide different mechanisam to add watermark on your image.
Simply take relative layout in XML and add Textview and ImageView .
Now get the Image name from below code
you can use the substring method to get the name of the file from the path string.
String path=":/storage/sdcard0/DCIM/Camera/1414240995236.jpg";
// it contains your image path...I'm using a temp string...
String filename=path.substring(path.lastIndexOf("/")+1);

Displaying a image captured using Camera inside an html image tag placed within a WebView - Xamarin.Android

I'm looking for a way on to display the image captured using Camera2 API in Xamarin.Android inside an HTML tag which is placed within a WebView.
Though it was possible to obtain the File URi where the image is located, setting it into the image tag which I have tried, isn't working. I also want to know whether this kind of thing can be done in Native Android.
You can encode the content of the image in base64, and than set it in the src of your img tag like this:
<img src="data:image/jpg;base64,VeryLongBase64EncodedImageData"/>

Thumbnail in Text Files with WebView

I have a files's list in my Android app and I want put them a preview image, an icon (thumbnail).
I have got this purpose for image and video files, but not for text files.
In this last case, I know there is a Google Docs function that it creates an image from a text file that it can be used like thumbnail:
http://docs.google.com/viewer?url=MY_LINK&a=bi&pagenumber=1&w=300
Here, you can put the text file url, the number page and the width for thumbnail.
This method works well, but I don't know like obtaining the image created with this url, for saving in a Bitmap and put it in the icon ImageView.
Thanks for your attention.

android : how to specify the path of image in source code

I want to display some text and image in webview. FOr this i am using a template html string.
Within this template i want to replace the {image} with the path for an image in drawable folder
i tried
str = str.replace("{image}","res/drawable-hdpi/about.png" )
but the image is not coming.
Is this the right way to give path.
Or what is the right solution
Thanks a lot for your time and help

How can I reference a file in my drawable folder to put in WebView in android?

For example, I want to make an image appear in webview to utilize the zoom functions.
I would use this line of code:
this.myWebView.loadUrl("file://");
I just need to know what to put after file to reference the image.
you would have to use the data uri and base64 encode the image bytes. the Uri would look something like this:
this.myWebView.loadUrl("data:image/png;base64,<base64DataHere>");

Categories

Resources