仅指定大小与GDI +和DOTNET创建迪布 [英] Creating a Dib by only specifying the size with GDI+ and DotNet

查看:165
本文介绍了仅指定大小与GDI +和DOTNET创建迪布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近刚刚发现的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.

这篇关于仅指定大小与GDI +和DOTNET创建迪布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆