Instantiate Bitmap object from unmanaged memory/ Memory Allocation ? [modified]
-
Hi, I'm struggling with the following problem: I have a large unmanaged buffer, allocated with VirtualAlloc for performmance reasons. I use this buffer to load prepared bitmap image data into it. For displaying, I tried to instantiate a bitmap object the following way:
// ButPtrStart points to an offset in my linear, unmanaged buffer. Bitmap bmp = new Bitmap(Width, Height, Width * 4, System.Drawing.Imaging.PixelFormat.Format32bppPArgb, new IntPtr((void*)BufPtrStart.ToPointer());
Usually, as I understood, creating a bitmap this way should not allocate any memory through the GC. But in my tests I found that memory is allocated anyway. Interestingly it isn't the size the bitmap has uncompressed in memory, but it is a significant amount. Does anybody have similar Effects and knows the cause ? Bye, Florian -- modified at 11:45 Wednesday 21st June, 2006