问题描述
我想创建一个Android应用 它显示图像的所有像素,但是当我缩放像素角的颜色与周围的其他像素融合时,我希望像素在其正方形中完美显示其颜色 (如放大时的像素图或ms绘画) 我尝试在画布上绘制矩形并绘制位图1×1 用我想要的颜色,但它融合了
try{
//creating bitmap from other for background
bt2 = Bitmap.createBitmap(bt,i2,i3,i,i);
}
Canvas c=new Canvas(bt2);
c.drawColor(Color.argb(255,255,255));
//creating 1×1 image
Bitmap bt3 = Bitmap.createBitmap(bt,1,1 );
//blue color to draw for pixel looking
Canvas c2 =new Canvas(bt3);
c2.drawColor(Color.argb(255,255));
int w=bt2.getWidth();
int h= bt2.getHeight();
//geting pixels so i would use it
btpixels=new int [w*h];
bt2.getPixels(btpixels,w,h );
int j =0;
Paint paint =new Paint();
for(j=0;j<w;j++)
{
paint.setARGB(255,0);
//drawing blue bitmap on bt2
c.drawBitmap(bt3,j,paint) ;
//paint.setColor( btpixels[j]);
/* c.drawRect(
(float)i-1,(float) i-1,(float)i,paint ); */
}
img.setimageBitmap( bt2 );
}catch(IllegalArgumentException e){ }
解决方法
我了解如何停止像素融合。我在屏幕300ppi上使用2×2图像。如果我想显示每英寸1个像素,则应使用像素位图(此处bt3)宽度为300
最好是
像素正方形的宽度=
屏幕宽度/像素数