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

这个方法只能保证picturebox仅对其父控件透明
 

C# picturebox 加载图片后透明显示在另一控件之上的更多相关文章

  1. JavaScript-onerror事件:图片加载失败后不显示

    HTML: <img src="http://www.mazey.net/images/upload/image/20170518/1495122198180663.gif" ...

  2. Android之ListView异步加载图片且仅显示可见子项中的图片

    折腾了好多天,遇到 N 多让人崩溃无语的问题,不过今天终于有些收获了,这是实验的第一版,有些混乱,下一步进行改造细分,先把代码记录在这儿吧. 网上查了很多资料,发现都千篇一律,抄来抄去,很多细节和完整 ...

  3. php页面加载完毕后再显示购买按钮

    php页面加载完毕后再显示购买按钮 $document.ready(function(){ $("#buybotton").show()})

  4. WPF加载Winform窗体时 报错:子控件不能为顶级窗体

    一.wpf项目中引用WindowsFormsIntegration和System.Windows.Forms 二.Form1.Designer.cs 的 partial class Form1 设置为 ...

  5. v关于使用Glide加载图片失败时显示自己特定的图片

    Glide是Android加载图片的一个框架. 常用加载图片到imageView:Glide.with(this).load(url).into(ImageView imageview). 当加载失败 ...

  6. js处理img标签加载图片失败,显示默认图片

    1.第一种方法: 如果已经引入了jquery插件,就很好办.没有的话,如果实在需要,可以附上代码: script(type='text/javascript', src="http://aj ...

  7. bootstrap异步加载树后样式显示问题

    整个过程: 1.先加载整个页面 2.通过jquery异步请求后台返回数据 3.循环遍历数据,拼接需要的内容 4.把拼接好的数据加载到页面中. 问题: 把拼接好的内容加载到页面后,样式显示不正确.而如果 ...

  8. 解决问题:swiper动态加载图片后无法滑动

    原因:swiper在初始化的时候会扫描swiper-wrapper下面的swiper-slide的个数,从而完成初始化,但是由于动态加载时在初始化之后的动作,所以导致无法滑动. 解决方案 1:在动态获 ...

  9. 关于iOS UIWebView 加载网页,点击网页内某些控件导致 Application 'UIKitApplication:xxx.xxx.xxx' was killed by jetsam.

    问题:公司用的腾讯问卷系统,内嵌在我们应用或游戏的自定义UIWebView里面展示,发现在iOS 10 以下系统,点击圆形勾选框 会大概率出现闪退. 通过联调发现:报了这样一个警告Applicatio ...

随机推荐

  1. 微信小程序 IView List与Icon结合使用

    wxml <i-cell-group>     <i-cell title="测试" is-link>           <i-icon slot= ...

  2. socket 服务器向指定的客户端发消息

    一.需求 需求如题. 当多个客户端连接服务器时,服务器如何给指定的客户端发送消息. 二.解决方案 核心思想: 在服务器端,需保存不同客户端的socket列表及客户端相关信息. socket含有发送方和 ...

  3. 设计模式开闭原则--java

    静态工厂模式 + 反射控制入参范围 public interface IPrinter { void print(); } public class CanonPrinter implements I ...

  4. 时间戳转换日期格式 - Vue

    日常开发中经常会遇到时间相关的问题,服务端返回的数据都是以时间戳的方式,那么需要将其处理转化为对应的时间格式,具体方式如下: 一.filters 中 formatDate 方法实现 <scrip ...

  5. Decision Trees 决策树

    Decision Trees (DT)是用于分类和回归的非参数监督学习方法. 目标是创建一个模型,通过学习从数据特征推断出的简单决策规则来预测目标变量的值. 例如,在下面的例子中,决策树从数据中学习用 ...

  6. 面试官:SpringBoot jar 可执行原理,知道吗?

    文章篇幅较长,但是包含了SpringBoot 可执行jar包从头到尾的原理,请读者耐心观看.同时文章是基于 SpringBoot-2.1.3进行分析.涉及的知识点主要包括Maven的生命周期以及自定义 ...

  7. Django【第11篇】:Django之分页升级版本(组件)

    分页组件 一.分页的实现与使用 class Pagination(object): """ 自定义分页 """ def __init__(s ...

  8. SSM常用配置文件头模板

    web.xml文件头 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi=&q ...

  9. Python---面向对象---案例

    a = 5print(5/10)# 地板除(功能类似于数学模块当中floor()向下取整操作)print(5//10)print(a%10)b = 25print(b/10)print(b//10)p ...

  10. 【GDOI2016模拟3.9】暴走的图灵机

    题目 分析 我们发现当两个字符串合并时,a0.a1表示左右两个字符串中有多少个T,C表示合并处新增的T的个数,那么 a0=a1 a1=a0+a1+C 令s0和s1表示左右手两个字符串,那么每一次操作后 ...