amespace CrystalReport2---A窗体
{
public partial class Mainform : Form
{
public Mainform()
{
InitializeComponent();
}
private void btnBroswer_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "*.jpg,*.jpeg,*.bmp|*.jpg;*.jpeg;*.bmp";
openFileDialog1.ShowDialog();
Image myImage = System.Drawing.Image.FromFile(openFileDialog1.FileName);
this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
this.pictureBox1.Image = myImage;
}
private void btnPrint_Click(object sender, EventArgs e)
{
Form1 f = new Form1();
f.Img = this.pictureBox1.Image;
f.ShowDialog();
//this.pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage;
//this.pictureBox2.Image = this.pictureBox1.Image;
}
B窗体
private Image img;
public Image Img
{
get { return img; }
set { img = value; }
}
private void Form1_Load(object sender, EventArgs e)
{
this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
this.pictureBox1.Image = img;
byte[] bmpBytes;
Bitmap bt = new Bitmap(img);
using (MemoryStream ms = new MemoryStream())
{
bt.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
ms.Flush();
bmpBytes = ms.ToArray();
}
this.textBox1.Text = "wuwei";
DynamicImage di = new DynamicImage();
FileStream fs = new FileStream(@"D:/Images/1.jpg", FileMode.Open, FileAccess.Read);
BinaryReader br1 = new BinaryReader(fs);
byte[] byte1 = br1.ReadBytes((int)fs.Length);
FileStream fs1 = new FileStream(@"D:/Images/MTI_LOGO.BMP", FileMode.Open, FileAccess.Read);
BinaryReader br2 = new BinaryReader(fs1);
byte[] byte2 = br2.ReadBytes((int)fs1.Length);
FileStream fs3 = new FileStream(@"D:/Images/1.jpg", FileMode.Open, FileAccess.Read);
BinaryReader br3 = new BinaryReader(fs3);
byte[] byte3 = br3.ReadBytes((int)fs3.Length);
FileStream fs4 = new FileStream(@"D:/Images/MTI_LOGO.BMP", FileMode.Open, FileAccess.Read);
BinaryReader br4 = new BinaryReader(fs4);
byte[] byte4 = br4.ReadBytes((int)fs4.Length);
FileStream fs5 = new FileStream(@"D:/Images/MTI_LOGO.BMP", FileMode.Open, FileAccess.Read);
BinaryReader br5 = new BinaryReader(fs5);
byte[] byte5 = br5.ReadBytes((int)fs5.Length);
fs = null;
fs1 = null;
//di.Images.AddImagesRow(byte1, byte2, "heihei");
di.Info.AddInfoRow("Patient ID:" + "112", "Exam Date:" + "2010-7-21", "Patient Name:" + "wuwei", "Birth Date:" + "1989-02-05", "Sex:" + "male", "Primary Physician:" + "he", "Ordering Physician:" + "haha", "Examiner:" + "xixi", "Physician:" + "wuwu", bmpBytes);
di.Images.AddImagesRow(byte1, byte2, byte3, byte4, "Patient Name:" + textBox1.Text, "Size:" + "15mm*17mm", "Size:" + "6", "Shape:" + "Multiple Peaks", "Notes:" + "rib");
di.Images.AddImagesRow(byte1, byte3, byte2, byte4, "Patient Name:" + textBox1.Text, "Size:" + "15mm*17mm", "Shape:" + "6", "Shape:" + "One Peak", "Notes:" + "rib");
CrystalReport1 crt = new CrystalReport1();
//((TextObject)crt.ReportDefinition.ReportObjects["Images"]).Text = "hello World";
textBox1.Text = crt.Section3.ReportObjects.Count.ToString();
crt.SetDataSource(di);
crystalReportViewer1.ReportSource = crt;
}