打印画布以形成 silverlight 图像

发布于 2024-12-29 09:03:12 字数 850 浏览 2 评论 0原文

我已使用 WritebleBitmap 类成功地将画布添加到位图,然后尝试使用位图通过 SaveFileDilogue 将图像保存在客户端系统上。我正在使用 FluxJpegCore 图像编码方法,其中我们使用栅格数组按像素生成图像。 下面是完成这项工作的代码部分。

        byte[][,] raster = new byte[bands][,];

        for (int i = 0; i < bands; i++)
        {
            raster[i] = new byte[width, height];
        }

        for (int row = 0; row < height; row++)
        {
            for (int column = 0; column < width; column++)
            {
                int pixel = bitmap.Pixels[width * row + column];
                raster[0][column, row] = (byte)(pixel >> 16);
                raster[1][column, row] = (byte)(pixel >> 8);
                raster[2][column, row] = (byte)pixel;
            }
        }    

图像保存一切顺利,但是当我缩放图像然后打印它时,代码在“raster[i] = new byte[width, height];”行失败。出现系统内存不足错误。谁能帮我找到这个问题的解决方案?

I have scuccesfully added canvas to bitmap using WritebleBitmap class and then trying to use the bitmap to save image on client system through SaveFileDilogue. I am using the method of FluxJpegCore image encoding where we use raster arrays to generate image pixel-wise.
Below is the part of the code which does the job.

        byte[][,] raster = new byte[bands][,];

        for (int i = 0; i < bands; i++)
        {
            raster[i] = new byte[width, height];
        }

        for (int row = 0; row < height; row++)
        {
            for (int column = 0; column < width; column++)
            {
                int pixel = bitmap.Pixels[width * row + column];
                raster[0][column, row] = (byte)(pixel >> 16);
                raster[1][column, row] = (byte)(pixel >> 8);
                raster[2][column, row] = (byte)pixel;
            }
        }    

All goes fine with image saving, however when i zoom the image and then print it, the code fails at the line "raster[i] = new byte[width, height];". System out of memory error is raised. Can anyone help me to find the solution on this?

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

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

发布评论

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

评论(2

东风软 2025-01-05 09:03:12

我不确定是否有解决方案。您有 3 个数组,每个数组都需要一个连续的 163MB 内存块。问题是进程没有 3 个这样大小的可用地址块。

还要记住,bitmap.Pixels 将是一个 653MB 大的数组。

您唯一真正的希望是使用

  1. 应用程序 OOB,希望虚拟机碎片会受到限制并允许分配如此大的数组。
  2. 如果 FluxJpegCore 可以使用 Stream 而不是字节数组,并且效率很高(您仍然需要做很多工作),
  3. 请升级到 Silverlight 5 并在 64 位浏览器实例中托管您的应用程序。

I'm not sure there is a solution to be had. You have 3 arrays that each need a contiguous 163MB block of memory. The problem will be that the process does not have 3 such address blocks available that are that size.

Bear in mind also that the bitmap.Pixels will be an array 653MB big.

Your only real hope(s) would be to

  1. Use the app OOB, hopefully VM fragmentation would be limited and allow such very large arrays to be allocated.
  2. If FluxJpegCore can use Stream instead of a byte array and does so effeciently (still a lot of work for you to do there)
  3. Move up to Silverlight 5 and host your app in a 64 bit browser instance.
最偏执的依靠 2025-01-05 09:03:12

与@AnthonyWJones 一起,我很确定宽度或高度类似于 double.NAN。确保检查宽度和高度是否为实数。还要检查您的数组在 Silverlight 中是否没有超出可能的范围

Going with @AnthonyWJones I'm pretty sure width or height is something like double.NAN. Make sure you place a check to see is width and height is a real number. Also check that your array does not a lot for more than possible within Silverlight

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