ERROR: In /home/yanghantao/Documents/VTK-8.2.0/IO/Image/vtkImageReader2.cxx, line 595
vtkBMPReader (0xe0f1b0): Initialize: Could not open file /home/yanghantao/Documents/ruxian/000_R.bmp
An inaccessible file may be caused by a multitude of factors.
The usual checklist applies (assuming you are on some Unix-like system):
Do an ls /home/yanghantao/Documents/ruxian/000_R.bmp to test whether it exists or is accessible if any of those directories was mounted from some network share.
Do a cat /home/yanghantao/Documents/ruxian/000_R.bmp to test whether you have at least read access to it.
Do an ls on each directory all the way down to the file to test whether you have the execution flag set properly on each of them.
Open /home/yanghantao/Documents/ruxian/000_R.bmp in another program to rule out file corruption.
TIP: place your code between two ``` so it doesn’t get parsed by the markup parser.
Another quetion about the code Reader->SetDataExtent(0, 2047, 0, 2047, 1, 30); I have already I set the fifth and sixth parameters to be 1 and 30 respectively. Why my console show me Could not open file /home/yanghantao/Documents/ruxian/000_R.bmp. Actually I didn’t let him to read the 000_R.bmp
I suggest you to use a debugger to track down the source of that incorrect string. Your loop starts with 1. So why you’re getting an all-zero path you have to probe your code carefully. I’d certainly avoid those dreaded char *-based C functions like printf and the sort. They are common sources of hard-to-find bugs. Try using modern C++ replacements like: