- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用 GDI+ 绘制各种颜色:
brush = new SolidBrush(color);
graphics.FillRectangle(brush, x, y, width, height);
FillRectangle
行为不同于
FillEllipse
:
FillEllipse
with an opaque color 绘制不透明颜色 FillRectangle
使用不透明颜色绘制部分(或完全)透明 CompositingMode Enumeration
The CompositingMode enumeration specifies how rendered colors are combined with background colors. This enumeration is used by the
Graphics::GetCompositingMode
and 'Graphics::SetCompositingMode' methods of the Graphics class.CompositingModeSourceOver
Specifies that when a color is rendered, it is blended with the background color. The blend is determined by the alpha component of the color being rendered.
CompositingModeSourceCopy
Specifies that when a color is rendered, it overwrites the background color. This mode cannot be used along with TextRenderingHintClearTypeGridFit.
CompositingModeSourceCopy
的描述,听起来这不是我想要的选项。从它施加的限制来看,这听起来像是我想要的选择。使用合成或透明度禁用它
不是 我想要的选项,因为它执行
SourceCopy ,而不是
SourceBlend :
graphics
之后对象,我尝试更改合成模式:
graphics = new Graphics(hDC);
graphics.SetCompositingMode(CompositingModeSourceCopy); //CompositingModeSourceCopy = 1
最佳答案
对我来说似乎工作正常。由于缺乏完整的代码示例,我假设您的合成模式错误。
public void RenderGdiPlus()
{
List<string> colors = new List<string>(new string[] { "000000", "ff0000", "00ff00", "0000ff", "ffffff" });
List<string> alphas = new List<string>(new string[] { "00", "01", "40", "80", "c0", "fe", "ff" });
Bitmap bmp = new Bitmap(200, 300, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics graphics = Graphics.FromImage(bmp);
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
SolidBrush backBrush = new SolidBrush(Color.FromArgb(254, 131, 208, 129));
graphics.FillRectangle(backBrush, 0, 0, 300, 300);
graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
Pen pen = new Pen(Color.Gray);
for (int row = 0; row < alphas.Count; row++)
{
string alpha = alphas[row];
for (int column=0; column<colors.Count; column++)
{
string color = "#" + alpha + colors[column];
SolidBrush brush = new SolidBrush(ColorTranslator.FromHtml(color));
graphics.DrawRectangle(pen, 40*column, 40*row, 32, 32);
graphics.FillRectangle(brush, 1+40*column, 1+40*row, 31, 31);
}
}
Graphics gr2 = Graphics.FromHwnd(this.Handle);
gr2.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
gr2.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
gr2.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None;
gr2.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
gr2.DrawImage(bmp, 0, 0);
}
关于Aero:如何在玻璃上绘制纯色(不透明)颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4258295/
我正在尝试更改iOS背景颜色,但是我认为透明度(alpha:1)似乎在起作用并改变了预期的颜色。 In **AppDelegate.m** rootView.backgroundColor = [
https://www.dropbox.com/s/4zkhtdv4yaqhpxy/Screenshot%20from%202015-01-28%2010%3A42%3A02%201.png?dl=0
照明不工作,对象显示为纯色。颜色本身随 Material 或照明参数而变化,但没有阴影或任何纯灰色。 部分代码如下: glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
ppt幻灯片生成时,系统默认是无色背景填充,幻灯片设计需要手动设置背景效果,可设置颜色填充或者图片背景填充。本文将对此介绍具体实现方法。 jar文件导入方法(参考): 步骤1:在java程序中可
我是一名优秀的程序员,十分优秀!