English 中文(简体)
添加到资源中
原标题:Add byte[] to resources in wpf c#

我有大约28-30米的3幅标图。 我的运用需要经常从这些图像中获取图象。

目前,我正在编造所有3份档案的比特马塔,锁定这些档案,然后用3份不同的星号阅读所有书目。 如下:

System.Drawing.Imaging.BitmapData bmpData = result.LockBits(new System.Drawing.Rectangle(0, 0, result.Width , result.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite,((System.Drawing.Bitmap)Properties.Resources.bmp1).PixelFormat);
int pixelBytes = System.Drawing.Image.GetPixelFormatSize(((System.Drawing.Bitmap)Properties.Resources.silk_box).PixelFormat) / 8;
System.IntPtr ptr = bmpData.Scan0;
int size = bmpData.Stride * result.Height;
byte[] pixels = new byte[size];
System.Runtime.InteropServices.Marshal.Copy(ptr, pixels, 0, size);

所有3幅标都添加到申请资源中。

问题...... 尽管上述方法正在实行罚款。 唯一的问题是业绩。 它需要大约10-12秒的时间,才能将比图转换成沥青,并使用特定的子。

我的猜测是以下线,需要很多时间:

System.Runtime.InteropServices.Marshal.Copy(ptr, pixels, 0, size);

For the purpose, I am thinking to add the byte[] of all the 3 images to the application resources so that it can be directly accessed and conversion of the images to byte[] will be not required. The performance should increase then.

上述方法是否会被trick弄?

我需要知道,如何将图像推向外,然后添加到应用资源中?

是否还有其他解决办法?

增 编

最佳回答
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签