Copy a region from the source image (which must be a PhotoImage) to this image, possibly with pixel zooming and/or subsampling. If no options are specified, this command copies the whole of the source image into this image, starting at coordinates (0, 0). The FROM_C
(self, sourceImage, *, from_coords=None, to=None, shrink=False,
zoom=None, subsample=None, compositingrule=None)
| 4345 | return self.copy(subsample=(x, y), from_coords=from_coords) |
| 4346 | |
| 4347 | def copy_replace(self, sourceImage, *, from_coords=None, to=None, shrink=False, |
| 4348 | zoom=None, subsample=None, compositingrule=None): |
| 4349 | """Copy a region from the source image (which must be a PhotoImage) to |
| 4350 | this image, possibly with pixel zooming and/or subsampling. If no |
| 4351 | options are specified, this command copies the whole of the source |
| 4352 | image into this image, starting at coordinates (0, 0). |
| 4353 | |
| 4354 | The FROM_COORDS option specifies a rectangular sub-region of the |
| 4355 | source image to be copied. It must be a tuple or a list of 1 to 4 |
| 4356 | integers (x1, y1, x2, y2). (x1, y1) and (x2, y2) specify diagonally |
| 4357 | opposite corners of the rectangle. If x2 and y2 are not specified, |
| 4358 | the default value is the bottom-right corner of the source image. |
| 4359 | The pixels copied will include the left and top edges of the |
| 4360 | specified rectangle but not the bottom or right edges. If the |
| 4361 | FROM_COORDS option is not given, the default is the whole source |
| 4362 | image. |
| 4363 | |
| 4364 | The TO option specifies a rectangular sub-region of the destination |
| 4365 | image to be affected. It must be a tuple or a list of 1 to 4 |
| 4366 | integers (x1, y1, x2, y2). (x1, y1) and (x2, y2) specify diagonally |
| 4367 | opposite corners of the rectangle. If x2 and y2 are not specified, |
| 4368 | the default value is (x1,y1) plus the size of the source region |
| 4369 | (after subsampling and zooming, if specified). If x2 and y2 are |
| 4370 | specified, the source region will be replicated if necessary to fill |
| 4371 | the destination region in a tiled fashion. |
| 4372 | |
| 4373 | If SHRINK is true, the size of the destination image should be |
| 4374 | reduced, if necessary, so that the region being copied into is at |
| 4375 | the bottom-right corner of the image. |
| 4376 | |
| 4377 | If SUBSAMPLE or ZOOM are specified, the image is transformed as in |
| 4378 | the subsample() or zoom() methods. The value must be a single |
| 4379 | integer or a pair of integers. |
| 4380 | |
| 4381 | The COMPOSITINGRULE option specifies how transparent pixels in the |
| 4382 | source image are combined with the destination image. When a |
| 4383 | compositing rule of 'overlay' is set, the old contents of the |
| 4384 | destination image are visible, as if the source image were printed |
| 4385 | on a piece of transparent film and placed over the top of the |
| 4386 | destination. When a compositing rule of 'set' is set, the old |
| 4387 | contents of the destination image are discarded and the source image |
| 4388 | is used as-is. The default compositing rule is 'overlay'. |
| 4389 | """ |
| 4390 | options = [] |
| 4391 | if from_coords is not None: |
| 4392 | options.extend(('-from', *from_coords)) |
| 4393 | if to is not None: |
| 4394 | options.extend(('-to', *to)) |
| 4395 | if shrink: |
| 4396 | options.append('-shrink') |
| 4397 | if zoom is not None: |
| 4398 | if not isinstance(zoom, (tuple, list)): |
| 4399 | zoom = (zoom,) |
| 4400 | options.extend(('-zoom', *zoom)) |
| 4401 | if subsample is not None: |
| 4402 | if not isinstance(subsample, (tuple, list)): |
| 4403 | subsample = (subsample,) |
| 4404 | options.extend(('-subsample', *subsample)) |
no test coverage detected