| 154 | return height_start, height_end, width_start, width_end |
| 155 | |
| 156 | def prepare_view(self, input_image, height_start, height_end, width_start, width_end): |
| 157 | # Iterate over all of the pixels |
| 158 | # Also prepare the debug view of the image (disp_test) |
| 159 | disp_test = "+" |
| 160 | for pixel in range( 0, self.max_width ): |
| 161 | disp_test += "-" |
| 162 | disp_test += "+\n" |
| 163 | |
| 164 | for y in range( 0, self.max_height ): |
| 165 | disp_test += "|" |
| 166 | |
| 167 | # Check if within height range |
| 168 | if not ( y >= height_start and y < height_end ): |
| 169 | disp_test += " " * self.max_width + "|\n|" |
| 170 | continue |
| 171 | |
| 172 | for x in range( 0, self.max_width ): |
| 173 | # Check if within width range |
| 174 | if not ( x >= width_start and x < width_end ): |
| 175 | disp_test += " " |
| 176 | continue |
| 177 | |
| 178 | # Use image value to determine pixel |
| 179 | try: |
| 180 | if input_image.getpixel( (x - width_start, y - height_start) ) == 0: |
| 181 | disp_test += "*" |
| 182 | self.output_image.setpixel( x, y + 1 ) # +1 is due to page boundary |
| 183 | else: |
| 184 | disp_test += " " |
| 185 | except IndexError: |
| 186 | print( (x - width_start,y - height_start) ) |
| 187 | |
| 188 | disp_test += "|\n" |
| 189 | |
| 190 | disp_test += "+" |
| 191 | for pixel in range( 0, self.max_width ): |
| 192 | disp_test += "-" |
| 193 | disp_test += "+\n" |
| 194 | return disp_test |
| 195 | |
| 196 | def prep(self): |
| 197 | image = self.create_and_convert_image() |