winform图片透明移动问题

一人一世界 2017-08-09 09:17:42
winform
在picturebox1设置了图片,上层画出文字,现在要实现移动图片文字不移动,有解决方法吗?
为了实现透明,文字层parent设成了picturebox1
...全文
359 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
cyg17173 2017-08-31
  • 打赏
  • 举报
回复
好贴,占坑。
xuzuning 2017-08-30
  • 打赏
  • 举报
回复
        public Form1()
{
InitializeComponent();
pictureBox1.Load("1.jpg");

using (var p = new GraphicsPath())
{
p.AddString("方案二", new FontFamily("方正琥珀简体"), 1, 32, Point.Empty, new StringFormat());
panel1.Region = new Region(p);
}
一人一世界 2017-08-30
  • 打赏
  • 举报
回复
有没有哪位大神能给解答一下呢?
一人一世界 2017-08-10
  • 打赏
  • 举报
回复
现在我是用了三个picturebox, bottomPictureBox放背景图, textPictureBox放文字, drawPictureBox为画布,笔迹在这上面。
drawPictureBox.BackColor = Color.Transparent;
            textPictureBox.BackColor = Color.Transparent;
            bottomPictureBox.BackColor = Color.Transparent;
            textPictureBox.Parent = bottomPictureBox;
            drawPictureBox.Parent = textPictureBox;
现在要实现拖动bottomPictureBox时上面两层不动。
一人一世界 2017-08-10
  • 打赏
  • 举报
回复
现在帖子不能回复某个人了,只能统一回复了啊?
感谢版主回复,我用Region时总出错,代码如下:
private Region GetRegion(Bitmap bmp)
{
Region res = new Region();
res.MakeEmpty();
var colorTransparent = bmp.GetPixel(0, 0);

var a = Enumerable.Range(0, bmp.Width).ToList();
var b = Enumerable.Range(0, bmp.Height).ToList();
var q = from x in a
from y in b
where bmp.GetPixel(x, y) != colorTransparent
select new Rectangle(x, y, 1, 1);
foreach (var r in q) res.Union(r);
return res;
}

bottomPictureBox.Region = GetRegion(new Bitmap(bottomPictureBox.Image));

出错截图:
xuzuning 2017-08-10
  • 打赏
  • 举报
回复
方法一:文字由 GDI++ 绘出,缺点:不是所有的控件都提供有效的 Graphics 设备(比如视频播放器) 方法二:文字层(容器)用 Region 裁剪出有效区域,放置在背景容器之前,缺点:文字轮廓可能有锯齿
一人一世界 2017-08-09
  • 打赏
  • 举报
回复
两个框是啥意思。。。
EIT王子 2017-08-09
  • 打赏
  • 举报
回复
你是在Picturebox上用GID画的文字?那这个会随着图片移动而移动的。如果你要两个相互独立那就用两个框

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧