This message means that read.bmp expects some byte depth, 4 bytes per integer, in binary format, with each integer being part of the pixel that you can see in this section of the code. The script determines and tests file sizes based on color depth and header definitions.
If you look at this code under the hood of a function:
bytes_pixel=h$depth / 8 row_width_bytes=h$width * bytes_pixel # bmp rows are written to lenth of nearest 4 bytes rounded_row_width_bytes = ceiling(row_width_bytes/4)*4 bytes_to_trim = row_width_bytes %% 4 bytes_to_read=rounded_row_width_bytes * h$height if(h$bmp_bytesz==0) { if(Verbose) warning("invalid byte size information for image") } else if(h$bmp_bytesz != bytes_to_read) stop("mismatch between predicted and actual number of bytes in image")
h$bmp_bytesz=4
The h$ fields are all defined header parameters that set the byte depth from 1L to 4 for various image sizes. In this section, you will see that the file is acting as expected. This is either 8, 24, or 32 bits, because it passed the first warning above this section. He stopped because there was a problem with encoded file sizes.
If the file is correctly formatted and not damaged, with 3x8 channels, it should appear correctly. (or black and white with 1x8 channels)
Try to run:
is.bmp('tiger.bmp') to verify that it is a viable Windows BMP file.
source share