Back to project page Media-Pack.
The source code is released under:
Apache License
If you think the Android project Media-Pack listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
// // INTEL CORPORATION PROPRIETARY INFORMATION // This software is supplied under the terms of a license agreement or // nondisclosure agreement with Intel Corporation and may not be copied // or disclosed except in accordance with the terms of that agreement. // Copyright (c) 2013-2014 Intel Corporation. All Rights Reserved. ////from ww w .j av a 2 s. c o m package com.intel.inde.mp.samples.controls; import android.content.Context; import android.util.AttributeSet; import android.view.SurfaceView; public class TranscodeSurfaceView extends SurfaceView { int widthMeasureSpec; int heightMeasureSpec; int mVideoWidth; int mVideoHeight; public TranscodeSurfaceView(Context context, AttributeSet attrs) { super(context, attrs); } public void setImageSize(int width, int height) { mVideoWidth = width; mVideoHeight = height; } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { this.widthMeasureSpec = widthMeasureSpec; this.heightMeasureSpec = heightMeasureSpec; int width = getDefaultSize(mVideoWidth, widthMeasureSpec); int height = getDefaultSize(mVideoHeight, heightMeasureSpec); if (mVideoWidth > 0 && mVideoHeight > 0) { if (mVideoWidth * height > width * mVideoHeight) { height = width * mVideoHeight / mVideoWidth; } else if (mVideoWidth * height < width * mVideoHeight) { width = height * mVideoWidth / mVideoHeight; } else { } } setMeasuredDimension(width, height); } }