Crystal Reports Does Not Display BLOB Field Correctly in IBlobField Control Using Crystal Reports fo

J

Jeff

Help!!!

The bitmap I am trying to display in a sample Crystal Report is coming
up with much less quality than the original bitmap.

I have a 300x300 dpi bitmap file that I want to insert at run time into
a Crystal Report. The path to the file is stored in a varchar(100)
field in a table in SQL Server.

The Crystal Report displays the bitmap in the IBlobField object but it
is distorted and its resolution is much less than 300x300 dpi.

I created an .xsd file to represent a strongly typed dataset that was
used in order to design the Crystal Report. The column used to
populate the bitmap is of datatype "base64binary". It is also relevant
to note that the size of the IBlobField column that will be used to
display the bitmap has the same size dimension (3 inches wide x 1 inch
height) as the original bitmap.

The following C# code uses the path to the bitmap file, reads it into a
byte array, and then creates a DataTable that will be the source for
the Crystal Report. The properties of the Crystal Report Viewer
control are set in order to display the report.

Here is the code:

private void Form1_Load(object sender, System.EventArgs e)
{
// read bitmap file into Byte Array
String sPhotoFileName;
byte[] PhotoData;
sPhotoFileName = ConfigurationSettings.AppSettings["PhotoFilePath"] +
@"\Photo.BMP";

if (File.Exists(sPhotoFileName) == true)
{
FileStream fs = new
FileStream(sPhotoFileName,FileMode.Open,FileAccess.Read);

BinaryReader r = new BinaryReader(fs);
PhotoData = r.ReadBytes((int)fs.Length);

r.Close();
fs.Close();
}
else
{
PhotoData = null;
}

// create DataTable
DataTable dtEmployees = new DataTable();

dtEmployees.Columns.Add("EmployeeID",typeof(int));
dtEmployees.Columns.Add("LastName",typeof(string));
dtEmployees.Columns.Add("FirstName",typeof(string));
dtEmployees.Columns.Add("Photo",typeof(byte[]));

DataRow dr = dtEmployees.NewRow();

dr["EmployeeID"] = 123;
dr["LastName"] = "Schwartzmann";
dr["FirstName"] = "Jeff";

if (PhotoData != null)
{
dr["Photo"] = PhotoData;
}
else
{
dr["Photo"] = DBNull.Value;
}

dtEmployees.Rows.Add(dr);

// run Crystal Report
String sCrystalReportFileName;

sCrystalReportFileName =
ConfigurationSettings.AppSettings["CrystalFilePath"] +
@"\CrystalReport1.rpt";

ReportDocument oRpt = new ReportDocument();
oRpt.Load(sCrystalReportFileName);
oRpt.SetDataSource(dtEmployees);

crViewer.DisplayGroupTree = false;
crViewer.ReportSource = oRpt;

}


Thanks in advance for your help!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top