C# picturebox 加载图片后透明显示在另一控件之上
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging; namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} public static void ChangeOpacity(PictureBox pb, Single opacity, Control parent)
{
var img = pb.Image;
var bmp = new Bitmap(img.Width, img.Height);
using (var g = Graphics.FromImage(bmp))
{
var colorMatrix = new ColorMatrix();
colorMatrix.Matrix33 = opacity;
var attr = new ImageAttributes();
attr.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
g.DrawImage(img, new Rectangle(, , bmp.Width, bmp.Height), , , img.Width, img.Height, GraphicsUnit.Pixel, attr);
}
pb.BackColor = Color.Transparent;
pb.Image = bmp;
pb.Parent = parent;
pb.Left = ;
pb.Top = ;
} private void Form1_Load(object sender, EventArgs e)
{
ChangeOpacity(pictureBox1, 0.3F, button1);
}
}
}

C# picturebox 加载图片后透明显示在另一控件之上的更多相关文章
- JavaScript-onerror事件:图片加载失败后不显示
HTML: <img src="http://www.mazey.net/images/upload/image/20170518/1495122198180663.gif" ...
- Android之ListView异步加载图片且仅显示可见子项中的图片
折腾了好多天,遇到 N 多让人崩溃无语的问题,不过今天终于有些收获了,这是实验的第一版,有些混乱,下一步进行改造细分,先把代码记录在这儿吧. 网上查了很多资料,发现都千篇一律,抄来抄去,很多细节和完整 ...
- php页面加载完毕后再显示购买按钮
php页面加载完毕后再显示购买按钮 $document.ready(function(){ $("#buybotton").show()})
- WPF加载Winform窗体时 报错:子控件不能为顶级窗体
一.wpf项目中引用WindowsFormsIntegration和System.Windows.Forms 二.Form1.Designer.cs 的 partial class Form1 设置为 ...
- v关于使用Glide加载图片失败时显示自己特定的图片
Glide是Android加载图片的一个框架. 常用加载图片到imageView:Glide.with(this).load(url).into(ImageView imageview). 当加载失败 ...
- js处理img标签加载图片失败,显示默认图片
1.第一种方法: 如果已经引入了jquery插件,就很好办.没有的话,如果实在需要,可以附上代码: script(type='text/javascript', src="http://aj ...
- bootstrap异步加载树后样式显示问题
整个过程: 1.先加载整个页面 2.通过jquery异步请求后台返回数据 3.循环遍历数据,拼接需要的内容 4.把拼接好的数据加载到页面中. 问题: 把拼接好的内容加载到页面后,样式显示不正确.而如果 ...
- 解决问题:swiper动态加载图片后无法滑动
原因:swiper在初始化的时候会扫描swiper-wrapper下面的swiper-slide的个数,从而完成初始化,但是由于动态加载时在初始化之后的动作,所以导致无法滑动. 解决方案 1:在动态获 ...
- 关于iOS UIWebView 加载网页,点击网页内某些控件导致 Application 'UIKitApplication:xxx.xxx.xxx' was killed by jetsam.
问题:公司用的腾讯问卷系统,内嵌在我们应用或游戏的自定义UIWebView里面展示,发现在iOS 10 以下系统,点击圆形勾选框 会大概率出现闪退. 通过联调发现:报了这样一个警告Applicatio ...
随机推荐
- 利用webSocket实现浏览器中多个标签页之间的通信
webSoket用来实现双向通信,客户端和服务端实时通信. webSoket优点和缺点? 优点:对于前端来说,使用简单,功能灵活,如果部署了webSocket服务器,可以实现实时通信. 缺点:需要服务 ...
- 关于MKNetworking自己维护
关于MKNetworking自己维护 个人比较偏向MKNetworking, 因为在小项目里这个网络请求框架可以说是很轻量级.但是里边有一部分功能缺失或者是功能富余, 以及需要优化的地方. 所以决 ...
- 07.Linux系统-Fastdfs分布式文件系统-互为主从配置搭建部署
Fastdfs分布式文件系统-互为主从配置部署 1.安装基础依赖 yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl ...
- 《Java核心技术卷I》——第3章 Java的基本程序设计结构
byte和short类型主要用于特定的应用场合,例如,底层的文件处理或者需要控制占用存储空间量的大数组. 十六进制数值有一个前缀0x(如0xCAFE),八进制有一个前缀0,如010对应八进制中的8.很 ...
- mybatis返回自增主键问题踩坑
1 <insert id="insert" keyProperty="id" useGeneratedKeys="true" par ...
- 高并发-原子性-AtomicInteger
线程不安全: //请求总次数private static int totalCount = 10000;//最大并发数private static int totalCurrency = 100;// ...
- postman(三):详解postman动态变量使用
参考: Variables Dynamic variables
- Java调用Fortran生成so库报“libifport.so.5: 无法打开共享对象文件”错误解决方法
source /opt/intel/bin/compilervars.sh intel64
- springboot自定义错误页
静态错误页放在 动态可以放在freemaker或者thymeleaf 匹配规则: 先找动态页面再找静态页面 先找精确错误页面再找模糊页面 注:精确错误页面=50 ...
- 2019年开发App记录
Pod 制作私有库参考 https://www.jianshu.com/p/f903ecf8e882 Pod私有库的升级 改代码部分,到Example文件夹执行pod install ,修改XXX.s ...