android-gpuimage-plus icon indicating copy to clipboard operation
android-gpuimage-plus copied to clipboard

make ImageGLSurfaceview wrap it contnet

Open hoangcongtuan opened this issue 5 years ago • 3 comments

How to make ImageGLSurfaceview wrap it content, i don't want the black space when image ratio not equal to glsurfaceview ratio, i don't want to use DISPLAY_SCALE_TO_FILL or DISPLAY_ASPECT_FILL or using ImageView instead Thanks sorry for my English !!

hoangcongtuan avatar Nov 15 '18 12:11 hoangcongtuan

it is CameraGLSurfaceView, can i using it instead ImageGLSurfaceView

hoangcongtuan avatar Nov 16 '18 02:11 hoangcongtuan

Although it's too late, I've managed to solve this issue by setting a custom measure in ImageGLSufaceView based on the Bitmap measure, as following :

public void initializeView(Bitmap src, int mWidth, int mHeight) {
       mDensity = getResources().getDisplayMetrics().density;
       viewWidth = getResources().getDisplayMetrics().widthPixels;
       viewHeight = getResources().getDisplayMetrics().heightPixels;
       viewRatio = (double) viewHeight / (double) viewWidth;
       bmRatio = (double) (mHeight) / (double) (mWidth);
       if (bmRatio < viewRatio) {
           bmWidth = viewWidth;
           bmHeight = (int) (((double) viewWidth) * ((double) (mHeight) / (double) (mWidth)));
       } else {
           bmHeight = viewHeight;
           bmWidth = (int) (((double) viewHeight) * ((double) (mWidth) / (double) (mHeight)));
       }
       final FrameLayout.LayoutParams lparams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
       lparams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL;
       lparams.width = bmWidth;
       lparams.height = bmHeight;
       imgPhotoEdit.setLayoutParams(lparams);
       imgPhotoEdit.setImageBitmap(src);
   }

and just call it , initializeView(srcBitmap,srcBitmap.getWidth,srcBitmap.getHeight);

Mouadabdelghafouraitali avatar Nov 17 '19 22:11 Mouadabdelghafouraitali