Silverlight中的像素级2D图形

时间:2023-02-09 09:25:20

I am trying to port a WebForms app to Silverlight, this application is using the GDI Graphics class to draw polygons to a in-memory bitmap, it will then do pixel by pixel comparisons so I need access to the pixel buffer.

我正在尝试将WebForms应用程序移植到Silverlight,这个应用程序使用GDI Graphics类将多边形绘制到内存中的位图,然后它将逐像素地进行比较,因此我需要访问像素缓冲区。

Example:

    Graphics g = Graphics.FromImage(bmp);
    g.FillClosedCurve(brush, points, FillMode.Winding);

I have done some serious googling trying to figure out how to draw polygons and then be able to access the pixel buffer of the canvas surface. My findings indicate that this is not possible with the WPF silverlight graphics, so I need to use a custom graphics library but have only found some 3D libraries. Is there a simple 2D library for silverlight or should I just go a head and write a polygon render algorithm myself?

我做了一些严肃的谷歌搜索,试图找出如何绘制多边形,然后能够访问画布表面的像素缓冲区。我的发现表明这对于WPF silverlight图形是不可能的,所以我需要使用自定义图形库,但只找到了一些3D库。是否有一个简单的Silverlight 2D库,或者我应该自己去写一个多边形渲染算法?

2 个解决方案

#1


If you write a polygon rendering algorithm for Silverlight, it would have to be all managed code, I haven't seen any examples of this, but if you write one let me know, I've been looking for something like the for XNA.

如果你为Silverlight编写一个多边形渲染算法,它必须是所有托管代码,我没有看到任何这样的例子,但如果你写一个让我知道,我一直在寻找类似于XNA的东西。

Silverlight 3 should be adding some of the things you need to make this a lot easier like rendering to a texture and accessing a bitmap at the pixel level.

Silverlight 3应该添加一些你需要的东西,比如渲染纹理和访问像素级别的位图要容易得多。

#2


Could you grab an image from a server and process that? You could dynamically generate the image and you'd have access to whatever you needed outside of Silverlight.

你能从服务器上获取图像并进行处理吗?您可以动态生成图像,并且您可以访问Silverlight之外所需的任何内容。

#1


If you write a polygon rendering algorithm for Silverlight, it would have to be all managed code, I haven't seen any examples of this, but if you write one let me know, I've been looking for something like the for XNA.

如果你为Silverlight编写一个多边形渲染算法,它必须是所有托管代码,我没有看到任何这样的例子,但如果你写一个让我知道,我一直在寻找类似于XNA的东西。

Silverlight 3 should be adding some of the things you need to make this a lot easier like rendering to a texture and accessing a bitmap at the pixel level.

Silverlight 3应该添加一些你需要的东西,比如渲染纹理和访问像素级别的位图要容易得多。

#2


Could you grab an image from a server and process that? You could dynamically generate the image and you'd have access to whatever you needed outside of Silverlight.

你能从服务器上获取图像并进行处理吗?您可以动态生成图像,并且您可以访问Silverlight之外所需的任何内容。