2011-12-19 3 views
3

나는 splash.png에 그라데이션이 있습니다.RGBA_8888 및 디더를 올바르게 적용하는 방법은 무엇입니까?

public class TestditherActivity extends Activity { 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
} 

    @Override 
    public void onAttachedToWindow() { 
    super.onAttachedToWindow(); 
    getWindow().setFormat(PixelFormat.RGBA_8888); 
    } 
} 

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/LinearLayout01" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:gravity="center" > 

<ImageView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:scaleType="fitXY" 
    android:src="@drawable/test"/> 

</LinearLayout> 

test.xml의 :

<?xml version="1.0" encoding="utf-8"?> 

<bitmap 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:src="@drawable/splash" 
android:antialias="true" 
android:dither="true" /> 

그러나 화면이 이미지는이 질문에 대한

내 간단한 의 .apk

이 구성되어 있습니다 ... 너무 좋지 않아 보인다 splash.png

(210)

결과

enter image description here

어떻게 RGBA_8888디더링 제대로을 적용? 내 실수는 어디 갔지?

다음 코드는 에뮬레이터 나에게 완벽한 결과를 얻을 수 있지만 실제 장치에서 : 이것 좀 봐

public class TestditherActivity extends Activity { 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    getWindow().setFormat(PixelFormat.RGBA_8888); 
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER); 

    BitmapFactory.Options options = new BitmapFactory.Options(); 
    options.inPreferredConfig = Bitmap.Config.ARGB_8888; 
    Bitmap gradient = BitmapFactory.decodeResource(getResources(), R.drawable.splash, options); 

    findViewById(R.id.linear).setBackgroundDrawable(new BitmapDrawable(gradient)); 
} 
} 

main.xml에

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/linear" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"/> 

답변

1

: Awful background image quality in Android
또는 Android의 디더링에 대한 블로그 게시물 : http://android.amberfog.com/?p=247

문제가 비트 맵 XML에 있습니다. 비트 맵에 tileMode가 설정된 경우에만 디더가 작동한다는 것을 기억합니다.

+0

내 코드가 변경되었으며 에뮬레이터에서 결과가 완벽하지만 Galaxy S에서는 여전히 좋지 않습니다. – Sviatoslav

+0

.apk를 장치에 컴파일하면 더 낮은 품질의 이미지를 얻을 수 있습니다. 또는 장치 화면에서 많은 픽셀을 지원하지 않습니다. Android 2.1에서 은하를 사용하는 경우 디더링이 제대로 작동하지 않습니다 (이 문서 : http://www.displaymate.com/Galaxy_S_ShootOut.htm 참조) – Jave

+0

Android 2.3.7 버전의 Galaxy S를 사용하고 있습니다. – Sviatoslav

관련 문제