我最近刚刚发现的GDI +不同的构造函数之间的差异。展望:
I have just recently discovered the difference between different constructors in GDI+. Going:
VAR BMP =新位图(宽度,高度,像素格式);
创建一个DDB(设备相关位图),而:
creates a DDB (Device Dependent Bitmap) whereas:
VAR BMP =新位图(someFile);
创建一个DIB(设备无关位图)。这实在不是一般的重要,处理非常大的图像时(其中一个DDB将耗尽内存,并且在取决于机器和显存上的不同大小的内存耗尽)的除外。我需要创建一个DIB而不是DDB,但指定的高度,宽度和像素格式。有谁知道如何做到这一点在DOTNET的。也就是有什么类型的位图(DIB或DDB)是由哪一个位图构造函数创建一个引导?
creates a DIB (Device Independent Bitmap). This is really not usually important, except when handling very large images (where a DDB will run out of memory, and run out of memory at different sizes depending on the machine and its video memory). I need to create a DIB rather than DDB, but specify the height, width and pixelformat. Does anyone know how to do this in DotNet. Also is there a guide to what type of Bitmap (DIB or DDB) is being created by which Bitmap constructor?
这似乎这样做是为了自己分配内存,然后再创建位图的最佳方式:
It appears the best way to do this is to allocate the memory yourself, and then then create the bitmap with:
var bmp = new Bitmap(width, height, stride, format, scan0)
这样,您就可以创造出巨大的位图,而无需内存不足的错误。
This way you can create huge bitmaps without having an out of memory error.