Clip the video to fullly fill the screen in Android Auto - android-auto

Now, I am developing our own Android Auto Project. I encountered an issue.
I added 3 supported VideoConfiguration. (1920 X 1080, 1280 X 720, 800 X 480)
Our in-car screen's size is 1920 X 720.
After I started my app in car, I noticed the cellphone informed us which the video output from the cellphone(or MD) was 1920 X 1080. I also set the view area as 1920 X 720, or in another way, the content area was 1920 X 720.
Finally, the projectional video was shown, but unfortunately, the video was stretched forcefully. All of those icons, texts were out of shape, as if my configuration was useless.
My question is, how can I adjust my parameters so that the projectional contents from MD can be shown properly.
I asked google's service desk, they told me to set the margin on top and bottom 180 respectively.
But I tried, as below,
VideoFrameRateType frameRate = (fps == 30) ? VideoFrameRateType.VIDEO_FPS_30 : VideoFrameRateType.VIDEO_FPS_60;
Protos.Insets.Builder insetsBuilder = Protos.Insets.newBuilder().setTop(180).setBottom(180);
UiConfig.Builder uiBuilder = UiConfig.newBuilder().setMargins(insetsBuilder);
VideoConfiguration.Builder builder = VideoConfiguration.newBuilder()
// .setUiConfig(uiBuilder)
.setCodecResolution(codecResolution)
.setFrameRate(frameRate)
.setWidthMargin(0)
.setHeightMargin(360)
.setDensity(213)
.setRealDensity(170)
.setVideoCodecType(MediaCodecType.MEDIA_CODEC_VIDEO_H264_BP)
.setDecoderAdditionalDepth(decoderAdditionalDepth)
.setViewingDistance(viewingDistance)
.setPixelAspectRatioE4(Math.round(pixelAspectRatio * 1e4f));
I tried to set heightMargin, or add UiConfig's setTop(180).setBottom(180), nothing could sort the problem out.
Or, is there anything I can do we I create MediaFormat format = MediaFormat.createVideoFormat programmatically?

I think I have already wrapped things up by myself.
First, we need to adjust our layout attributes, from match_parent to 1920px & 1080px.
Second, before we create a VedioConfiguration, we should new UiConfig and set its top & bottom to match your content area.

Related

How to add missing borders to FMX controls?

I'm currently designing an FMX app with C++Builder. For some reason, when the app is built and launched (it looks normal in the editor), the upper and left border of TComboEdits are missing. Same for the right border of grids. This is quite unpleasant to the eye, how to change that?
Here is the design-time settings for one of the TComboEdits:
object SearchLotComboEdit: TComboEdit
Touch.InteractiveGestures = [LongTap, DoubleTap]
TabOrder = 2
ItemHeight = 19.000000000000000000
ItemIndex = -1
Position.X = 72.000000000000000000
Position.Y = 40.000000000000000000
Size.Width = 361.000000000000000000
Size.Height = 26.000000000000000000
Size.PlatformDefault = False
OnChange = SearchLotComboEditChange
OnTyping = SearchLotComboEditTyping
OnKeyDown = SearchLotComboEditKeyDown
I added pictures of what it looks like:
I have the same problem om my computer.
The problem is due to the fact that FMX does not paint some controls (e.g. Listbox misses right border) correctly when your Windows scaling isn't configured at 100%.
It probably depends on your screen resolution as well.
Try 100%, 125% or 150% scaling and observe if there are any differences.

Unity windowed mode size is different on different screen resolutions

So I want the window size in the build to be of a certain size and it works great when displayed on 1920 x 1080 screen resolution, anything more or less than that, and the window becomes too big or too small. Is there any way for the window to be of the same window to screen size resolution?
I have used the following settings:
My build settings
Afaik you can set the resolution depending on the Display screen size using Screen.currentResolution and Screen.SetResolution somewhat like e.g.
public class ScreenSizeController : MonoBehaviour
{
// how much space (percentage) of the screen should your window fill
[Range(0f,1f)]
public float fillX;
[Range(0f,1f)]
public float fillY;
private void Awake()
{
// Get actual display resolution
var res = Screen.currentResolution;
// calculate target resolution using the fill
var targetX = fillX * res.width;
var targetY = fillY * res.height;
// Set player resolution
Screen.SetResolution(targetX, targetY, false);
}
}
Note: Typed on smartphone but I hope the idea gets clear
Wouldn't changing the screen width/height in the resolution and presentation menu to 1920 x 1080 fix it

Frame animation from outside screen and translateto inside screen

I'm new to animation with Xamarin Forms, I have a frame that I need to place it outside the screen like this:
The small frame is outside the device's screen
The small frame now inside the device screen
My problem is I need to know how I can place the frame like that (outside the screen) from the start, and how to know the width and the height of every device so I can use the TranslateTo() method to translate the frame to the exact same position for every device.
Thanks in advance
You can try this from your .cs page
Application.Current.MainPage.Width
Application.Current.MainPage.Height
You can use Xamarin.Essentials NuGet pakage to achieve this. And there is a useful class DeviceDisplay in there that should be helpful for you.
The documentation can be found here.
Usage example:
// Get Metrics
var mainDisplayInfo = DeviceDisplay.MainDisplayInfo;
// Orientation (Landscape, Portrait, Square, Unknown)
var orientation = mainDisplayInfo.Orientation;
// Rotation (0, 90, 180, 270)
var rotation = mainDisplayInfo.Rotation;
// Width (in pixels)
var width = mainDisplayInfo.Width;
// Height (in pixels)
var height = mainDisplayInfo.Height;
// Screen density
var density = mainDisplayInfo.Density;

Wrong map center in iOS using nativescript-google-maps-sdk

In iOS when I put marker and mapView location, the map does not display centered, but if I move the phone to landscape and rotate again to portrait the map center displays fine.
In Android works fine.
You can get more information in this GitHub issue:
https://github.com/dapriett/nativescript-google-maps-sdk/issues/322
I have personally faced this and discovered that it's basically a layout problem on iOS. The height and width attribute values supplied to the MapView's XML element are somewhat differently treated by iOS. The solution to our problem, as described in the question itself is resizing the map on runtime (as rotating the screen makes it go through a resizing routine). Applying this absurd logic at the beginning of the map render, solves the problem.
This is how I did it:
Provide the width value of the MapView in XML:
<maps:mapView width="100%" mapReady="onMapReady" />
and set the height of the map inside onMapReady method, with a 100 millisecond delay.
/* if you want to set height in DIP */
setTimeout(() => this.mapView.height = 500, 100);
or if you want to set height in percentage
/* [0.85 means 85% here] */
setTimeout(() => this.mapView.height = {
unit: '%',
value: 0.85
}, 100);
100 millisecond delay makes it go through the resize effect. Tested on iOS 12.1

CopySubresourceRegion incorrectly reports an error about the size of the source box?

I have a source ID3D11Texture2D of size 2560x1440 (from a screenshot), a quarter of which (half width and height) I am copying into a staging ID3D11Texture2D surface created with a width of 1280 (=2560/2) and height of 720 (=1440/2) (as specified in D3D11_TEXTURE2D_DESC before calling ID3D11Device::CreateTexture2D()).
Calling..
ID3D11DeviceContext::CopySubresourceRegion(dst=staging, 0, 0, 0, 0, src=screenshot, 0, box={0,0,0,1281,721,1});
.. works fine (the staging surface contains all the data I expect), but the D3D11 debug layer reports the following error:
D3D11 ERROR: ID3D11DeviceContext::CopySubresourceRegion: When offset by the destination coordinates, pSrcBox does not fit on the destination subresource.
OffsetSrcBox = { left:0, top:0, front:0, right:1281, bottom:721, back:1 }.
DstSubresource = { left:0, top:0, front:0, right:1280, bottom:720, back:1 }.
[ RESOURCE_MANIPULATION ERROR #280: COPYSUBRESOURCEREGION_INVALIDSOURCEBOX]
Since the width and height of the staging (destination) surface are 1280 and 720, it looks to me like it's CopySubresourceRegion which is incorrectly working out DstSubresource as {0,0,0,1280,720,1} - instead of {0,0,0,1281,721,1} as I'd expect it to be (front and back are correct) - and then cheekily reporting that to me as an error - when it made the mistake.
I did double-check that D3D11_BOX was correct (the doc says "The values for right, bottom, and back are each one pixel past the end of the pixels that are included in the box region").
I do not want to mess around with offsets or create a staging surface with the wrong width and height (1281x721) just to make this error disappear, so I am correct in that this error is misleading, or am I unknowingly doing something wrong? (I'm still quite new at coding for D3D11.)
The answer is that I have been a bit stupid. The DstSubresource box (the destination in the staging surface) is indeed correct: it's 1280 pixels wide, so the pixels go from #0 to #1279 (and #1280 is the one pixel past the end).
Where I went wrong is in the specification of the source region, whose box I specified with:
left = 0;
top = 0;
right = width + 1;
bottom = height + 1;
As soon as I properly noticed that there was both "width" and "+1" together (same for the height), when it's always width = (right-left) of course and therefore wasn't the same, I realised my mistake.
So, it was nothing to do with being new at coding for D3D11, and everything to do with an inattention error.

Resources