以24位RGB位图填充 [英] Padding in 24-bits rgb bitmap

查看:123
本文介绍了以24位RGB位图填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以向我解释为什么在24位RGB位图文件中我必须添加一个填充,其大小取决于图像的宽度吗?什么用?

could somebody explain to me why in 24-bit rgb bitmap file I have to add a padding which size depends on width of image ? What for ?

我的意思是我必须将此代码添加到我的程序中(在C中):

I mean I must add this code to my program (in C):

 if( read % 4 != 0 ) {
   read = 4 - (read%4);
   printf( "Padding: %d bytes\n", read );
   fread( pixel, read, 1, inFile );
  }

推荐答案

因为24位是奇数个字节(3),并且由于多种原因,所有图像行都必须从一个整数倍的地址开始4个字节.

Because 24 bits is an odd number of bytes (3) and for a variety of reasons all the image rows are required to start at an address which is a multiple of 4 bytes.

这篇关于以24位RGB位图填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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