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 ...
随机推荐
- PAT Basic 1010 一元多项式求导 (25 分)(活用stringstream,昨天学习的)
设计函数求一元多项式的导数.(注:xn(n为整数)的一阶导数为nxn−1.) 输入格式: 以指数递降方式输入多项式非零项系数和指数(绝对值均为不超过 1000 的整数).数字间以空格分隔. ...
- mepg
MPEG(Moving Picture Experts Group,动态图像专家组)
- macos升级Nodejs和Npm到最新版
第一步,先查看本机node.js版本: node -v 第二步,清除node.js的cache: sudo npm cache clean -f 第三步,安装 n 工具,这个工具是专门用来管理node ...
- div 垂直居中的方法
方法一 .table-body>ul>li{ font-size: 0 } .table-body>ul>li:after { content: ''; width: 0; h ...
- python+selenium实现发送一封带附件的邮件
163邮件登录首页 登录成功断言是否有退出按钮 点击退出退出登录 from selenium import webdriver import unittest import time class Vi ...
- C++fread/fwrite的基础用法
前言 fread是吼东西 应某人要求(大概)科普一下 fread #include <iostream> #include <cstdlib> #include <cst ...
- CSS3画菱形和平行四边形以及立方体
利用CSS3中的transform属性画菱形和平行四边形 transform 实现2D或是3D的变形转换,通过transform可以实现对元素的四种变换:旋转.缩放.移动.倾斜 一.菱形 菱形的特点: ...
- POJ 2104 K-th Number ( 求取区间 K 大值 || 主席树 || 离线线段树)
题意 : 给出一个含有 N 个数的序列,然后有 M 次问询,每次问询包含 ( L, R, K ) 要求你给出 L 到 R 这个区间的第 K 大是几 分析 : 求取区间 K 大值是个经典的问题,可以使用 ...
- 关联规则挖掘--Eclat算法
- Leetcode 12. Integer to Roman(打表,水)
12. Integer to Roman Medium Roman numerals are represented by seven different symbols: I, V, X, L, C ...