gpt4 book ai didi

c# - 如何在面板上将图片合二为一

转载 作者:行者123 更新时间:2023-11-30 12:46:46 26 4
gpt4 key购买 nike

我需要将 4 张不同的图像合二为一,它会出现在面板中。面板大小从 180 到 320 不等。我尝试做一个主面板,在她的位置上有 4 个,它们由 anchor 固定...

我有什么(来源四张图片)

enter image description here

我需要得到什么。像这样的面板

enter image description here

我得到了什么

enter image description here

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

这是结果

enter image description here

关于c# - 如何在面板上将图片合二为一,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18823001/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com