Android Auto video resolution - android-auto

I have to support VideoConfiguration,(1280 X 720, 800 X 480) Our car display size is 1024 X 600. After android auto is started , the cellphone(or MD) is sending the video output of 1280X 720px.
Based on the HUIG doc calculation we need to set margin since we cannot downscale the video. After
setting the width Margin of 256 and height margin of 120 , arbitary content is visible and touch coordinate are not working properly. My question is, how can I adjust my parameters so that the video contents from MD is rendered properly.
Car Display size =1024x600
To support 1280 x720
width Margin =1280-1024=256
height Margin=720-600=120
Found this answer https://stackoverflow.com/a/68028928/4722613 , but need some code snippet or detailed explanation.

I have wrapped up things by myself. In order to support 1280*720px resolution, follow the below steps
surface view need to be scaled up in x and y axis. In my case its
1.25 in x axis and 1.2 in y axis.
SurfaceView.setScaleX(1.25f);
SurfaceView.setScaleY(1.2f);
we need to subtract the applied margins from the touch coordinates
before applying the scaling factor to touch coordinates.

Related

Resize proportionally and crop image in any aspect like top right,top left..... on html5canvas [duplicate]

I'm trying to upload images and have them fit into different sized boxes....To give you an idea of what the application does: People upload images and have them printed onto posters.
For example, we'd have a poster size of 8" x 10"(live area) and the full size is 9.5" x 11.5", since the minimum DPI is 100, we typically multiple the 8x10 by 100 = 800x1000.
Here's an image explaining that I have an original image(http://i.imgur.com/Uds9rcZ.jpg) and need it to fit accordingly to the different sizes.
I may need to clarify this a bit, so ask questions if needed.
Thanks.
Canvas's context.drawImage has a version which allows you to scale an image while you are drawing it to the canvas.
If you resize disproportionally (like you do in your example) some of your resized image will fall off the canvas. Then your kitty will look distorted (in your example: stretched vertically)
This sample code resizes proportionally by using only the width. This way your kitty is not stretched.
// calculate how much to scale the resulting image
var originalWidth=16;
var originalHeight=20;
var desiredWidth=20;
var scalingFactor = desiredWidth/originalWidth;
// scale the original size proportionally
var newWidth=originalWidth*scalingFactor;
var newHeight=originalHeight*scalingFactor;
// resize the canvas to fit the desired image size
// Note: canvas is a reference to your html canvas element
canvas.width=newWidth;
canvas.height=newHeight;
// Draw the image to the canvas
// This version of drawImage allows you to scale the original image
// while you are drawing it to the canvas.
context.drawImage(
originalImage,
0,0,originalWidth,originalHeight,
0,0,newWidth,newHeight);
I would like to suggest you use the easyCanvas library to do this. The reason for this is that the built-in drawImage method of context do not scale the image proportionally for you, and it involves a small dose of math to get it right, especially in cases where destination shape differs from original and you want it to cover the whole area.
I made a method in this library to handle situations such as these allowing you to draw the original image proportionally into any shape even if the shape doesn't correspond with the original.
See this demo for an live example.
In essence what you do is to draw your uploaded image into the canvas with this method:
ez.drawImageProp(image, x, y, width, height);
where width and height would be that of destination.
It also has offset parameters so you can move the image around within that shape where an offset of 0.5 is center, 0 is from left and 1 is from right:
ez.drawImageProp(image, x, y, width, height, offsetX, offsetY);
Assuming image is already available all you need to do is:
var ez = new easyCanvas('canvas'); /// provide ID of existing canvas
ez.drawImageProp(image, 0, 0, ez.width, ez.height);
Disclaimer: I am the author of easyCanvas. easyCanvas is open-source (GPL3.0 license).

Set Pixel Dimensions in Matlab

I am pretty new to MatLab. I simply want to display an image for viewing, the image is 1024 x 1024 array. I have been using imagesc to display the image with a line of code such as this:
imagesc(xRange, yRange, imageData, [Min Max]);
However my image dimensions are not equal. For example, my image width is 10mm but in height it is 300mm, so I want it to appear reflecting this, so in this case I would expect it to appear very narrow but tall because the height is so much greater than the width. Instead it displays as a square which does not reflect the true dimensions.
I have looked at some MatLab functions but have not been successful in finding the correct one to do this. Does anybody know how i can set it so each pixel, point in the image is displayed reflecting its true dimensions? Thanks!
Try using daspect
imagesc( imageData );
daspect([ 1 30 ] );
Set your x and y ranges in terms of the desired image dimensions, and set the axes to be equal:
imagesc(xRange, yRange, imageData, [Min Max]);
axis equal tight

How to decrease the size of the svg used in : animated skills diagram with Raphael

I implemented the following plugin into my website http://tympanus.net/codrops/2011/04/22/animated-skills-diagram/comment-page-3/#comments
Unfortunately the set width of the svg used is 600px x 600px. I tried to overwrite the size to a smaller one of 350 px, but it did not work. is simply cuts off a part of the svg. Could anyone give me advise on how to make the animation smaller?
Thanks in advance,
Ev Chen
You can use a viewbox to scale the svg. Set the svg container to the size you want that normally causes cropping, and then set the viewbox to be 600px x 600px, allowing resizing
http://raphaeljs.com/reference.html#Paper.setViewBox
paper.setViewBox(0, 0, 600, 600, true)
This will fit the specified region (600 x 600) into the container.

Resolution from Size and pixels of an image

Is there any formula to calculate image resolution, if provided with image size and image height and width. I googled for an answer, but didnt get much of a help. Got one formula, but if i calculate with height and width of an image, the resolution i got is different from actual resolution.
Also if i have take a pic from 42 mega Pixel camera and 32 mega pixel camera, will the image size and dimensions vary?
Thanks Jithen
It's a simple cross-multiplication
if your image is supposed to have a width of 10 inches and is 1000 pixels wide, its horizontal resolution is 1000 / 10 = 100 ppi (pixels per inch).
Do I missed something ?

Image percentWidth 100 height stays original image height (margin)

What happens with the code below is that image width is scaled to 100% as expected and the height also scales as expected keeping the aspect ratio correct. Issue is that there is a margin at the bottom and that seems to be the height of the original contentHeight of the image. How can I get rid of that?
I am using percentages so that it scales when device orientation changes.
backdrop.source = "http://cf2.imgobject.com/t/p/" + "w342" + data.backdrop;
backdrop.scaleMode = "letterbox";
backdrop.horizontalAlign = "left";
backdrop.verticalAlign = "top";
backdrop.smooth = true;
backdrop.percentWidth = 100;
The answer to your question is don't use the letterbox setting. That is going to preserve the aspect ratio and make the black area, hence the name letterbox :)
Try setting scaleMode to zoom instead. As the documentation states, zoom will result in one axis being clipped. This should scale the image, preserve the aspect ratio, but clip some edges of the image to avoid having the black area.
Other solutions to this problem are:
modify the original image outside of Flash
use a mask to achieve similar results that the zoom setting will provide. In this approach you make the image bigger, but then apply a square mask to the image. The mask reveals only the square portion ... clipping what is outside the mask.
(undesirable in most cases) use the scaleMode setting of strectch (and specify both width/height) so that the area is filled, this will not preserve the aspect ratio
PS: There is no way to avoid the black area if the image's aspect ratio is not square. Even with HTML/CSS. This is just math/geometry. The same thing happens in HTML -- the image is either stretched, clipped, or will not fill both dimensions.
[Edit]
PPS: One other idea, if you know the original aspect ratio of the image, is to calculate a new width that will be closest to the desired width, but naturally preserves the width to height aspect ratio.
For example, the width:height ratio is 4:3. Your desired width is 500 pixels. Using cross products you get this:
4 500
- = -
3 x
Using cross products you get the equation:
4x = 3*500
Now solve for x:
x = 3*500/4 = 375
Therefore, if the original aspect ratio is 4:3, you can set a width of 500 and a height of 375 to scale the image and not have any black areas. You can even write code that dynamically calculates the aspect ratio, and applies this logic to scale something nicely. The point is that you have to the respect aspect ratio when scaling the image to avoid the "black" areas.

Resources