I want to render a html-page with the C#-Webbrowser Form.
Normally I receive the html file from another application. For simplicity I just read the html page from the hard drive into a stream and then I set the webBrowserControl to this content.
That works in general. But now I want the html file to reference to images in the imageList.
I don't want to save the images to the hard drive.
Is there any possibilty to reference images in RAM with HTML.
The common way like
<img src="C:\\pic.png"/>
is obviously not possible.
Explanation Code
Image image = Image.FromFile(src_pathfile); //normally from another application over interface
List<Image> imageList = new List<Image>();
imageList.Add(image);
Stream source = File.OpenRead("C:\\Webpage.html"); //from another application
webBrowser.DocumentStream = source;
Thank you for your help in advance.
magicbasti
You can encode the image as base-64 and store it in the <img> tag itself. There's some information about it here.
Related
I am setting an absolute path to Image control. This path is having spaces. After assigning the path to ImageURL property of the Image ASP.NET control, it does not show the image. I don't have option to remove the spaces as it is the requirement. Also, this path is outside the root directory(There is basically a FileUpload control that takes the file and then I am assigning the path to Image control).
Firstly is it possible to do. If yes how? Below are the code blocks relevant to the question
Server Code
target.ImageUrl = strImagePath;
where target is the Image control id
File Path: C:\Users\WebMaster\Downloads\2 States Full Vedio Songs 720p Bluray Encodded By(Khanz)\Screenshoot\vlcsnap-2014-05-17-13h22m13s103.png
Rendered HTML
<img id="target" alt="[Jcrop Example]" src="C:\Users\WebMaster\Downloads\2%20States%20Full%20Vedio%20Songs%20720p%20Bluray%20Encodded%20By(Khanz)\Screenshoot\vlcsnap-2014-05-17-13h22m13s103.png" />
Thanks in advance for your help.
Thanks Manson. I was so wrong. The image has to be hosted on the web server to access. Actually, this is what I want to cut down. Uploading the image from local user path to server folder was taking time. But I forgot the basics. Re-writing your comment as answer.
I'm working on a project which requires to save the current page in an image. I found some examples in Javascript to create a blob of page, but what I would like to do is save the page in a file.
My question is, is it possible to save the content of a page in an image file?
Does a plugin exist to do it directly ?
If not, is it possible to save the blob and render the blob in C# to create an image?
To save a page as an image, you can use http://html2canvas.hertzen.com/
Example:
var canvas = document.getElementById("mycanvas");
var img = canvas.toDataURL("image/png");
document.write('<img src="'+img+'"/>');
I am trying to make image gallery for my website .
in my case i am showing thumbnail of all images and if we clicks
on the image it shows image in modal window .
there are 2 folders
Thumbs (consist thumbnail)
Full image (consist full image)
i have put the image with the same name ,as well i can do it by giving path of my images hard coded like this code
<ul id="gallery">
<li><img class="GalleryThumbnail" src="http://ppplugins.com/demo/ppgallery/images/s_01.jpg"></li>
</ul>
But dont know how can we do it without giving value hard coded .
please help me .
like if i add more iages in that folders it must show the image on page .
checkout here
1>http://182.50.154.23/elweb//CheckImagesFromFolder.aspx(trying to make it as 2nd link given below but not using source hard coded)
2>http://182.50.154.23/elweb//Gallery.aspx (required output)
var thumbs = Directory.GetFiles("your thumbs directory");
var images = Directory.GetFiles("your images directory");
foreach (var image in images)
{
var thumbname = thumbs.Where(x => x.Substring(2) == image.Substring(2));
}
I'm not sure if it's what you want, but if the files are in two seperate folders it will take their paths.
You can also match thumb with image comparing their names.
Use Database to store image name and Path. use reapeter control to show image list.
I was wondering how you, on WP8, can navigate to / open an image?
Suppose I just saved an image to my Save Pictures folder, I now want to navigate the user to that image so they can share it on facebook.
Lets say I have:
MediaLibrary lib = new MediaLibary();
Picture p = library.SavePicture("foo.jpg", imgStream);
How can I navigate to p as if the user had clicked it from the picture library?
A simple method for navigate into image is related to Efficient image manipulation in C#. I think that you need an framework for precessing like AForge.NET.
You could always try passing the url of the image as a string to a page that has nothing on it except an "Image". Then as soon as you navigate to the page you open up the image from the url(url can be for an isolatedstorage file) and set it as the "Image" on the page.
I am developing a C# web project. I run it on the local web server.
I draw. I show image as follows:
bitmap.Save(Server.MapPath("diagram.jpg"), ImageFormat.Jpeg);
Image1.ImageUrl = ResolveUrl("diagram.jpg");
I don't see new image. Only old one, which I had after changing image name
(Say, I change diagram.jpg to diagram2.jpg).
Browser is Firefox.
The design page in C# is simple. Just Image and few TextBoxes on the page.
No UpdatePanel and such.
Something with caching... But how to fight with that...
But how to fight with that.
Always use a separate path / name. Pug a GUID somewhere. Simple like that. Different file can not be cached.
I'm not sure what ResolveUrl does, but try adding a querystring to the image url so that the page always gets a "fresh" file. Something like this:
Image1.ImageUrl = ResolveUrl(string.Format("diagram.jpg?v={0}", Guid.NewGuid()));
You can alternative write the image file as
diagram.jpg?ver=2
to keep the same image file, but force the browser to update it.
If Image has Same name and URL browser picks the image from the cache and displays the same for faster loading of the pages.
Even if you change the image server side the same cached image is displayed until you clear the cache of the browser. You can use query string to change image url like below.
Image1.ImageUrl = ResolveUrl("diagram.jpg?" + DateTime.Now.Ticks.ToString());