views:

117

answers:

2

I'm trying to write a .bmp in C++ but unsigned char can't hold a value high enough for my needs and other data types add padding because of specific byte alignment that makes a mess of things. So is there an alternative data type that can hold a higher value that won't add padding (or a way to make unsigned char hold a higher value)?

+2  A: 

If you write your data in an array first, there is no padding.

Klaim
+2  A: 

It sounds as if you are misunderstanding how data is stored.

If you have a bmp image in memory it may be kept in an internal structure (struct/class) however you can serialize that to an array of unsigned chars (bytes) which you write to a file. A file opened in binary mode doesn't add anything more than what you write.

see

Anders K.