Пример #1
0
  /**
   * Scales the Pix to specified x and y scale. If no scaling is required, returns a clone of the
   * source Pix.
   *
   * @param pixs the source Pix
   * @param scaleX x-dimension (width) scaling factor
   * @param scaleY y-dimension (height) scaling factor
   * @return a Pix scaled according to the supplied factors
   */
  public static Pix scale(Pix pixs, float scaleX, float scaleY) {
    if (pixs == null) throw new IllegalArgumentException("Source pix must be non-null");
    if (scaleX <= 0.0f) throw new IllegalArgumentException("X scaling factor must be positive");
    if (scaleY <= 0.0f) throw new IllegalArgumentException("Y scaling factor must be positive");

    long nativePix = nativeScale(pixs.getNativePix(), scaleX, scaleY);

    if (nativePix == 0) throw new RuntimeException("Failed to natively scale pix");

    return new Pix(nativePix);
  }
Пример #2
0
  /**
   * Scales the Pix to the specified scale without sharpening.
   *
   * @param pixs the source Pix (1, 2, 4, 8, 16 and 32 bpp)
   * @param scale scaling factor for both X and Y
   * @return a Pix scaled while maintaining its aspect ratio
   */
  public static Pix scaleWithoutSharpening(Pix pixs, float scale) {
    if (pixs == null) throw new IllegalArgumentException("Source pix must be non-null");
    if (scale <= 0.0f) throw new IllegalArgumentException("Scaling factor must be positive");

    return new Pix(nativeScaleGeneral(pixs.getNativePix(), scale, scale, 0f, 0));
  }