Skip to content
Loading
.bmp Images Not Displaying
+1
  • Bharathi Raja
    1. Bitmap b = BitmapFactory.decodeByteArray(bitmapProfilePic , 0, bitmapProfilePic .length)  
    2. ivProfilePic.setImageBitmap(Bitmap.createScaledBitmap(b, 120, 120, false));  
    0
  • Hi hemalatha,
     
    I just tested with Image Control and a sample bitmap image in sample asp.net web application. It is displaying the image of extension .bmp.
     
    I think this is not the problem with Image Control. It is supporting .bmp files.
     
    I am attaching sample for your reference.
     
    Thank you.
    +1
    1. Convert Image to Bytes.  
    2.   
    3. public static byte[] ImageToByte2(Image img)  
    4. {  
    5.     byte[] byteArray = new byte[0];  
    6.     using (MemoryStream stream = new MemoryStream())  
    7.     {  
    8.         img.Save(stream, System.Drawing.Imaging.ImageFormat.Png);  
    9.         stream.Close();  
    10.   
    11.         byteArray = stream.ToArray();  
    12.     }  
    13.     return byteArray;  
    14. }  
    15.   
    16. In the code behind use   
    17.   
    18. Convert BMP file to img.  
    19.   
    20. System.Drawing.Image img = null;   
    21. img = System.Drawing.Image.FromFile(Server.MapPath(_ImageUrl));  
    22.   
    23. var imgArr= ImageToByte2(img);  
    24.   
    25. string base64String = Convert.ToBase64String(imgArr= , 0, imgArr= .Length);  
    26. Image1.ImageUrl = "data:image/jpeg;base64," + Convert.ToBase64String(base64String)  
    +2
  • Yogesh Vedpathak
    add this code
    1. protected void Page_Load(object sender, EventArgs e)  
    2. {  
    3. Bitmap bitmapimg = new Bitmap(120, 120, PixelFormat.Format32bppArgb);  
    4. Graphics grph = Graphics.FromImage(bitmapimg);  
    5. SolidBrush br = new SolidBrush(Color.Green);  
    6. grph.FillEllipse(br, 4, 4, 110, 110);  
    7. Response.ContentType = "image/gif";  
    8. bitmapimg.Save(Response.OutputStream, ImageFormat.Gif);  
    9. bitmapimg.Dispose();  
    10. }  
    +2
  • I am sry but system.Drawing.Bitamp doesnt exists ,shown as it is included in system.Drawing name space.Sry if iam wrong
    +2
  • Yogesh Vedpathak
    try this 
    system.Drawing.Bitamp 
    +2
  • even that is not displaying the bmp images
    +2
  • Yogesh Vedpathak
    check namespaces 
    System.Drawing
    +2
  • I am not getting any error its not displaying the image it is showing blank for bmp images
    +2
  • Yogesh Vedpathak
    code is reflect correctly can you please check your image type
    .and which line you get an error
    +2
  • protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    //Image1.ImageUrl = Server.MapPath("~/bin") + "\\Images\\4.bmp";
    }
    }
    protected void Timer1_Tick(object sender, EventArgs e)
    {
    SetImages();
    // Image1.ImageUrl=
    }
    private void SetImages()
    {
    try
    {
    NameValueCollection list = new NameValueCollection();
    list.Add("1", Server.MapPath("~/bin") + "\\Images\\1.bmp");//~/bin/Images/1.bmp");
    list.Add("2", Server.MapPath("~/bin") + "\\Images\\2.jpg");//"~/bin/Images/2.bmp");
    list.Add("3", Server.MapPath("~/bin") + "\\Images\\3.jpg");//"~/bin/Images/3.bmp");
    list.Add("4", Server.MapPath("~/bin") + "\\Images\\4.bmp");//"~/bin/Images/4.bmp");
    list.Add("5", Server.MapPath("~/bin") + "\\Images\\5.bmp");//"~/bin/Images/5.bmp");
    list.Add("6", Server.MapPath("~/bin") + "\\Images\\6.bmp");//"~/bin/Images/5.bmp");
    list.Add("7", Server.MapPath("~/bin") + "\\Images\\7.bmp");//"~/bin/Images/5.bmp");
    Random rad = new Random();
    int i = rad.Next(0, 7);
    Image1.ImageUrl = list[i].ToString();
    }
    catch (Exception)
    {
    throw;
    }
    }
     
    aspx page code I am using ajax timer,update panel
     
    +2
  • Yogesh Vedpathak
    HI Hema we need to see your code first
    +1