In this paper, the image encryption algorithm combining the image encryption based on S-boxes scrambling with error-correcting codes was developed. The Error-correcting code could effectively improve the security of image encryption algorithm based on S-boxes scrambling. Through analysis of image scrambling effects of a specific example of this algorithm, the safety and anti-shear capacity of it was studied. The analytical method of cryptography was first used in this paper to analyze the security of disordered images; at the same time, an error- correcting code was designed to prevent passive attacks based on bit modification. Experimental results show that the method is safe, efficient and has great ability of error correcting.