Java 类com.badlogic.gdx.graphics.Pixmap.Filter 实例源码

项目:nvlist    文件:PixmapUtil.java   
/**
 * Converts the given pixmap to the specified target color format. If the source pixmap is already in the
 * correct format, the original pixmap is returned unmodified.
 */
public static Pixmap convert(Pixmap source, Format targetFormat, boolean disposeSource) {
    if (source.getFormat() == targetFormat) {
        return source; // Already the correct format
    }

    int iw = source.getWidth();
    int ih = source.getHeight();
    Pixmap result = newUninitializedPixmap(iw, ih, targetFormat);
    copySubRect(source, Rect.of(0, 0, iw, ih), result, Rect.of(0, 0, iw, ih), Filter.NearestNeighbour);

    if (disposeSource) {
        source.dispose();
    }
    return result;
}
项目:nvlist    文件:PremultFileTextureData.java   
protected Pixmap ensurePot(Pixmap pixmap) {
    if (Gdx.gl20 == null && FileTextureData.copyToPOT) {
        int pixmapWidth = pixmap.getWidth();
        int pixmapHeight = pixmap.getHeight();
        int potWidth = MathUtils.nextPowerOfTwo(pixmapWidth);
        int potHeight = MathUtils.nextPowerOfTwo(pixmapHeight);
        if (pixmapWidth != potWidth || pixmapHeight != potHeight) {
            Pixmap copy = PixmapUtil.resizedCopy(pixmap, Dim.of(potWidth, potHeight), Filter.BiLinear);
            pixmap.dispose();
            return copy;
        }
    }
    return pixmap;
}
项目:nvlist    文件:PixmapUtil.java   
/**
 * Takes a sub-rect {@code srcRect} from {@code src} and copies it to a sub-rect {@code dstRect} in {@code dst}.
 *
 * @param filter Determines which type of interpolation to use if the src/dst rects are a different size.
 */
public static void copySubRect(Pixmap src, Rect srcRect, Pixmap dst, Rect dstRect, Filter filter) {
    Blending oldBlend = dst.getBlending();
    Filter oldFilter = Filter.BiLinear;
    try {
        dst.setBlending(Blending.None);
        dst.setFilter(filter);

        dst.drawPixmap(src, srcRect.x, srcRect.y, srcRect.w, srcRect.h,
                dstRect.x, dstRect.y, dstRect.w, dstRect.h);
    } finally {
        dst.setBlending(oldBlend);
        dst.setFilter(oldFilter);
    }
}
项目:nvlist    文件:PixmapUtil.java   
/**
 * Creates a scaled copy of a pixmap.
 *
 * @see #copy(Pixmap)
 * @see #copySubRect(Pixmap, Rect, Pixmap, Rect, Filter)
 */
public static Pixmap resizedCopy(Pixmap src, Dim dstSize, Filter filter) {
    Pixmap copy = newUninitializedPixmap(dstSize.w, dstSize.h, src.getFormat());
    copySubRect(src, Rect.of(0, 0, src.getWidth(), src.getHeight()), // src rect
            copy, Rect.of(0, 0, dstSize.w, dstSize.h), // dst rect
            filter);
    return copy;
}
项目:nvlist    文件:ImageBlurBenchmark.java   
/** Init libGDX platform and load the pixmap. */
@Setup(Level.Trial)
public void init() {
    HeadlessGdx.init();

    pixmap = new Pixmap(Gdx.files.classpath("img/test.png"));
    pixmap = PixmapUtil.convert(pixmap, Format.RGBA8888, true);
    // Resize to a large standard resolution
    pixmap = PixmapUtil.resizedCopy(pixmap, Dim.of(1920, 1080), Filter.BiLinear);
}
项目:nvlist    文件:ImageBlurBenchmark.java   
private Pixmap doBlur(Pixmap original, int radius) {
    int scale = 2;
    Dim scaledSize = Dim.of(original.getWidth() / scale, original.getHeight() / scale);

    Pixmap blurred = PixmapUtil.resizedCopy(original, scaledSize, Filter.NearestNeighbour);

    ImageBlur imageBlur = new ImageBlur();
    imageBlur.setRadius(radius / scale);
    imageBlur.applyBlur(blurred);

    blurred.dispose();
    return blurred;
}
项目:AChocolate    文件:AUtils.java   
public static Pixmap resize(Pixmap pixmap, float ratio) {
    Pixmap thumb = new Pixmap((int)(pixmap.getWidth() * ratio), (int)(pixmap.getHeight() * ratio), pixmap.getFormat());
    Pixmap.setFilter(Filter.BiLinear);
    thumb.drawPixmap(pixmap, 0, 0, pixmap.getWidth(), pixmap.getHeight(), 0, 0, thumb.getWidth(), thumb.getHeight());

    return thumb;
}
项目:nvlist    文件:ImageResizer.java   
private Pixmap resizedCopy(Pixmap original) {
    Dim originalSize = Dim.of(original.getWidth(), original.getHeight());
    return PixmapUtil.resizedCopy(original, scale(originalSize), Filter.BiLinear);
}
项目:teavm-libgdx    文件:PixmapEmulator.java   
public static void setFilter(@SuppressWarnings("unused") Filter filter) {
}