getPixel setPixel 太慢,.NET CF 上还有其他替代方案吗

发布于 2024-09-07 01:57:59 字数 208 浏览 3 评论 0原文

我正在使用 Bitmap Class' .setPixel 和 .getPixel 在 .NET CF 上绘制位图字体。但它太慢了,在java中我们有 getRGB() 和 setRGB() 来通过一次调用来设置颜色数组。 .NET CF 中有类似的东西吗?我的要求只是将位图的一部分绘制到指定 x,y 处的另一个位图中。

编辑:源图像具有透明度(不是 alpha,只是简单的透明度)。

I'm using Bitmap Class' .setPixel and .getPixel to draw my bitmap fonts on .NET CF. But it is too slow, in java we have getRGB() and setRGB() to set array of colors with a single call. Is there something like that in .NET CF. My requirement is simply to draw a portion of a bitmap into another bitmap at specified x,y.

EDIT: The source image have transparancy (not alpha but just simple transparency).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

往昔成烟 2024-09-14 01:57:59

不要滚动自己的循环。您应该能够使用 ImageAttributes 属性运行 DrawImage 方法,设置正确的颜色键(白色、紫色,无论您在图像中使用什么)。

imageAttributes = new ImageAttributes();
imageAttributes.SetColorKey(Color.Magenta, Color.Magenta);

graphics.DrawImage(image, 
                   destinationRectangle, 
                   sourceRectangle.X, 
                   sourceRectangle.Y, 
                   sourceRectangle.Width, 
                   sourceRectangle.Height, 
                   GraphicsUnit.Pixel, 
                   imageAttributes);

Don't roll your own loop. You should be able to run the DrawImage method with the ImageAttributes attribute, setting the correct color key (white, purple, whatever you use in your image).

imageAttributes = new ImageAttributes();
imageAttributes.SetColorKey(Color.Magenta, Color.Magenta);

graphics.DrawImage(image, 
                   destinationRectangle, 
                   sourceRectangle.X, 
                   sourceRectangle.Y, 
                   sourceRectangle.Width, 
                   sourceRectangle.Height, 
                   GraphicsUnit.Pixel, 
                   imageAttributes);
浅语花开 2024-09-14 01:57:59

不要使用 for 循环执行您自己的“blit”并获取/设置像素!

使用 Graphics.FromImage() 并使用 DrawImage( )

Don't do your own 'blit' with a for loop and get/set pixels!

Use Graphics.FromImage() and draw the other bitmap into it using DrawImage().

逆流 2024-09-14 01:57:59

使用位图、BitBlt 功能。我在此处中展示了一个示例。

Use bitmap, BitBlt functionality. I show an example in here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文