- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我知道How to design a cool semi transparent splash screen .
我制作了一个 png 图像并将其设置为 C# 应用程序的表单背景图像。
我已将表单的 BackColor
和 TransparentKey
颜色设置为 Magenta。如果有帮助,我还将 DoubleBuffer
设置为 True。
但是当我运行该应用程序时,表单周围出现了很多噪音。
是否缺少我不知道的东西?
最佳答案
感谢Rui Godinho Lopes (rui@Rui lopes.com) Per Pixel Alpha Blend post,我找到了解决问题的方法在 codeproject.com 上
首先,我将 PerPixelAlphaForm 添加到我的项目中。
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
using System.Runtime.InteropServices;
// class that exposes needed win32 gdi functions.
class Win32
{
public enum Bool
{
False= 0,
True
};
[StructLayout(LayoutKind.Sequential)]
public struct Point
{
public Int32 x;
public Int32 y;
public Point(Int32 x, Int32 y) { this.x= x; this.y= y; }
}
[StructLayout(LayoutKind.Sequential)]
public struct Size {
public Int32 cx;
public Int32 cy;
public Size(Int32 cx, Int32 cy) { this.cx= cx; this.cy= cy; }
}
[StructLayout(LayoutKind.Sequential, Pack=1)]
struct ARGB
{
public byte Blue;
public byte Green;
public byte Red;
public byte Alpha;
}
[StructLayout(LayoutKind.Sequential, Pack=1)]
public struct BLENDFUNCTION
{
public byte BlendOp;
public byte BlendFlags;
public byte SourceConstantAlpha;
public byte AlphaFormat;
}
public const Int32 ULW_COLORKEY = 0x00000001;
public const Int32 ULW_ALPHA = 0x00000002;
public const Int32 ULW_OPAQUE = 0x00000004;
public const byte AC_SRC_OVER = 0x00;
public const byte AC_SRC_ALPHA = 0x01;
[DllImport("user32.dll", ExactSpelling=true, SetLastError=true)]
public static extern Bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref Point pptDst, ref Size psize, IntPtr hdcSrc, ref Point pprSrc, Int32 crKey, ref BLENDFUNCTION pblend, Int32 dwFlags);
[DllImport("user32.dll", ExactSpelling=true, SetLastError=true)]
public static extern IntPtr GetDC(IntPtr hWnd);
[DllImport("user32.dll", ExactSpelling=true)]
public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
[DllImport("gdi32.dll", ExactSpelling=true, SetLastError=true)]
public static extern IntPtr CreateCompatibleDC(IntPtr hDC);
[DllImport("gdi32.dll", ExactSpelling=true, SetLastError=true)]
public static extern Bool DeleteDC(IntPtr hdc);
[DllImport("gdi32.dll", ExactSpelling=true)]
public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject);
[DllImport("gdi32.dll", ExactSpelling=true, SetLastError=true)]
public static extern Bool DeleteObject(IntPtr hObject);
}
/// <para>Your PerPixel form should inherit this class</para>
/// <author><name>Rui Godinho Lopes</name><email>rui@ruilopes.com</email></author>
public class PerPixelAlphaForm : Form
{
public PerPixelAlphaForm()
{
// This form should not have a border or else Windows will clip it.
FormBorderStyle = FormBorderStyle.None;
}
/// <para>Changes the current bitmap.</para>
public void SetBitmap(Bitmap bitmap)
{
SetBitmap(bitmap, 255);
}
/// <para>Changes the current bitmap with a custom opacity level. Here is where all happens!</para>
public void SetBitmap(Bitmap bitmap, byte opacity)
{
if (bitmap.PixelFormat != PixelFormat.Format32bppArgb)
throw new ApplicationException("The bitmap must be 32ppp with alpha-channel.");
// The ideia of this is very simple,
// 1. Create a compatible DC with screen;
// 2. Select the bitmap with 32bpp with alpha-channel in the compatible DC;
// 3. Call the UpdateLayeredWindow.
IntPtr screenDc = Win32.GetDC(IntPtr.Zero);
IntPtr memDc = Win32.CreateCompatibleDC(screenDc);
IntPtr hBitmap = IntPtr.Zero;
IntPtr oldBitmap = IntPtr.Zero;
try {
hBitmap = bitmap.GetHbitmap(Color.FromArgb(0)); // grab a GDI handle from this GDI+ bitmap
oldBitmap = Win32.SelectObject(memDc, hBitmap);
Win32.Size size = new Win32.Size(bitmap.Width, bitmap.Height);
Win32.Point pointSource = new Win32.Point(0, 0);
Win32.Point topPos = new Win32.Point(Left, Top);
Win32.BLENDFUNCTION blend = new Win32.BLENDFUNCTION();
blend.BlendOp = Win32.AC_SRC_OVER;
blend.BlendFlags = 0;
blend.SourceConstantAlpha = opacity;
blend.AlphaFormat = Win32.AC_SRC_ALPHA;
Win32.UpdateLayeredWindow(Handle, screenDc, ref topPos, ref size, memDc, ref pointSource, 0, ref blend, Win32.ULW_ALPHA);
}
finally {
Win32.ReleaseDC(IntPtr.Zero, screenDc);
if (hBitmap != IntPtr.Zero) {
Win32.SelectObject(memDc, oldBitmap);
//Windows.DeleteObject(hBitmap); // The documentation says that we have to use the Windows.DeleteObject... but since there is no such method I use the normal DeleteObject from Win32 GDI and it's working fine without any resource leak.
Win32.DeleteObject(hBitmap);
}
Win32.DeleteDC(memDc);
}
}
protected override CreateParams CreateParams
{
get {
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x00080000; // This form has to have the WS_EX_LAYERED extended style
return cp;
}
}
}
然后我像这样更改了启动画面代码
namespace MoballeghanPro.Client
{
public partial class frmSplashScreen : PerPixelAlphaForm
{
public frmSplashScreen()
{
InitializeComponent();
}
private void frmSplashScreen_Load(object sender, EventArgs e)
{
SetBitmap(Properties.Resources.IntroMobaleghan); //Png picture in the resources
}
}
}
现在表格显示的很完美
这是我使用的代码的许可证:
// Copyright © 2002-2004 Rui Godinho Lopes <rui@ruilopes.com>
// All rights reserved.
//
// This source file(s) may be redistributed unmodified by any means
// PROVIDING they are not sold for profit without the authors expressed
// written consent, and providing that this notice and the authors name
// and all copyright notices remain intact.
//
// Any use of the software in source or binary forms, with or without
// modification, must include, in the user documentation ("About" box and
// printed documentation) and internal comments to the code, notices to
// the end user as follows:
//
// "Portions Copyright © 2002-2004 Rui Godinho Lopes"
//
// An email letting me know that you are using it would be nice as well.
// That's not much to ask considering the amount of work that went into
// this.
//
// THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED. USE IT AT YOUT OWN RISK. THE AUTHOR ACCEPTS NO
// LIABILITY FOR ANY DATA DAMAGE/LOSS THAT THIS PRODUCT MAY CAUSE.
关于c# - 创建没有任何噪音的透明启动画面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37453743/
我有一个表,用于测量数据集中两个不同值的分布百分比(我有一个计数,替换为 Percentage )。我只想在仪表板中发布 85% 的值。这样做的步骤是什么? .现在,如果我过滤掉 NO 值, YES
我想平均N通过Type对于 Inst 的值 我的数据设置为: Type, Inst, N A, A1, 4 A, A1, 13 A, A1, 13 A, A2, 4 A, A3, 5 B, B1, 4
当我使用 Node 的 http2 库(仅支持 HTTPS,不支持 HTTP)进行开发时,当我在 Chrome 中打开 localhost 时,我会看到一个警告屏幕: Your connection
我想创建一个具有响应式布局的导航栏菜单。当网站显示在显示器上时,我想播放导航栏。当网站在手机上显示时,我会显示最终显示导航栏的菜单图标。 我该怎么做? 最佳答案 试试这个,在移动设备上,导航栏不仅会显
我聘请了一名程序员为我创建一个 iPhone 应用程序。该应用程序的目的是拍照并将其上传到服务器。我们想制作一个特殊用途的屏幕,以便在上传照片之前查看照片。这个专门开发的屏幕将具有至关重要的缩放功能。
我在 Tableau 上有一个我无法解决的简单问题。 我想显示一个图表,显示随时间变化的度量。我想将用户通过参数选择的一个客户端与未选择的所有其他客户端进行比较。该图将显示具有 2 种不同颜色的两条线
我使用 Python 脚本从 3 个不同的 RDS 执行一系列复杂查询,然后将数据导出到一个 CSV 文件中。我现在正在尝试找到一种方法,每周将使用这些数据的仪表板自动发布到 Tableau 服务器中
我在工作中使用 tableau 来处理各种数据类型,包括敏感的个人数据,这些数据只能以聚合格式共享。我试图找到一种方法来保护私有(private)信息,方法是在单元格值小于 5 时隐藏它。这样,当用户
我最近开始在网站上嵌入 Tableau 可视化效果,并遇到了在浏览器中直接使用 Control + P 打印它们的问题。大多数完全扭曲,如果有的话。我做了一些挖掘,发现这是一个已知问题: http:/
例如,此 URL 包含十几个项目:https://tableautest.domain.uk/t/CustomerSharing/view/projects 在每个项目中都有几个工作簿。每个工作簿中都
我正在研究如何使用 Tableau 连接到 Cloudera Hadoop。我提供服务器和端口详细信息并使用“Impala”进行连接。我能够成功连接,选择默认模式并选择所需的表。 在此之后,当我将维度
我正在尝试将 Tableau 工作表嵌入到我的 ReactJS 应用程序中。我有一个包含报告名称列表的菜单(在 react 中),当单击菜单项时,它会更新包含报告名称的状态。我决定使用 tableau
我有以下问题!我有一个这样的表: Data Source 我想创建一个可以获取 apl_id 的字段(我想这是一个字段),有一些我想要的 service_offered。 上表中的示例。如果我想要只有
我有一个航类延误数据电子表格,我正在处理一个显示每个机场总延误时间的工作表。我想过滤维度“机场”,即根据每个机场的起飞次数创建机场类别,“小型”、“中型”和“大型”,这是通过计算维度“航类号”计算得出
我想创建一个带有过滤器的表格,用于选择和比较事物: 假设我有一个变量 Var,包含值 A、B、C、D、E。我想要一个过滤器,以便用户可以选择 A B C D 之一,同时 E 始终被选中。这样选中的E和
我是一名优秀的程序员,十分优秀!