Convert asp Image to bitmap RRS feed

  • Question

  • User336760158 posted

    I have a asp image that I want to convert to Bitmap

    <asp:Image runat="server" ID="A3picture" />

    This doesn't work

    Bitmap uploadedImage = new Bitmap(A3picture);

    Any suggestions

    Friday, June 28, 2019 3:39 AM

All replies

  • User665608656 posted

    Hi powderworks,

    According to your description, you can't convert an image control directly into bitmap.

    In your image control, there should be an image URL path to display the image like this:

     <asp:Image ID="A3picture" runat="server"  ImageUrl="~/Cases/Images/logo.png" />

    If you just want to convert the image into BitMap format, I suggest you get the physical path of the image directly and put it in as a parameter like below:

     Bitmap uploadedImage = new Bitmap(@"C:\Users\yongqy\source\repos\CaseProject\WebApplication1\Cases\Images\logo.png");

    You can refer to this link : https://docs.microsoft.com/en-us/dotnet/api/system.drawing.bitmap?view=netframework-4.8

    Best Regards,


    Friday, June 28, 2019 6:40 AM
  • User-1038772411 posted

    Hello powderworks,

    You can get a bitmap of your uploaded image as follows:

    System.Drawing.Bitmap bmpPostedImage = new System.Drawing.Bitmap(userFileUpload.PostedFile.InputStream)

    You then get the stored copy (which hopefully is stored as a byte array and you have an ID to get it), and then convert it to bitmap as follows

    byte[] byteArrayStoredImage = ImageService.GetImageData(imageID);
    MemoryStream imgStream = new MemoryStream(byteArrayStoredImage);
    System.Drawing.Bitmap bmpStoredImage = new Bitmap(imgStream);

    For more details and reference kindly refer the following link



    I hope this will help you .

    Thank you

    Friday, June 28, 2019 6:40 AM
  • User336760158 posted

    Thanks all for coming back to me. See what I can do with your replies

    Tuesday, July 2, 2019 4:10 AM