Sanjay Gupta

Hi,

I want to show in my report dynamic Image through Object data source.  I was set source property for Image 'Extarnel' after runing report showing symbel 'x' instead of Image. But Embedded Image working perfectly OK.
 
I am using June CTP version. Is it possible to show dynamic Image in the report or I am doing somewhare wrong

Thanks in Advance


Re: Visual Studio Report Controls Dynamic Image

Rajeev Karunakaran

Since you are supplying the image via a field, try setting the source to Database.





Re: Visual Studio Report Controls Dynamic Image

Sanjay Gupta

Hi Rajeev,

Thanks for quick responce. I tried setting the source to Database and MIMEtype is image\jpeg but still given red symbol 'x' instead of Image.

I am enclosed my object code. May be I defined something wrong in my code. Please help me where I am wrong.

using System;

using System.Collections.Generic;

using System.Drawing;

public class Merchant

{

private List<Product> m_products;

public Merchant()

{

m_products = new List<Product>();

m_products.Add(new Product("Pen", 25, System.Drawing.Image.FromFile(@"c:\Sunset.jpeg")));

}

public List<Product> GetProducts()

{

return m_products;

}

}

public class Product

{

private string m_name;

private int m_price;

private Image m_RotateField;

public Product(string name, int price, System.Drawing.Image RotateField)

{

m_name = name;

m_price = price;

m_RotateField = RotateField;

}

public string Name

{

get

{

return m_name;

}

}

public int Price

{

get

{

return m_price;

}

}

public Image RotateField

{

get

{

return m_RotateField;

}

}

}





Re: Visual Studio Report Controls Dynamic Image

Rajeev Karunakaran

ReportViewer expects a byte array for images. You are returning an image object. Instead, read the contents of the .jpg file into a byte array and return it.



Re: Visual Studio Report Controls Dynamic Image

NandiniR

can you send me the code to conver the .bmp image into byte array.

Thanks in Advance .





Re: Visual Studio Report Controls Dynamic Image

NandiniR





Re: Visual Studio Report Controls Dynamic Image

eldelo

There's examples of putting images into byte arrays and ergo into reports (etc) all over the net. I don't have any references handy. A minute, perhaps two (tops) will yield what you're looking for...






Re: Visual Studio Report Controls Dynamic Image

Mahoura

Je Crois que c'est ca que tu cherche :

Private Function GetImageData(ByVal FileName As String) As Byte()

Dim Fs As System.IO.FileStream = _

New System.IO.FileStream(FileName, _

System.IO.FileMode.Open, System.IO.FileAccess.Read)

Dim Br As System.IO.BinaryReader = New System.IO.BinaryReader(Fs)

Return (Br.ReadBytes(Convert.ToInt32(Br.BaseStream.Length)))

End Function

Bon courrage