【问题标题】:Andengine gles2 - weird JPG lookAndengine gles2 - 奇怪的 JPG 外观
【发布时间】:2014-04-09 13:24:34
【问题描述】:

我想从 JPG 加载背景纹理,将其缩小到合适的大小。所以我有 1920x1080 的图片,我将其缩放到 ~800x480。

BitmapTextureAtlas splashTextureAtlas = new BitmapTextureAtlas(this.getTextureManager(), 1920, 1080, TextureOptions.DEFAULT);
        splashTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(splashTextureAtlas, this, "new/splash_bg1.JPG", 0, 0);
        splashTextureAtlas.load();

Sprite splash = new Sprite(0, 0, splashTextureRegion, mEngine.getVertexBufferObjectManager());
        splash.setScale(mainScaleX);

而且效果很差。

原始文件

我在屏幕上看到的

我尝试使用不同的 TextureOption 但没有任何效果。 你能告诉我我做错了什么吗?


更新

即使我保持纵横比质量很差

【问题讨论】:

  • 这不是一个奇怪的问题,它被称为色带,它发生在渐变图像上,你可以使用抖动来解决它,抖动的优点之一是你可以使用具有相同渐变的小(100X100),您可以将它们放大到(1000X1000),并且仍然具有整洁的渐变背景并节省纹理空间。

标签: android opengl-es andengine


【解决方案1】:

默认情况下,出于性能原因禁用抖动。对于遇到非常糟糕的条带的渐变纹理,请尝试将其添加到您的精灵创建中:

Sprite splash = new Sprite(0, 0, splashTextureRegion, mEngine.getVertexBufferObjectManager()) {

    protected void preDraw(GLState pGLState, Camera pCamera) {
        super.preDraw(pGlState, pCamera);
        pGlState.enableDither();
    }

};

【讨论】:

    【解决方案2】:

    问题可能在于您的缩放比例 - 在 1920x1080 时,纵横比为 1.777 - 但在 800x480 时,纵横比为 1.667。

    尝试将图像缩放为 800x450 或 853x480 以保持 1.777 的宽高比 - 如果您确实需要 800x480,则在缩小尺寸后将图像裁剪为这些规格。

    【讨论】:

    • 我刚刚更新了我的问题,我忘了提到它:)
    猜你喜欢
    • 2021-10-11
    • 2013-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多