如果我们将Bitmap转换为2D数组,那么维度是多少? [英] What would be the dimensions if we convert the Bitmap to a 2D array?
本文介绍了如果我们将Bitmap转换为2D数组,那么维度是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经编写了一个测试程序并将PNG图像加载到其中,
I have written a test program and loaded a PNG image into it,
https://dotnetfiddle.net/XHwp7o
- 像素格式= 32位颜色
- 位图分辨率,
- 宽度= 512像素
- 高度= 512像素
如果我们将Bitmap转换为2D数组会有什么尺寸?
What would be the dimensions if we convert the Bitmap to a 2D array?
推荐答案
- Stride通常是以字节为单位报告,而非像素。
- 每个像素是4个字节(32位)。
- 这意味着您的偏移或填充将为0(2048字节 - 512 * 4字节) )。
位图的每一行都是512 * 4 = 2018字节,并且会有512行。这意味着只需将1D字节数组的每个连续2048字节复制到2D数组的每一行。
Each row of your bitmap will be 512 * 4 = 2018 bytes, and there will be 512 rows. This means that it is simply a case of copying each sequential 2048 bytes of your 1D byte array into each row of the 2D array.
这篇关于如果我们将Bitmap转换为2D数组,那么维度是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文