- Where Developers Learn, Share, & Build Careers


First, a small background:

For the time being Further forgiveness is the long-winded nature of this introduction; However, it can help to provide an alternative solution which is not specific to the nature of the question.

I have an ASP.NET MVC application that uses Embedded WinForm UserControls. These controls provide support for "narrow" on tablet PCs via the Microsoft .inux library. They are an unfortunate requirement due to an IE8 corporate standard; Otherwise, the HTML5 canvas solution will be there.

However, an image URL InkPicture to & lt; PARAM & gt; Has been passed through .

  and object VIEWASEXT = "true" classid = "MyInkControl.dll # MyInkControl.MyInkControl" id = "myImage" name = "myImage" runat = "server" & gt; & Lt; PARAM name = "ImageUrl" value = "http: //some-website/Content/images/myImage.png" /> & Lt; / Object & gt; The associated property in the   

UserControl takes that URL, one method calls a HttpWebRequest , and the returned image It is kept in it InkPicture .

  public image download image (string url) {image _tmpImage = null; Try {// Open a Connection HttpWebRequest _HttpWebRequest = (HttpWebRequest) HttpWebRequest.Create (url); _HttpWebRequest.AllowWriteStreamBuffering = True; // Use default credentials _HttpWebRequest.Credentials = Credential cache. Default credentials; // Request Reaction: System.Net.WebResponse _WebResponse = _HttpWebRequest.GetResponse (); // Open data stream: system. Io Stream_webstream = _WebResponse.getResponseStream (); // Change webstream to image _tmpImage = Image.FromStream (_WebStream); // CleanUp _WebResponse.Close (); } Hold (Exception Pre) {// Error Throw Before; } Return _tmpImage; }   

Problem

This works, but there is a lot of overhead in this process, which is important I delay loading webpage (15 pictures take 15 seconds ... not ideal). image img = new bitmap (url) in the UserControl file IO permissions issues (due to complete trust or not, does not work in this situation, I failed to delete

An existing option, I decided to test it I will load each image in javascript, then use canvas and toDataUrl () to get base64 data. After all, instead of passing the URL to UserControl and all the leg work, I pass the base 64 data as and lt; PARAM & gt; Then it quickly converts that data into the image.

15 seconds for 15 images is less than 3 seconds, so the image that works in IE 7/8-> Base 64 The search for the solution began.


Here are some additional requirements / restrictions:

  • Can not resolve external dependent Classes (ie $ .getImageData)
  • It should be explained 100% to make it portable.
  • The source and quantity of images is variable, and they are in the URL format (base64 data is not an option).

    I hope that I have provided enough information and I appreciate any direction you can give.

    Thank you.

    You can use any FlashCanvas, fxCanvas or excanvas libraries, which in older Internet Explorer versions Flash or simulate the canvas using VML. I believe that all of them provide the toDataURL method from the canvas API, from which you can get an encoded representation of your image.

    After extensive excavation (I am in the same fix) I believe that this is the only solution, it is less than writing a PHP script, which you can send to the image. Of course, the problem is that none of these three situations is true, unless there is no way to send pictures to PHP scripts:

    • Browser type array ( Uint8Array )
    • Supports sendAsBinary
    • to the browser being uploaded by someone through a form (the situation In this is a PHP script that reacts with base 64 encoding)

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -