0

this is android studio's imageView and i wanna fix them 64*64 pixel to 32*32 pixel and 16*16 pixel.

    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;

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • you are resizing your bitmap object, shouldn't you be reisizing your imageview instead. – karan Oct 29 '18 at 06:11
  • resizing another imageview to make that? i don't know buf[i] = 0xff000000 what i change –  Oct 29 '18 at 06:25
  • your question is unclear, can you add more detail of what you want. – karan Oct 29 '18 at 06:26
  • then,...i should make that function(64, 32, 16) and make three imageView is that right? and [case = 'P'] should i change it? –  Oct 29 '18 at 06:30
  • i wanna three button and if i push 'A' button it makes show 64*64 pixels image, if i push 'B'button it makes show 16*16 pixels image –  Oct 29 '18 at 06:33
  • then resizing your imageview on particular button click will be a good option, you don't need to resize your bitmap. – karan Oct 29 '18 at 06:37
  • oh, good then now what should i do? if i fix that [64] numbers change to [32] it's not work. –  Oct 29 '18 at 07:21
  • Try using `LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(your_width, your_height); ((ImageView) findViewById(R.id.testImageView)).setLayoutParams(layoutParams);` Use layout params of parent layout of your imageview. – karan Oct 29 '18 at 07:24
  • humm.... if i use that it can not start application. and failed –  Oct 29 '18 at 07:33
  • post your updated code and error log. – karan Oct 29 '18 at 07:34
  • it doesn't error but in smartphone it can not start.. –  Oct 29 '18 at 07:35
  • //temp = Bitmap.createBitmap(buf,64,64,Bitmap.Config.ARGB_8888); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(32, 32); ((ImageView) findViewById(R.id.testImageView)).setLayoutParams(layoutParams);//temp = Bitmap.createScaledBitmap(temp, IMAGE_SIZE_X, IMAGE_SIZE_Y, true); //((ImageView) findViewById(R.id.testImageView)).setImageBitmap(temp); –  Oct 29 '18 at 07:36
  • check your logcat for errors.https://stackoverflow.com/questions/13857560/how-to-find-error-from-logcat-in-android – karan Oct 29 '18 at 07:40
  • not android studio's error... –  Oct 29 '18 at 07:44

0 Answers0