X11: How to rotate the gravity/orientation to 90 degrees - x11

I need to know is it possible to rotate the orientation of all X-based apps to 90 degrees. Without modifying their sources. I guess X11 should have some configuration option for this.
So how to do this ?

Found the answer myself.
xrandr -o left will rotate display orientation to left.
xrandr -o right will rotate display orientation to right.
xrandr -o inverted will invert display orientation
xrandr -o normal will set to normal mode.

Related

How to edit an image in Gimp when the target display has different horoiztonal and vertical resolution?

I want to make a wallpaper for this desktop, which has a resolution of 1024 x 384
When I create an image of this dimension in GIMP, it looks like it's half the height by comparison:
It's difficult to create art at a different ratio to the target. How can I handle this in GIMP? (I'm told that in photoshop there is a menu option for this situation, so they look the same but still have the same dimensions but I don't know what it's called.)
Use Image ➤ Print size you can set a different vertical and horizontal resolution for the image (click the chain link to decouple them). You typically want an Y resolution which is half the X one, and best use a resolution which is close to your actual display, possibly 100PPI for X and 50PPI for Y).
Tell Gimp you want it to work using the print size: un-tick View ➤ Dot for dot
Remember that Gimp still works with pixels, if you copy/paste a square from another image, it will be stretched vertically. Likewise a 1:1 aspect ration in the Rectangle and Ellipse selection tools will yield a vertically stretched selection.
On the other hand if you create text with the text tool, it will look normal in "Print size" view, and stretched horizontally in "Dot for Dot" view.

How to render each pixel of a bitmap texture to each native physical pixel of the screen on macOS?

As modern macOS devices choose to use a scaled HiDPI resolution by default, bitmap images get blurred on screen. Is there a way to render a bitmap pixel by pixel to the true native physical pixels of the display screen? Any CoreGraphics, OpenGL, or metal API that would allow this without change the display mode of the screen?
If you are thinking of those convertXXXXToBacking and friends, stop. Here is the explanation for you. A typical 13 in MacBook pro now has native 2560x1600 pixel resolution. The default recommended screen resolution is 1440x900 after fresh macOS install. The user can change it to 1680x1050 via System Preferences. In either 1440x900 or 1680x1050 case, the backingScaleFactor is exactly 2. The typical rendering route would render anything first to the unphysical 2880x1800 or 3360x2100 resolution and the OS/GPU did the final resampling with an unknown method.
Your best bet is probably Metal. MTKView's drawableSize claims that the default is the view's size "in native pixels". I'm not certain if that means device pixels or backing store pixels. If the latter, you could turn off autoResizeDrawable and set drawableSize directly.
To obtain the display's physical pixel count, you can use my answer here.
You can also try using Core Graphics with a CGImage of that size drawn to a rect of the screen size in backing store pixels. It's possible that all of the scaling will be internally cancelled out.
If these are resource images, use asset catalogs to provide x2 and x3 resolution version of your images, icons, etc. Classes like NSImageView will automatically select the best version for the display resolution.
If you just have some random image and you want it draw at the resolution of the display, get the backingScaleFactor of the view's window. If it's 2.0 then drawing a 200 x 200 pixel image into a 100 x 100 coordinate point rectangle will draw it at 1:1 native resolution. Similarly, if the scale factor is 3.0, a 300 x 300 pixel image will draw into a 100 x 100 coordinate point rectangle.
Not surprisingly, Apple has an extensive guide on this subject: High Resolution Guidelines for OS X

Skew one side of image

I'm going to be doing a project on a Raspberry Pi where I display an image through a projector. The image is a rectangle that exactly twice as long as it is wide. Since I'm displaying via the projector, that means the side furthest from the project will end up being narrower than the closer side, so I need to expand that side of the image.
Can someone point me in the right direction of how I'd implement that please? I don't even know what the right terminology is to good it and look into the math I'd need to do.
What you're asking for is called "keystone correction," I believe. Many video projectors can do this automatically, so it's worth checking before writing a pile of code :)
Here's how to do this using the ImageMagick convert utility. You need to know the size of the image to start with. For the sake of discussion, let's assume it's 889 x 746. Also, let's assume we want the image to be "thinner" at the bottom than the top, by 60 pixels, and that the "thinning" is symmetrical about the vertical centre-line.
So let's call the top-left pixel (1,1), the top-right (889,1), the bottom left (1,746) and the bottom-right (889,746). The top-left and top-right pixels stay where they are; the bottom-left "moves" from (1,746) to (61,746). The bottom-right moves to (829,746), because 889-60 is 829 -- this is a move to the left.
The convert -distort perspective command requires the coordinates of four pixels, their pre-move and post-move values. It then calculates how to move all the other pixels, such that straight lines in the original remain straight. So, taking the calculated values above, we need:
convert in.png -virtual-pixel transparent -distort perspective \
'1,1 1,1 \
889,1 889,1 \
1,746 60,746 \
889,746 829,746' \
out.png
Of course, the spacing isn't essential: it's just to show how the numbers line up with the calculated values above.
Naturally, you'll need to adjust the numbers to suit your image size, and the degree of correction you need. ImageMagick is avilable for Raspberry Pi, and it's easy enough to embed a call to convert in application code.

MLT Framework. How to add text or image watermark on the center of video and add zoomIn animation to it?

Tried this:
-filter watermark:"welcome.jpg" in=0 out=320 composite.progressive=1 producer.align=centre composite.valign=middle composite.halign=center crop_to_fill=1 composite.geometry="0=0,0:80%x80%:0%;60=0,0:100%x100%:100%;260=0,0:120%x120%:100%;320=0,0:120%x120%:0%"
But it doesn't increase size of watermark, it just moves it to right bottom side...
I don't know of a way to animate a center zoom only using the watermark filter. But it is possible to animate a center zoom using the affine transition. You would need to use two tracks: one with the background video and another with the text to be animated. Here is an example:
melt color:blue in=0 out=320 -track welcome.jpg in=0 out=320 -transition affine valign=middle halign=center scale=1 fill=1 geometry="0=10%,10%:80%x80%:0%;60=0,0:100%x100%:100%;260=-10%,-10%:120%x120%:100%;320=-10%,-10%:120%x120%:0%"
The key is that the position of the watermark is relative to the left corner. So, in addition to animating the size, you also need to animate the x and y position as shown in the example.
Also note that the animation will interpolate the size and position for each frame - but the position is rounded to the nearest pixel. So the motion may not be smooth. That is a known limitation to the animation capabilities in MLT.

How can I make screenshot of the part of the screen with ImageMagick?

I use Windows 8. I have coordinates of the part of the screen and I want to make screenshot only of that rectangle. How can I do it with ImageMagick?
If you have at least ImageMagick 6.8.9-0 you can do the following to take a screenshot of part of your screen:
convert screenshot: -crop 100x100+500+500 screenshot.png
In example above, -crop operation cuts out a rectangle that is 100x100 (width and height) at position 500x500 (x and y of the top left corner of the rectangle). And if your computer has multiple monitors you can specify an index screenshot:[1]. The index of the monitor starts with 0, so first monitor will have index 0.
convert screenshot:[1] -crop 100x100+500+500 screenshot.png

Resources