MVC Display Binary Image from ViewBag

I am having problem when displaying the binary image in MVC view. I stored images in database as binary format and then assigned to ViewBag in Controller. How do I assign viewbag data to image in View?
Controller
ItemBO mibo = new ItemBO();
ViewBag.Picture1 = Convert.ToByte(mibo.GetImage(1));
View
var elem = document.createElement("img");
elem.setAttribute("src", @ViewBag.Picture1);
elem.setAttribute("style", "height:100%");
elem.setAttribute("alt", "Image");
document.getElementById("mydiv").appendChild(elem);
Above code doesn't work as I expected. Any help would be appreciated.

MVC section is at the below link.
http://forums.asp.net/

Similar Messages

  • How can I display an image from a shared-network folder?

    Hi
    Does anyone know how I can display images from within APEX that are found outside the database? What configuration have I missed?
    Within Windows-Internet-Explore I can access the following image using the below URLs, BUT I cannot access it from within APEX?
    What do I need to do so APEX can display theses images from our internal shared network folder?
    both these URLs work within Firefox (but on APEX):
    \\Saremote\UPDOWNFILES_DIR\polk_insight.gif
    file://///Saremote/UPDOWNFILES_DIR/polk_insight.GIF
    So within APEX I have created a "display as Text' Item that works with this "amazon image" syntax:
    {lessthan} IMG SRC= {doublequot} http://g-images.amazon.com/images/G/01/associates/navbar2000/logo-no-border(1).gif {doublequot} {greaterthan}
    BUT sadly not with my image:
    {lessthan} IMG SRC= {doublequot} file://///Saremote/UPDOWNFILES_DIR/polk_insight.GIF {doublequot} {greaterthan}
    Any ideas would be appreciated.
    Thanks
    Steve
    Edited by: [email protected] on Sep 12, 2008 8:30 AM
    Edited by: [email protected] on Sep 12, 2008 8:31 AM
    Edited by: [email protected] on Sep 12, 2008 8:32 AM
    Edited by: [email protected] on Sep 12, 2008 8:33 AM

    If you have a local html file, or open an image locally from the menu, then yes, it works, but with web pages that are served from a remote location (web server), security kicks in and prevents the web page from accessing local files (and files on a networked drive).
    you will either have to put the image on the web server and access it through http, or you can load it into the database/workspace images and access it that way.

  • Can i display all images from databases with adf jsp

    hi
    I want to display all images from the databases whit adf bussines components, because with the sample on http://www.oracle.com/technology/training/products/intermedia/index.html page, i only can display 10 images. i'd lije to know if i can to search in the databases by the id of the image.
    this is the code:
    %@ taglib uri="http://xmlns.oracle.com/adf/ui/jsp/adftags" prefix="adf"%>
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
    <%@ page contentType="text/html;charset=windows-1252"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>untitled</title>
    </head>
    <body>
    <html:errors/>
    <table border="1" width="100%">
    <tr>
    <th> </th>
    <th>
    <c:out value="${bindings.ImagenView1.labels['Id']}"/>
    </th>
    <th>
    <c:out value="${bindings.ImagenView1.labels['Descripcion']}"/>
    </th>
    <th>
    <c:out value="${bindings.ImagenView1.labels['Image']}"/>
    </th>
    </tr>
    <c:forEach var="Row" items="${bindings.ImagenView1.rangeSet}">
    <tr>
    <td>
    <c:out value="${Row.currencyString}"/>
    </td>
    <td>
    <c:out value="${Row['Id']}"/> 
    </td>
    <td>
    <adf:render model="Row.Image"/>
    </td>
    <td>
    <c:out value="${Row['Image']}"/> 
    </td>
    </tr>
    </c:forEach>
    </table>
    </body>
    </html>

    I think you want the interMedia JSP tag library...
    http://www.oracle.com/technology/software/products/intermedia/htdocs/descriptions/tag_library.html
    Larry

  • Display an image from an array of bytes

    Hi, I'm trying to display an image from the raw pixel values. lets say i read a bmp file to an array, chuk the header off and want to display the pixel. How can I do this? I don't want any file formats, just want to display the pixels and creat the image. Is this possible?
    Many thanks,
    H

    Thanks for the reply. I had a look at MemoryImageSource and other classes that relates to it. I wrote the example given, but it doesn't identify createImage(). I've implemented ImageProducer, but still complains. Have you any idea why? Thanks for your help.
    H

  • Displaying the image from camera after processing

    Hi,
    Using NI vision assistant I captured the image from the camera in continous mode with inline processing. Then the image was proceesed (filter,threshold and particle analysis), then I created a bounding box and integrated that with the real time video. But, the image viewer is displaying the image in binary form rather than in RGB space.
    I can't find any mistake.
    Please help.
    Thank you.

    Hi illuminator,
                           Can you post your VI and provide some more information?
    Thanks as kudos only

  • Displaying an image from a URL

    I have a program which visits a html page and creates a JComboBox with all the images from that page. When the user selects an image from the combo box it displays that image in a JLabel. This works fine with images that exist, when I try it with an image that doesn't exist I want it to realise that and display a message saying that "the image cannot be found". Heres part of my code that handles the selection:
    public void actionPerformed(ActionEvent f) {
                        JComboBox cb = (JComboBox)f.getSource();
                        String imageName = (String)cb.getSelectedItem();
                        try {
                             imageUrl = new URL(imageName);
                        catch (MalformedURLException ex) {
                             System.out.println("Image Collection Error: " + ex);
                        catch (Exception e) {
                             System.out.println("Some sort of exception: " + e);
                        picture.setIcon(new ImageIcon(imageUrl));
              });When I select a bad link image from the list I was hoping the catch blocks would trap it and I could make adjustments accordingly, this does not happen. No exception is thrown at all.
    Any ideas of what I can do??
    Bow_wow.

    Thanks for your help, I have changed it to the following code:
    ImageIcon imageToDisplay = new ImageIcon(imageUrl);
                        ImageIcon badImage = new ImageIcon("logo.jpg"); // An image I know exists
                        int status = imageToDisplay.getImageLoadStatus();
                        if (status == MediaTracker.COMPLETE) {
                             picture.setIcon(imageToDisplay);
                        else {
                             picture.setIcon(badImage);                              
                        }It works now, thanks again for your help!

  • [Forum FAQ] How to display an image from Http response in Reporting Services?

    Question:
    There is a kind of scenario that users want to display an image which is from URL. In Reporting Services, if the URL points to an image file, we can directly display it by typing the URL in embedded image. However, some URLs are just sending Http requests
    to server side, then redirect to another position and the server will return the image. For these kind of URLs, Reporting Services can’t directly render the image from Http response.
    Answer:
    To achieve this goal, we can add custom code into the report. Pass the URL as argument into our custom function so that we can create HttpRequest and get the HttpResponse. Then we can use custom function to return the Bytes() from the HttpResponse and render
    it into an image in report.
    Ps: In Reporting Services, it only support drawing Bytes() array into image, so we need to have our custom function return Bytes array.
    Add the assembly and custom code into the report.
    Public shared Function GetImageFromByte(Byval URL as String) As byte() 
                    Dim photo as System.Drawing.Image 
             Dim Request As System.Net.HttpWebRequest 
           Dim Response As System.Net.HttpWebResponse 
                  Request = System.Net.WebRequest.Create(URL)         
                     Response = CType(Request.GetResponse, System.Net.WebResponse) 
                 If Request.HaveResponse Then  
                      If Response.StatusCode = Net.HttpStatusCode.OK Then                    
                           photo = System.Drawing.Image.FromStream(Response.GetResponseStream) 
                     End If 
                 End If 
                  Dim ms AS System.IO.MemoryStream = new System.IO.MemoryStream() 
                 photo.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg) 
                    Dim imagedata as byte()  
                    imagedata = ms.GetBuffer()  
                    return imagedata
    End Function
    Grant the permission for assemblies. 
    Go to: 
    C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\RSpreviewPolicy.config 
    C:\Program Files\Microsoft SQL Server\MSSQL\Reporting Services\ReportServer\rssrvpolicy.config
    Give “FullTrust” for Report_Expressions_Default_Permissions.
    Insert an image into report. 
    Expression:
    =Code.GetImageFromByte("https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSrVwPoAtlcA2A3KaiAJi-XjS4icr1QUnKYr7uzpX3IL3g2GPisAQ")
    The Result looks below:
    Applies to:
    Reporting Services 2005
    Reporting Services 2008
    Reporting Services 2008 R2
    Reporting Services 2012
    Reporting Services 2014
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    >
    Hi, I'd like to display a dynamic image from the web inside a JLabel or any other swing component it could work in. I've been looking on the Swing tutorials and others forums, all I can have is that a JLabel can load an Icon object, defined by an image URL, but can this URL be like "http://xxxxx/image.jpg" somehow or can it only be a local image URL?>
    I do not know why you start talking about an image on the web then go on to show concerns about whether it will work for a 'local' URL.
    But perhaps this answer will cover the possibilities.
    So long as you can from an URL to the image, and the bytes are available for download (e.g. some web sites wrap a direct call to an image in HTML that embeds the image), the URL based icon constructors will successfully load it.
    It does not matter if that URL points to
    - a web site,
    - a local server ('localhost'),
    - an URL representation of a File on the local file system, or
    - it is inside a Jar file that is on the application's run-time classpath.
    How you go about forming a valid URL to a 'local resources' (or indeed what you regard as local resources) is another matter, depending on the form of the project, and how the resources are stored (see list above).
    Probably the main reason that examples use images at a hard coded URL on the net is that it makes an 'image example' self contained. As soon as we compile and run it, we can see the result. I have posted a few examples like that on these forums.
    Edit 1:
    BTW - Welcome to the Sun forums
    Edited by: AndrewThompson64 on Apr 21, 2009 12:15 PM

  • How to display an image from database

    Hi all,
    I've saved an image(jpeg file) as BLOB item in the database through the forms.I need to fetch that particular image from the database and display the image in the report.How can i do that?
    I tried to fetch the column from the database and added a text item and selected the PHOTO column , the properties has changed once i selected the BLOB item.File format I changed to Image , But the width is 4 and I'm not able to change that.
    While executing I'm getting two errors,
    REP : 0069 Internal Error
    REP : 62203 Internal Error reading the image - Unable to render RenderedOp for this operation
    Please help me to solve this issue.
    Thanks in advance...

    Hello,
    Try to revert to the "old" way to render images :
    http://www.oracle.com/webapps/online-help/reports/10.1.2/topics/htmlhelp_rwbuild_hs/rwrefex/envvars/envvar_reports_default_display.htm
    To revert to the dependency on DISPLAY and use screen fonts (old font look up algorithm):
    Set REPORTS_DEFAULT_DISPLAY=NO.
    Remove the screenprinter.ppd entry in the uiscreenprint.txt file.
    Set the DISPLAY variable to the active X-Windows display surface.
    Regards

  • How to Display a image from WebCam in the Forms 10.1.2.0.2!

    Hi Friends!
    I'm using a Forms 10.1.2.0.2 and i need to display of someway a image from webcam in some item inside the Forms!
    This is possible?
    I saw an explanation in http://www.orafaq.com/forum/t/89431/67467/ but it works only for a Forms 6.0!
    Somebody can Help me?

    As Jan mentioned, there is no way to display webcam video in Forms unless you create a Java Bean which can be incorporated into your form. As Pauli mentioned, if your webcam software is viewable via a browser, you can use WEB.SHOW_DOCUMENT to display a browser window with the content, however you will not be able to put this content in the form using the method.
    A good starting place would be Google. Look for a java bean or applet which can operate a web cam.
    http://www.google.com/search?q=java+applet+web+cam

  • Automatically display remote images from trusted senders?

    To help control spam, I have Mail set to not display remote images. However, I get a couple daily emails that are from trusted senders and clicking on the "Display Images" button for these gets old pretty quickly. Is there a way I can get Mail to automatically display the remote images from these trusted senders without turning on the display of remote images for all senders? In case it matters, these senders are not in my Address Book and I would prefer not to add them for reasons too involved to explain here. Although if that is the only way to accomplish what I want, I'll do it.

    there is no option to do that. you can request that this feature be added here:
    http://www.apple.com/feedback/macosx.html

  • I tried to display gif image from oracle to jsp but nothing appear

    i tried to display image from oracle DB to jsp directly without using file processing , and i used Servlet and jsp , Servlet to get image from DB and jsp to use <img> tag , when i Run Servlet code
    the image appaer on Microsoft Photo Editor , and when i run jsp the image dose not appear on jsp page , so please anyone has an idea about this broblem ,send the soluation or any information to my e-mail [email protected] , and I'll thankful about your help.
    the Servlet and jsp code are below .
    thank for your help
    Servlet:
    import java.io.InputStream;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.PrintWriter;
    import java.io.IOException;
    public class Servlet extends HttpServlet
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    response.setContentType("image/gif");
    int id = Integer.parseInt(request.getParameter("no"));
    // int id = 2 ; when Run Servlet .
    ResultSet rs = null;
    Connection Lcon = null;
    String stmt = " select Image from ImageTable where lmage_id ="+id;
    Statement sm = null;
    String data1 ="";
    try
    Lcon = getConntcion();
    sm = Lcon.createStatement();
    rs = sm.executeQuery(stmt);
    if(rs.next())
    InputStream in = rs.getBinaryStream(1);
    ServletOutputStream sout = response.getOutputStream();
    int c;
    while((c=in.read())!= -1)
    sout.write(c);
    in.close();
    sout.flush();
    sout.close()
    }catch(Exception e)
    System.out.println("error in selectValue the error is "+e);
    finally
    rs .close( );
    sm .close( );
    Lcon.close( );
    public Connection getConntcion()
    Connection con = null;
    try{
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    con = DriverManager.getConnection(",,,,,,,, DB Info ,username and password ,,,,,,,,,,,");
    }catch(Exception e)
    System.out.println("error in connection the error is "+e);
    return con;
    Jsp code :
    <%@ page contentType="text/html"%>
    <html>
    <head
    </head>
    <title> testing image </title>
    <body>
    <form>
    <img src="servlet/Servlet?no=2">
    </form>
    </body>
    </html>

    InputStream in = rs.getBinaryStream(1);
    byte[] image= null;
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    byte[] buffer = new byte[8192];
    int bytesRead = 0;
    while ((bytesRead = in.read(buffer, 0, 8192)) != -1)
         baos.write(buffer, 0, bytesRead);
    image= baos.toByteArray();
    in.close();
    ServletOutputStream sout = response.getOutputStream();
    if (image != null)
           sout.write(image);
           sout.flush();
    }

  • Display scanned image from the image server in the browser in BW Reports...

    Hi All,
    I need to display a scanned image of invoice In BW Reports ,  the information about image ie URL Llink Present in the table TOA01
    u2022
    TOA02
    u2022
    TOA03
    u2022
    TOAHR
    u2022
    TOADL .  I have an idea that we can extract the information from above table to BW and can able to Display the image in WAD Reporting ................
           Can anybody help regarding this .............? 
    Give some idea or material regarding this will be help full ?

    Hi Guru,
      Check the below link, it will be useful for you:
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e0c8bfa4-7348-2c10-b9ae-bc1ff04a9aeb?QuickLink=index&overridelayout=true
    Thanks
    Pawan

  • Display an image from a URL

    Hi,
    I've looked through the Java Swing tutorial and I've searched the forums here, but I haven't figured out how to load an image from a URL into my GUI and display it.
    I don't want the image to be at certain coordinates, as I am using the FlowLayout. My problem is: how do I load an image from a URL, then display it in a JPanel, such as a JScrollPane?
    I'm sorry if I missed any tutorials or similar things about this topic, but if anyone could provide some advice, I would appreciate it.
    Thanks,
    Dan

    try this:
              try {
                   JLabel label = new JLabel(new ImageIcon(new URL("http://developers.sun.com/forums/img/gold.gif")));
                   JScrollPane sp = new JScrollPane(label);
              catch (MalformedURLException x) {
                   x.printStackTrace();
              }

  • Display BLOB Images from a  SQL Server DB

    I am using Crystal Reports X and SQL Server 2000.  I have a table (TABLE_PICS) that contains images (the images are stored in the DB.  I have another table (TABLE_NAMES) where each record references its related image by an ID. 
    What I want to do is create a report where I display each record from TABLE_NAMES with their associated TABLE_PICS images.
    I created a report, and the link is valid, but the report only displays a thumbnail and the name of the image.
    1.  Can someone tell me how I can get the actual images to appear?
    2.  I would prefer the images not be stored in the DB.  Can someone tell me how I can get the images on the report as explained above, without the images being in the DB.
    TIA,
    Jack

    I am using Crystal Reports X and SQL Server 2000.  I have a table (TABLE_PICS) that contains images (the images are stored in the DB.  I have another table (TABLE_NAMES) where each record references its related image by an ID. 
    What I want to do is create a report where I display each record from TABLE_NAMES with their associated TABLE_PICS images.
    I created a report, and the link is valid, but the report only displays a thumbnail and the name of the image.
    1.  Can someone tell me how I can get the actual images to appear?
    2.  I would prefer the images not be stored in the DB.  Can someone tell me how I can get the images on the report as explained above, without the images being in the DB.
    TIA,
    Jack

  • Displaying TIF images from a Servelet?

    Hi All,
    I have a servlet sitting between database of Images (of type bmp, tif, DICOM) and the HTML query interface.
    Baed on the user's input, the servlet queries the database and displays the images. The servelt's code contains
    out.println("<a href=\"javascript:NewWindow(1,'" + url + "','" + fname+"')\"><img src = \"" + url + "\" width = \"100\" height = \"100\" alt = \"" + url+"\" />  </a><br>" + fname + "<br><br>");
    where url is the path to get the image on the disk.
    This works successfully for bmp images but not for tif images. Somebody told me, it does not display tif because IE does not display tif. I would like it to display DICOM images later.
    Any suggestions?

    1. Convert the image to a format that IE understands.
    2. Use a decent browser.

Maybe you are looking for

  • Incorrect characters in material PO text after upgrade

    Hi there, We have just upgraded from 4.6c to ECC 6.0 and have a problem with invalid characters on material PO text. On the material master there is a long text description with the character "-". in ECC 6.0, these have been replaced with the charact

  • Multiple URLs for different sites created on iWeb?

    When I created a second site and went to publish it, the site was given the same URL (web address) as the first site I created. Does iWeb not identify new sites with unique URLs? Essentially my question is does each MobileMe account only support a si

  • What is the most efficient way to use Remove Grain from After Effects on large Premiere Pro project?

    I've tried to use Dynamic Linking both ways but it doesn't the effects don't appear no matter how dramatic I make them. Why couldn't there just be Remove Grain in Premiere Pro so I wouldn't have to go through the headache of figuring this out. I've t

  • LOOP PLAYING ON IPOD NANO

    I WANT TO PRODUCE A 'MUSAC'  PLAYLIST TO LAST APPROX 90 MINUTES BY LOOPING 30 MINUTES WORTH OF TRACKS. HAS ANYONE GOT A SUGGESTION FOR HOW THIS CAN BE CARRIED OUT?

  • Tcode for Open POs

    Hi all, Please tell me the Tcode to search the list of open POs. Thanks in advance Regards, Neetu