public boolean matches(Format format) {

    if (!super.matches(format)) {
      FormatUtils.traceMatches(this, format, false);
      return false;
    }

    if (!(format instanceof RGBFormat)) {
      final boolean result = true;
      FormatUtils.traceMatches(this, format, result);
      return result;
    }

    final RGBFormat oCast = (RGBFormat) format;

    // do not check lineStride:
    final boolean result =
        FormatUtils.matches(this.bitsPerPixel, oCast.bitsPerPixel)
            && FormatUtils.matches(this.redMask, oCast.redMask)
            && FormatUtils.matches(this.greenMask, oCast.greenMask)
            && FormatUtils.matches(this.blueMask, oCast.blueMask)
            && FormatUtils.matches(this.pixelStride, oCast.pixelStride)
            && FormatUtils.matches(this.flipped, oCast.flipped)
            && FormatUtils.matches(this.endian, oCast.endian);

    FormatUtils.traceMatches(this, format, result);

    return result;
  }