surfaceview

Android:Crash: Binary XML file line : Error inflating class (using SurfaceView)

萝らか妹 提交于 2019-12-17 20:44:53
问题 I'm having android surfaceView and in that I'm trying to add buttons to this. In the surfaceView canvas I draw something. And I have a thread class to keep drawing. package com.androidsurfaceview; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class androidsurfaceview extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate

add image to surface view in android

僤鯓⒐⒋嵵緔 提交于 2019-12-17 18:44:31
问题 I want to add image to Surface view. So i used below code public class MySurfaceView extends SurfaceView implements SurfaceHolder.Callback{ Bitmap myicon; Canvas canvas; private Paint mBitmapPaint; Paint p= new Paint(); @Override protected void onDraw(Canvas canvas) { Bitmap myicon=BitmapFactory.decodeResource(getResources(),R.drawable.icon); canvas.drawColor(Color.BLACK); canvas.drawBitmap(myicon, 0,0, p); // canvas.drawBitmap(myicon, 0,0, null); // canvas.drawBitmap(myicon, 25,25, null); }

How to resize a bitmap eficiently and with out losing quality in android

倖福魔咒の 提交于 2019-12-17 10:32:43
问题 I have a Bitmap with a size of 320x480 and I need to stretch it on different device screens, I tried using this: Rect dstRect = new Rect(); canvas.getClipBounds(dstRect); canvas.drawBitmap(frameBuffer, null, dstRect, null); it works, the image fills the whole screen like I wanted but the image is pixelated and it looks bad. Then I tried : float scaleWidth = (float) newWidth / width; float scaleHeight = (float) newHeight / height; Matrix matrix = new Matrix(); matrix.postScale(scaleWidth,

Android Multiple SurfaceViews

人盡茶涼 提交于 2019-12-17 08:55:08
问题 I'm trying to work with 3 SurfaceViews on one screen, one on top half (BoardView), one on bottom half (StatusView), and the last one as an extra layer above the top half (TileView) (see main.xml). I created a class MySurfaceView, which is extended by BoardView, StatusView and TileView. I've got multiple problems with this. Let me first give the code. main.xml: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width

Take a screenshot using MediaProjection

五迷三道 提交于 2019-12-17 07:12:50
问题 With the MediaProjection APIs available in Android L it's possible to capture the contents of the main screen (the default display) into a Surface object, which your app can then send across the network I have managed to get the VirtualDisplay working, and my SurfaceView is correctly displaying the content of the screen. What I want to do is to capture a frame displayed in the Surface , and print it to file. I have tried the following, but all I get is a black file: Bitmap bitmap = Bitmap

Understanding Canvas and Surface concepts

人走茶凉 提交于 2019-12-17 06:20:46
问题 I'm struggling to understand the process of drawing to SurfaceView and therefore the whole Surface / Canvas / Bitmap system, which is used in Android. I've read all articles and API documentation pages, which I was able to find on android-developers site, a few tutorials of android graphics, LunarLander source code and this question. Please tell me, which of these statements are true, which are not, and why. Canvas has its own Bitmap attached to it. Surface has its own Canvas attached to it.

Overlay images onto Camera preview SurfaceView

流过昼夜 提交于 2019-12-17 05:37:55
问题 I have a SurfaceView that is being used to draw images, and I would like to overlay them onto a live-feed from the phone's camera. Currently, the SurfaceView that contains the images have a white-background, but if I were to overlay them onto the phone's camera feed, they would have to be transparent. The camera and animation drawing cannot be done on the same SurfaceView . What is the best course to pursue the use of multiple views that involve managing the camera and drawing images? Is it

setDisplayOrientation in Camera make wrong orientation when save image

你离开我真会死。 提交于 2019-12-14 03:13:49
问题 I'm making an OCR app in Android and already installed OCR engine, and now want to create Surfaceview of Camera and have an area box on top to select capture area. I meet the problem with Orientation of surfaceview display: it rotated 90 degree to left: and I overcome with Camera.setDisplayOrientation(90) But, seem to be the bug of camera when I capture image, it rotated 90 degree to left. If I don't use setDisplayOrientation function, the sufaceview is wrong orientation display (landscape)

Flaw in the Lunar Lander example (IllegalThreadStateException)

徘徊边缘 提交于 2019-12-14 01:59:13
问题 I've been playing around with the lunar lander example and have run into a problem while trying to implement an about screen. I changed one of the menu items (in onCreateOptionsMenu) to an "about" option. When this option is selected, a new Activity starts and displays an about screen. @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case MENU_ABOUT: startActivity(new Intent(this, About.class)); return true; //Other cases } return false; } This works

How do I use a matrix to resize a bitmap in SurfaceView?

元气小坏坏 提交于 2019-12-13 20:35:10
问题 I found this bit of code on a similar question, but I can't figure out how to use it. Resizing a Bitmap: public Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) { int width = bm.getWidth(); int height = bm.getHeight(); float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; // create a matrix for the manipulation Matrix matrix = new Matrix(); // resize the bit map matrix.postScale(scaleWidth, scaleHeight); // recreate the new Bitmap