具有像素平方的ImageView(无插值) [英] ImageView with squared pixels (without interpolation)

查看:67
本文介绍了具有像素平方的ImageView(无插值)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个9X11像素的位图,代表一个迷宫,其路径为绿色,黑色的墙壁,橙色和蓝色的末端.

I have a bitmap of 9X11 pixels representing a maze with the path in green, walls in black, start in orange and blue end.

它的矩阵是:

int[][] map = new int[][] { 
            { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, 
            { 0, 0, 1, 0, 0, 0, 0, 0, 1 },
            { 1, 1, 1, 1, 0, 1, 1, 0, 1 }, 
            { 1, 1, 1, 1, 1, 1, 1, 0, 0 },
            { 1, 0, 0, 0, 0, 1, 0, 0, 0 }, 
            { 1, 1, 1, 1, 0, 1, 1, 1, 1 },
            { 1, 1, 1, 1, 0, 1, 0, 0, 1 }, 
            { 1, 1, 1, 1, 0, 1, 0, 0, 1 },
            { 1, 1, 1, 1, 0, 1, 0, 0, 1 }, 
            { 1, 1, 1, 1, 0, 1, 0, 0, 0 },
            { 1, 1, 1, 1, 0, 1, 1, 1, 1 }, };

问题是当我在ImageView(fill_parent,fill_parent)中绘制位图时,结果是:

The problem is that when I draw the bitmap in a ImageView (fill_parent,fill_parent) the result is:

如何使像素保持平方?

注意:我使用

 Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

并使用方法

 bitmap.setPixel(x,y,Color.XXX);

推荐答案

如果要在不使用抗锯齿的情况下缩放图像视图,则真正需要做的是获取BitmapDrawable.示例:

If you want an image view to scale without antialiasing, what you really need to do is get a BitmapDrawable. Example:

BitmapDrawable bd = new BitmapDrawable(activity.getResources(), bitmap);
bd.setAntiAlias(false);

这篇关于具有像素平方的ImageView(无插值)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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