色带Android解决方案 [英] Color Banding Android Solution

查看:219
本文介绍了色带Android解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是可能的解决方案,以在Android的活动,或在OpenGL带状图像。

What is possible solution to banded images in Android Activity or in OpenGl.

看看下面的答案。

希望它能帮助

推荐答案

彩色条带解决ooooooooooyyyyyyyeaaaaaaaaaa

Color Banding Solved ooooooooooyyyyyyyeaaaaaaaaaa

我分两个阶段解决色带

1)*当我们使用BitmapFactory脱code资源它去codeS在RGB565资源这说明,而不是使用ARGB_8888色带,所以我用BitmapFactory.Options设置去$ C以ARGB_8888 $ C选项

1) * when we use the BitmapFactory to decode resources it decodes the resource in RGB565 which shows color banding, instead of using ARGB_8888, so i used BitmapFactory.Options for setting the decode options to ARGB_8888

第二个问题是

2)这是艰难的部分,并采取了很多的搜索终于摸索 *该方法Bitmap.createScaledBitmap用于缩放的位图也降低了图像RGB565格式缩放我得到带状图像后(旧方法用于解决该用在一个巴的至少一个透明的象素,但没有其他格式像JPG或BMP加工),以便在这里,我创建了一个方法CreateScaledBitmap规模与由此带来的规模位图的原始位图配置(其实我复制从发布者logicnet.dk的方法和翻译在Java)

2) This was the tough part and took a lot of searching and finally worked * the method Bitmap.createScaledBitmap for scaling bitmaps also reduced the images to RGB565 format after scaling i got banded images(the old method for solving this was using at least one transparent pixel in a png but no other format like jpg or bmp worked)so here i created a method CreateScaledBitmap to scale the bitmap with the original bitmaps configurations in the resulting scale bitmap(actually i copied the method from a post by logicnet.dk and translated in java)

    BitmapFactory.Options myOptions = new BitmapFactory.Options();
    myOptions.inDither = true;
    myOptions.inScaled = false;
    myOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;//important
    //myOptions.inDither = false;
    myOptions.inPurgeable = true;
    Bitmap tempImage =  
    BitmapFactory.decodeResource(getResources(),R.drawable.defaultart, myOptions);//important

    //this is important part new scale method created by someone else
    tempImage = CreateScaledBitmap(tempImage,300,300,false);

    ImageView v = (ImageView)findViewById(R.id.imageView1);
    v.setImageBitmap(tempImage);

//功能

public static Bitmap CreateScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter)
{
    Matrix m = new Matrix();
    m.setScale(dstWidth  / (float)src.getWidth(), dstHeight / (float)src.getHeight());
    Bitmap result = Bitmap.createBitmap(dstWidth, dstHeight, src.getConfig());
    Canvas canvas = new Canvas(result);
    //using (var canvas = new Canvas(result))
    {
        Paint paint = new Paint();
        paint.setFilterBitmap(filter);
        canvas.drawBitmap(src, m, paint);
    }
    return result;

}

请纠正我,如果我错了。 如果它的工作对你还有意见。

Please correct me if i am wrong. Also comment if it worked for you.

针对OpenGL您只需绑定应用上的功能后创建的位图

For OpenGl you simply bind the bitmap created after applying upper functions

这篇关于色带Android解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆