这是android studio的imageView,我想将它们的64 * 64像素固定为32 * 32像素和16 * 16像素。
protected void recieveMessage(Message msg) {
super.recieveMessage(msg);
ConnectionData data = (ConnectionData)msg.obj;
switch(data.getCommand()) {
case 'P' :
int[] buf = new int[64*64];
byte[] imb = data.getData();
Bitmap temp = null;
for(int i = 0; i< 64*64; i++) {
buf[i] = 0xff000000 |
(imb[i] & 0xff) << 16 |
(imb[i] & 0xff) << 8 |
(imb[i] & 0xff);
}
temp = Bitmap.createBitmap(buf,64,64,Bitmap.Config.ARGB_8888);
temp = Bitmap.createScaledBitmap(temp, IMAGE_SIZE_X, IMAGE_SIZE_Y, true);
((ImageView) findViewById(R.id.testImageView)).setImageBitmap(temp);
sended = false;
break;
}
}
IMAGE_SIZE_X = 256;
IMAGE_SIZE_Y = 256;