Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#,覆盖OnPaint:alpha透明带双缓冲区_C#_Windows Mobile_Compact Framework_Doublebuffered_Onpaint - Fatal编程技术网

C#,覆盖OnPaint:alpha透明带双缓冲区

C#,覆盖OnPaint:alpha透明带双缓冲区,c#,windows-mobile,compact-framework,doublebuffered,onpaint,C#,Windows Mobile,Compact Framework,Doublebuffered,Onpaint,我正在用.Net Compact Framework 2.0 SP2和C#开发一个Windows Mobile 5.0及以上版本的应用程序 我在一个自定义messagebox上重写OnPaint方法,该messagebox绘制一个位图,用alpha透明度填充整个表单,并在半透明背景上覆盖一个渐变框,其中包含一个按钮和一条消息 我正在测试它,但它太慢了,所以我打算使用双缓冲区。我可以使用双缓冲区来绘制渐变框和测试,但是如果我使用带有alpha透明度的背景位图的双缓冲区,它不会绘制alpha透明度。

我正在用.Net Compact Framework 2.0 SP2C#开发一个Windows Mobile 5.0及以上版本的应用程序

我在一个自定义messagebox上重写OnPaint方法,该messagebox绘制一个位图,用alpha透明度填充整个表单,并在半透明背景上覆盖一个渐变框,其中包含一个按钮和一条消息

我正在测试它,但它太慢了,所以我打算使用双缓冲区。我可以使用双缓冲区来绘制渐变框和测试,但是如果我使用带有alpha透明度的背景位图的双缓冲区,它不会绘制alpha透明度。所以我只做了双缓冲梯度框和消息和按钮。bacground透明位图直接绘制在e.Graphics上

我想知道我是否可以保存一个位图上的e.Graphics来完成所有的工作,并将OnPaint方法的绘图结束为e.Graphics这个我以前保存的位图

这是我的代码:

protected override void OnPaint(PaintEventArgs e)
{
    Graphics gxOff;
    gxOff = Graphics.FromImage(bmpOffscreen);

    if (!isOuterBackgroundPainted)
    {
        isOuterBackgroundPainted = true;
        DrawingHelper.DrawAlpha(e.Graphics, outerBackground, 180, 0, 0);
        // Here I don't use double buffer because Alpha Blend doesn't work with double buffer.
        //DrawingHelper.DrawAlpha(gxOff, outerBackground, 180, 0, 0);
    }

    // Draw the gradient box
    GradientFill.Fill(gxOff, rectangle, startColor, endColor, FillDirection.TopToBottom);

    gxOff.DrawString(message, font, brush, textLayoutRectangle);

    e.Graphics.DrawImage(bmpOffscreen, 10, 10);
    base.OnPaint(e);
}
bmpOffscreen:双缓冲区位图

也许我可以在bmpOffscreen中创建一个表单快照,然后在其上绘制半透明背景、渐变框和文本

总结:我想使用带有双缓冲区的alpha混合


有什么建议吗?

确切地说,如何做到这一点其实相当复杂——比这里简单的答案要复杂得多。请看一看源代码。我们有一个双缓冲窗体,我们在背景和控件中使用透明alpha通道进行绘制。

是一种拍摄在Windows Mobile上运行的应用程序快照的方法,无需拍摄标题栏和菜单


这是我正在寻找的开始双缓冲的图片。

我不明白。不保存电子图形(不起作用),保存位图。在指定消息文本时创建它。我已更新我的问题。我想如果我能将图形保存到位图,我会使用双缓冲区。你是否也在做我想做的事情?看看代码。它先画一个背景,然后再画一个透明的图像。如果你想使用透明和双缓冲,这是我知道的唯一的例子。