How to convert to image format to crystal report?

Hi Keith,

Sometime I ask you to help me and you answered so I thanks you,
Now I want to convert a image with "bmp" format. That image i used GDI+ draw and save to "bmp" format then I save that image to "byte[]" format and add to dataset to fill crystal report. But when I show a crystal report that image don't show and I checked on windowform ok.
Please take a look my code. Can you help me to show that image on crystal report

private byte[] DrawImageToReport()

{

System.Drawing.Bitmap pic = new Bitmap(100, 100, System.Drawing.Imaging.PixelFormat.Format32bppRgb);

Graphics gc = Graphics.FromImage(pic);

//Set pen

Pen pen = new Pen(Color.FromArgb(100, 255, 0), 2);

Brush textBrush = new HatchBrush(HatchStyle.DarkVertical, Color.Red);

gc.DrawLine(pen, 70, 80, 100, 80);

//Save line

Stream MemoryStr =new MemoryStream();

pic.Save(MemoryStr,System.Drawing.Imaging.ImageFormat.Bmp);

byte[] bys = new byte[(int)MemoryStr.Length];

BinaryReader br = new BinaryReader(MemoryStr);

bys = br.ReadBytes((int)br.BaseStream.Length);

gc.Dispose();

MemoryStr.Close();

return bys;

}

//Create dataset to Draw image

public void CreateImage(dsImage aDataSetImage)

{

DataRow row= aDataSetImage.Tables[0].NewRow();

row[0] = (byte[])DrawImageToReport();

aDataSetImage.Tables[0].Rows.Clear();

aDataSetImage.Tables[0].Rows.Add(row);

}

private void button2_Click(object sender, EventArgs e)

{

cry = new CrystalReport1();

CreateImage(_ds);

cry.SetDataSource(_ds);

crystalReportViewer1.ReportSource = cry;

}

I look forward to your relay as soon as possible,
Thanks you for supporting,
Start



Answer this question

How to convert to image format to crystal report?

  • byon

    Hello,

    How did you create the report Does the report have the same database schema as this dataset you are creating

    Keith - Business Objects

  • How to convert to image format to crystal report?