窗体间传送图片并显示在水晶报表上

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;
        }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值