The width is scaled from 1280 to 900 to fit the surface, so I scaled it back up to 1280 (i.e. Like I mentioned, the video is automatically scaled down when rendered into the surface, so what I tried to do was to scale it back up. Using SurfaceView method setScaleX and setScaleY.This didn't work either, because since the width and height are bigger than the screen size, Android doesn't make it 1280x720, but rather the maximum size it can (the screen size), so I ended up having the same result as before. ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) mSurfaceView.getLayoutParams() What I thought here was do setup the surface view with a width and height of 1280 and 720 respectively (a surfaceView grated than the screen itself) and then cropping the surfaceView with setMargins to the size of the screen. So in the end no margins from the video itself were cropped. In the end I ended up with a surface of 520x280 (not even the hole screen is used) and with the full video shrinked to that size. The layout parameter are of the surfaceView itself, so when calling setMargins they are applied to the surfaceView making it smaller: 900 - 190*2 = 520 and 500 - 110*2 = 280. Using SurfaceView method setLayoutParams and pass it a layout with margins:Ĭode snippet ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) mSurfaceView.getLayoutParams().NOTE: In order to make the explanation simpler and make code snippets more understandable, I'm using hard-coded numbers with the resolutions explained above, thou code is actually set up to have different resolutions. This seemed like it would be easy enough to do but I'm actually having trouble getting a solution. What I would actually need, is to crop the black margins from the side and use only the 900x500 images inside. the entire 1280x720 content is caled down to 900x500). With this setup, the full 1280x720 video is scaled down to the 900x500 screen, so the entire content is seen in the screen (i.e. I'm using MediaCodec in order to decode the video stream, and SurfaceView to render the video onto the screen (touch events are also needed). (EDIT: realized a link is created for the attached image, but I'll leave the ascii just in case)) 1280 (I had an image to go here but since its my first post I'm not allowed, I'll draw it with ascii.) I get a video stream (from android auto when a cellphone is connected to the board) of a 1280x720 resolution but with content inside the video of my screen size 900x500.īasically if you see the full video there is a smaller image inside a bigger frame, with black margins on the side of (1280-900)/2 = 190 and (720-500)/2 = 110, like the following image: I have a custom board, with a screen resolution of 900x500 pixels.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |