加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 如何在面板上将图片合成一张

发布时间:2020-12-15 21:56:17 所属栏目:百科 来源:网络整理
导读:我需要在一个中制作4个不同的图像,它将在面板中.面板尺寸从180到320不等.我试图做一个主面板,在她的位置4,由锚固定… 我有什么(源四图) 我需要得到什么.小组是这样的 我得到了什么 private void Form1_Load(object sender,EventArgs e) { Panel main_panel =
我需要在一个中制作4个不同的图像,它将在面板中.面板尺寸从180到320不等.我试图做一个主面板,在她的位置4,由锚固定…

我有什么(源四图)

我需要得到什么.小组是这样的

我得到了什么

private void Form1_Load(object sender,EventArgs e)
    {
        Panel main_panel = new Panel();
        main_panel.BackColor = Color.Azure;
        Panel panel_top_left = new Panel();
        Panel panel_top_right = new Panel();
        Panel panel_bottom_left = new Panel();
        Panel panel_bottom_right = new Panel();

        Bitmap btm_msg_panel_top_left = new Bitmap(Properties.Resources.blue_t_l);
        panel_top_left.BackgroundImage = btm_msg_panel_top_left;
        Bitmap btm_msg_panel_top_right = new Bitmap(Properties.Resources.blue_t_r);
        panel_top_right.BackgroundImage = btm_msg_panel_top_right;
        Bitmap btm_msg_panel_bottom_left = new Bitmap(Properties.Resources.blue_b_l);
        panel_bottom_left.BackgroundImage = btm_msg_panel_bottom_left;
        Bitmap btm_msg_panel_bottom_right = new Bitmap(Properties.Resources.blue_b_r);
        panel_bottom_right.BackgroundImage = btm_msg_panel_bottom_right;

        main_panel.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom;
        panel_top_left.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
        panel_top_right.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left;
        panel_bottom_left.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
        panel_bottom_right.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

        main_panel.Controls.Add(panel_top_left);
        main_panel.Controls.Add(panel_top_right);
        main_panel.Controls.Add(panel_bottom_left);
        main_panel.Controls.Add(panel_bottom_right);

        panel1.Controls.Add(main_panel);
    }

解决方法

嗯……我会在自己的帖子上回答:))

private void Form1_Load(object sender,EventArgs e)
    {
        Panel panel_top_left = new Panel();
        Panel panel_top_right = new Panel();
        Panel panel_bottom_left = new Panel();
        Panel panel_bottom_right = new Panel();


        Bitmap btm_msg_panel_top_left = new Bitmap(Properties.Resources.blue_t_l);
        panel_top_left.BackgroundImage = btm_msg_panel_top_left;
        Bitmap btm_msg_panel_top_right = new Bitmap(Properties.Resources.blue_t_r);
        panel_top_right.BackgroundImage = btm_msg_panel_top_right;
        Bitmap btm_msg_panel_bottom_left = new Bitmap(Properties.Resources.blue_b_l);
        panel_bottom_left.BackgroundImage = btm_msg_panel_bottom_left;
        Bitmap btm_msg_panel_bottom_right = new Bitmap(Properties.Resources.blue_b_r);
        panel_bottom_right.BackgroundImage = btm_msg_panel_bottom_right;


        panel_top_left.Width = btm_msg_panel_top_left.Width;
        panel_top_right.Width = btm_msg_panel_top_right.Width;
        panel_bottom_left.Height = btm_msg_panel_bottom_left.Height;
        panel_bottom_left.Width = btm_msg_panel_bottom_left.Width;
        panel_bottom_right.Height = btm_msg_panel_bottom_right.Height;
        panel_bottom_right.Width = btm_msg_panel_bottom_right.Width;


        panel_top_right.Location = new Point(panel_top_left.Width - panel_top_right.Width,0);
        panel_bottom_left.Location = new Point(0,panel_top_left.Height - panel_bottom_left.Height);
        panel_bottom_right.Location = new Point(panel_top_left.Width - panel_bottom_right.Width,panel_top_left.Height - panel_bottom_right.Height);


        panel1.Controls.Add(panel_bottom_right);
        panel1.Controls.Add(panel_top_right);
        panel1.Controls.Add(panel_bottom_left);
        panel1.Controls.Add(panel_top_left);
    }

这是结果

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读