Reputation: 32263
I have a bitmap of 9X11 pixels representing a maze with the path in green, walls in black, start in orange and blue end.
it matrix is:
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 }, };
The problem is that when I draw the bitmap in a ImageView (fill_parent,fill_parent) the result is:
How can I keep the pixels squared?
Note: I create the Bitmap with
Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
and set the pixels with the method
bitmap.setPixel(x,y,Color.XXX);
Upvotes: 2
Views: 1724
Reputation: 1307
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);
Upvotes: 2