我想将数据从Bitmap复制到int[]using getPixels(),这是我目前的代码:
int[] pixels = new int[myBitmap.getHeight() * myBitmap.getWidth()];
myBitmap.getPixels(pixels, 0, myBitmap.getWidth(), 0, 0,
myBitmap.getHeight(), myBitmap.getWidth());
for(int i = 0; i < myBitmap.getHeight() * myBitmap.getWidth(); i++) {
Log.e(TAG, "pixel"+i+"" +pixels[i]);
}
Run Code Online (Sandbox Code Playgroud)
但这是一个例外:
05-04 20:24:08.281: ERROR/AndroidRuntime(5700): Uncaught handler: thread main exiting due to uncaught exception
05-04 20:24:08.296: ERROR/AndroidRuntime(5700): java.lang.IllegalArgumentException: y + height must be <= bitmap.height()
05-04 20:24:08.296: ERROR/AndroidRuntime(5700): at android.graphics.Bitmap.checkPixelsAccess(Bitmap.java:818)
05-04 20:24:08.296: ERROR/AndroidRuntime(5700): at android.graphics.Bitmap.getPixels(Bitmap.java:771)
05-04 20:24:08.296: ERROR/AndroidRuntime(5700): at com.tecmark.Jjilapp$TouchView.onDraw(Jjilapp.java:206)
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?我刚刚将y参数指定为0.
我需要在android中获取我的活动的VideoView的高度,我使用以下命令,但它给了我高度为0.
VideoView vv = (VideoView)findViewById(R.id.video1);
String surl="SOME_LINK.mp4";
Uri uri=Uri.parse(surl);
MediaController mc = new MediaController(this);
vv.setVideoURI(uri);
vv.setMediaController(mc);
mc.setMediaPlayer(vv);
mc.setAnchorView(vv);
int vvHeight=vv.getMeasuredHeight();
Log.d("VideoView Height:",vvHeight+""); // The Logcat output : 0.
int VVheight=vv.getHeight();
Log.d("The Height of VideoView is :",VVheight+""); // The Logcat output : 0
Run Code Online (Sandbox Code Playgroud)
有人能告诉我我犯了什么错误.