getChannelSafe method
get the gray value(0-255) at Point(x, y) without exception. channel
is ignored
Implementation
@override
int getChannelSafe(int x, int y, [int? defaultValue, ImageChannel? channel]) {
if (x >= 0 && x < width && y >= 0 && y < height) {
return getChannel(x, y, channel);
} else if (defaultValue == null) {
if (x < 0) x = 0;
if (x > width - 1) x = width - 1;
if (y < 0) y = 0;
if (y > height - 1) y = height - 1;
return getChannel(x, y, channel);
}
return defaultValue;
}