Compile error with EasyBMP library
I'm trying to write a program that can rotate a given BMP file 180 degrees and create a new BMP file with the rotated image. I'm using the EasyBMP library. However, every time I try to compile, I get these warnings:
EasyBMP Warning: Attempted to access non-existent pixel (359, 236);
Truncating request to fit in the range 开发者_JAVA百科[0,358] x [0,269].
And I get hundreds of these! (The image in question is 359x270) The weird thing is that my code actually works 100%. When I run the program, it does create a rotated image and looks perfect.
If should be
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
color = in(x, y);
*(out(width - x - 1, height - y - 1)) = *color;
}
}
(Note <
instead of <=
and - 1
added).
精彩评论