surfaceview

Android Development: Combining small tiles/bitmaps into one bitmap

折月煮酒 提交于 2019-12-02 02:00:48
Im trying to get all my small images like grass, water and asphalt and so on, into one bitmap. I have an Array that goes like this: public int Array[]={3, 1, 3, 3, 1, 1, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ,1 ,1, 1, 1 ,1 ,1 ,7 ,7 ,7, 7, 7 ,7, 7 ,7 ,7, 7 ,7 ,7 ,7 ,7, 7 ,7, 7 ,7 ,7 ,7 ,7 ,7 ,7 ,7, 7, 7, 7, 7 ,7 ,7 ,7 ,7 ,7 ,7, 7, 7 ,7 ,7 ,7 ,7 ,7 ,7 ,7 ,7, 7, 7, 7 ,7 ,7, 7 ,6, 6, 6, 6, 6 ,6 ,6, 6, 6 ,6 ,6, 6, 6 ,6, 6, 6 ,6, 6 ,6 ,6 }; So basicly this is a 10*10 Every number is a placeholder for a image(number).png But how do i merge them together? //Simon Okay so the following

Playing video in a GLSurfaceView instead of SurfaceView

只愿长相守 提交于 2019-12-01 21:06:18
问题 I've been struggling with this for 2 days now... Following this answer: https://stackoverflow.com/a/2006454/444324 - it is mentioned that it's possible to play a video in a GLSurfaceView by altering the MediaPlayerDemo_Video example in API Demos: All you have to do there is to replace the SurfaceView with a GLSurfaceView in both the MediaPlayerDemo_Video.java file as well as in the corresponding layout file (mediaplayer_2.xml). Also you need to create a custom Renderer class (one that

How to find the best PixelFormat for an Android SurfaceView

吃可爱长大的小学妹 提交于 2019-12-01 18:18:44
I have found that changing the pixel format in a SurfaceView has a large impact on frame rates. However I can't seem to find a way to select the best format on a per device basis. Example: @Override public void surfaceCreated(final SurfaceHolder holder) { //This line seems to fix speed issue with his res devices holder.setFormat(PixelFormat.RGBA_8888); androidGame.setSurfaceHolder(holder); } This causes my game to run much faster on a Galaxy Nexus (ICS 4.0) but Slow on a Motorola Xoom (3.2.1). If I change to PixelFormat.OPAQUE the situation reverses. The Nexus is slow and the Xoom is now fast.

How to find the best PixelFormat for an Android SurfaceView

丶灬走出姿态 提交于 2019-12-01 17:36:46
问题 I have found that changing the pixel format in a SurfaceView has a large impact on frame rates. However I can't seem to find a way to select the best format on a per device basis. Example: @Override public void surfaceCreated(final SurfaceHolder holder) { //This line seems to fix speed issue with his res devices holder.setFormat(PixelFormat.RGBA_8888); androidGame.setSurfaceHolder(holder); } This causes my game to run much faster on a Galaxy Nexus (ICS 4.0) but Slow on a Motorola Xoom (3.2.1)

How to make a rounded surfaceview

末鹿安然 提交于 2019-12-01 13:35:26
I'm trying to make a rounded shaped surfaceview. I've searched a lot but i couldn't find a good solution. what i'm doing right now is that, I've put the SurfaceView into a FrameLayout, then another View on top of it, either with a PNG mask, or a shape xml drawable. here it is <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/LinearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:layout_width="140dp" android:layout_height="140dp" android:layout

Using the camera in Background Android

ⅰ亾dé卋堺 提交于 2019-12-01 10:45:14
I'm trying to get the picture into service from Camera. @Override public void onCreate() { super.onCreate(); //android.os.Debug.waitForDebugger(); myCamera=Camera.open(); SurfaceView dummy=new SurfaceView(getApplicationContext()); try { if(myCamera!=null) { myCamera.setPreviewDisplay(dummy.getHolder()); myCamera.setPreviewCallback(this); Log.i(TAG,"myCamera is not null"); } getFrames(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); Log.e(TAG, "setPreviewDisplay " + e); } myCamera.startPreview(); } public void getFrames() { new Thread(new Runnable() { public

Take camera screenshot while recording - Like in Galaxy S3?

≯℡__Kan透↙ 提交于 2019-12-01 10:31:47
Im developing a camera app which uses SurfaceView for display. I'm able to take screenshot of the SurfaceView (and save it as a bitmap) with getDrawingCache() (on a layout which wraps the SurfaceView) and also with canvas.drawBitmap(...) however in both ways, the bitmap is always transparent/blank. I have galaxy S3 and I can see that they have that feature in their camera how exactly they do it? thanks! Well after hours, I got a nice solution for that. Maybe it isn't the best way, but it is good enough for me. private long start; private long end; private long period; First get a start time

Android animate character in SurfaceView

旧城冷巷雨未停 提交于 2019-12-01 08:40:25
I want to animate a character (for eg run a dog) on screen. AnimationDrawable seemed a perfect fit for this, and AnimationDrawable requires an ImageView. How do I add and move around the ImageView in SurfaceView? Thanks. You don't need an ImageView . If your animation is an XML Drawable , you can load it directly from the Resources into an AnimationDrawable variable: Resources res = context.getResources(); AnimationDrawable animation = (AnimationDrawable)res.getDrawable(R.drawable.anim); Then set it's bounds and draw on the canvas: animation.setBounds(left, top, right, bottom); animation.draw

DrawerLayout not working with Android 4.4 & SurfaceView

主宰稳场 提交于 2019-12-01 08:17:13
Today I had one of those "android" moments again, which left me absolutely clueless. I have an app which consists of a DrawerLayout, which includes a RelativeLayout as container for a SurfaceView (surfaceViewContainer) and a second ViewGroup (subclass of RelativeLayout) as navigation. When the app starts, in onCreate I inflate the layout and add a SurfaceView to the surfaceViewContainer. On a Samsung S2 with 4.1.2 and a S3 with 4.3 everything works fine, I can see the SurfaceView drawn and I can open and close the drawer, by swipe gesture or home button. Then I tested on Android 4.4 with a

Android animate character in SurfaceView

江枫思渺然 提交于 2019-12-01 07:48:50
问题 I want to animate a character (for eg run a dog) on screen. AnimationDrawable seemed a perfect fit for this, and AnimationDrawable requires an ImageView. How do I add and move around the ImageView in SurfaceView? Thanks. 回答1: You don't need an ImageView . If your animation is an XML Drawable , you can load it directly from the Resources into an AnimationDrawable variable: Resources res = context.getResources(); AnimationDrawable animation = (AnimationDrawable)res.getDrawable(R.drawable.anim);