I'm trying to use XResizeWindow() to make a window which will span 2 monitors, but the ?window manager? is limiting it to one.
Is there a hint or property I can associate with the window to tell the WM not to limit it?
For my test case, I have two 1600x1200 monitors that nVidia is presenting as one 3200x1200 screen to KDE4. XDisplayWidth(display, 0); returns 3200 and XDisplayHeight(display, 0); returns 1200.
When I call
XCreateWindow(display, DefaultRootWindow(display),
220, 0, 1700, 930,
1, DefaultDepth(display,screen),
InputOutput, CopyFromParent,
CWCursor, &attributes);
for a window 1700x930 at 220,0 I get a window 1593x930 at 0,0, keeping it entirely on the left monitor. Any XResizeWindow larger than that gets shrunk to 1593. (I assume the 7 pixels are window decoration, which is fine.)
But, if I then XMoveWindow(display, win, 800, 0), it will move the window to span the screens, and I can then enlarge it up to 3200 wide (minus a few pixels).
Is there anything I can do to tell the window manager, or whoever is doing this, not to limit the window to a single monitor, and let me use the entire screen?
Thanks!
%xrandr -q --verbose
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 3200 x 1200, current 3200 x 1200, maximum 3200 x 1200
default connected 3200x1200+0+0 (0x161) normal (normal) 0mm x 0mm
Identifier: 0x160
Timestamp: 64409661
Subpixel: unknown
Clones:
CRTC: 0
CRTCs: 0
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
3200x1200 (0x161) 192.0MHz *current
h: width 3200 start 0 end 0 total 3200 skew 0 clock 60.0KHz
v: height 1200 start 0 end 0 total 1200 clock 50.0Hz
In general, an application should not try to rigidly control its window size and position, as WM is supposed to be smart and place the windows in the best possible fashion. If you want control anyway, try using XSizeHints like this:
XSizeHints sh;
sh.width = sh.min_width = 1700;
sh.height = sh.min_height = 930;
sh.h = 220;
sh.y = 0;
sh.flags = PSize | PMinSize | PPosition;
XSetWMNormalHints(dpy, win, &sh);
XMapWindow(dpy, win);
WMs will respect min_width and will not shrink the window smaller than this.
If you need a fullscreen window spanning multiple monitors, this is done differently, with _NET_WM_FULLSCREEN_MONITORS property. See here.
Related
I am attempting to write some Postscript in order to produce artwork in files I can send to a printer to get some signs printed.
The printer has various requirements for PDFs, one of which is that they should use CMYK.
In all my prior use of Postscript I have used setrgbcolor and never really dealt with colorspace management, ICC profiles, etc.
One of the colours I am using is called RAL 1507 RAL 5017 (Traffic Blue) with RGB and CMYK values I obtained by using a search engine for the colour name. I checked by using an online RGB to CMYK convertor (with no specified colourspace profile)
I though I'd try setcmykcolor and created the following
%!PS-Adobe3.0
%
% Test use of CMYK in Postscript in preparation for creating a PDF/A-1a file
% for use by a commercial printer.
%
%%Pages: 1
%%Page: One 1
/Hevetica-Bold 20 selectfont
0 90 255 div 140 255 div setrgbcolor
100 100 250 100 rectfill
120 130 moveto 1 setgray (RGB: 0 90 140) show
100 255 div 60 255 div 0 10 255 div setcmykcolor
100 200 250 100 rectfill
120 230 moveto 1 setgray (CMYK: 100 60 0 10) show
100 255 div 36 255 div 0 45 255 div setcmykcolor
100 300 250 100 rectfill
120 330 moveto 1 setgray (CMYK: 100 36 0 45) show
0 0 1 setrgbcolor
100 400 250 100 rectfill
120 430 moveto 1 setgray (RGB: 0 0 255) show
showpage
%%EOF
(Forgive the DSC - it's intended to be just enough to placate GSView)
GSView 5.0 on MS-Windows 10 with Ghostscript 9.05 renders it like this
I had expected at least one of the CMYK colours to be rendered much closer to the bottom RGB colour.
The colour in question is designed for printing road-signs, so I'd be surprised if it is outside the relevant colour gamut used by commercial printers.
What do I need to do to be confident the printer will print my CMYK value with a result close to what I expect from GSView's rendering of the RGB value.
I don't know where you got the CMYK values from but they are not (IMO) a good representation of the RGB colour. Try 0.74 0.44 0 0.27 setcmykcolor instead.
The numbers you have used would be reasonable, if you treated them as percentages, not as values in the range 0->255. 100% Cyan, 36% magenta 0% yellow and 45% black produces quite a respectable match. I wonder if that's your mistake ?
That would be:
1 0.36 0 0.45 setcmykcolor
By the way, I think you mean RAL 5017, not 1507 which is red.
On top of that, bear in mind that you are converting an RGB colour to CMYK, then displaying that CMYK value on an RGB monitor, which involves converting it back to RGB, so some loss of precision is to be expected.
The highly simplistic calculation given in the Red Book (PostScript Language Reference Manual) is that cyan = 1 - red, magenta = 1 - green, yellow = 1 - blue. However equal values of CMYK do not generally create black, so we also apply undercolor removal.
Take the lowest value of C, M, Y, Make that value K (black). Then subtract k from each of C, M, Y. The final result is:
c = 1 - red
m = 1 - green
y = 1 - blue
k = min (c, m, y)
cyan = c - k
magenta = m - k
yellow = y - k
black = k
For your values (mapped to values from 0-1, assuming a range of 0-255);
red = 0
green = 0.353
blue = 0.549
c = 1 - 0 = 1
m = 1 - 0.353 = 0.647
y = 1 - 0.549 = 0.451
k = 0.451
cyan = 1 - 0.451 = .549
magenta = 0.647 - 0.451 = 0.196
yellow = 0.451 - 0.451 = 0
black = 0.451
so
0.549 0.196 0 0.451 setcmykcolor
That's a cheap and cheerful calculation, its intended to be done by a PostScript interpreter in a printer, so its chosen to be quick, rather than accurate. But I think you'll see that its closer than the values you were using.
For proper colour space management the RGB colours you are using would be values in a particular RGB space, for example the colour space of your monitor. You would then use the ICC profile associated with that device to turn the RGB values into values in the CIE XYZ space (a device-independent space). Then you would choose a particular destination CMYK space (eg the printer you want to use) and would use the ICC profile asociated with the destination device to go the other way, turn the XYZ values into CMYK values.
In a properly colour managed workflow, where all the devices are characterised by ICC profiles, the result is that the colour on all the devices would be as close as it possible to get to being the same.
Of course, this relies on you having everything characterised, clearly you don't.
Note that spot colours (/Separation colours in PostScript and PDF) are somewhat 'different'. These are intended to be printed using the specific ink so there's no need to characterise the values, 50% Pantone 1495 is an absolutely accurate value.
However, if your printer isn't equipped to print that colour, because for example your doing a quick check on your local CMYK printer, these colours are normally defined to have an 'alternate' representation. Ideally these would be CMYK values which will print something which is not entirely unlike the desired colour. Some ink manufacturers specify an alternate representation which is not a particularly good representation of the actual colour, arguably because they have a number of inks which map to the same colour in CMYK, so they use 'off' values to be able to tell the difference. Suspicious users have been known to comment that its done to make sure you can't do a decent print without using the manufacturers inks.....
Anyone know how can I interpole a energy spectrum matrix linearrly spaced to a matrix where one of the axis is logarithimically spaced instead of linearly spaced?
The size of my energy spectrum matrix is 64x165. The original x axis represents the energy variation in terms of directions and the original y axis represents the energy variation in terms of frequencies. Both vectors are spaced linearly (the same interval between each vector position). I want to interpolate this matrix to a 24x25 format where the x axis (directions) continues linearly spaced (now a vector with 24 positions instead of 64) but the y axis (frequency) is not linearly spaced anymore; it is a vector with different intervals between positions (the interval between the position 2 and the position 1 is smaller than the interval between the position 3 and the position 2 of this vector... and so on up to position 25).
It is important to point out that all vectors (including the new frequency logarithmically spaced vector) are known (I don't wanna to generate them).
I tried the function interp2 and griddata. Both functions showed the same result, but this result is completely different from the original spectrum (what I would not expect to happen since I just did an interpolation). Anyone could help? I'm using Matlab 2011 for Windows.
Small example:
freq_input=[0.038592 0.042451 0.046311 0.05017 0.054029 0.057888 0.061747 0.065607 0.069466 0.073325]; %Linearly spaced
dir_input=[0 45 90 135 180 225 270 315]; %Linearly spaced
matrix_input=[0.004 0.006 1.31E-06 0.011 0.032 0.0007 0.010 0.013 0.001 0.008
0.007 0.0147 3.95E-05 0.023 0.142 0.003 0.022 0.022 0.003 0.017
0.0122 0.0312 0.0012 0.0351 0.285 0.024 0.048 0.036 0.015 0.036
0.0154 0.0530 0.0185 0.0381 0.242 0.102 0.089 0.058 0.060 0.075
0.0148 0.0661 0.1209 0.0345 0.095 0.219 0.132 0.087 0.188 0.140
0.0111 0.0618 0.2232 0.0382 0.027 0.233 0.156 0.119 0.370 0.187
0.0069 0.0470 0.1547 0.0534 0.010 0.157 0.154 0.147 0.436 0.168
0.0041 0.0334 0.0627 0.0646 0.009 0.096 0.136 0.163 0.313 0.112]; %8 lines (directions) and 10 columns (frequencies)
freq_output=[0.412E-01 0.453E-01 0.498E-01 0.548E-01 0.603E-01]; %Logarithimically spaced
dir_output=[0 45 90 135 180 225 270 315]; %The same as dir_input
After did a meshgrid with the freq_input and dir_input vectors, and a meshgrid using freq_output and dir_output, I tried interp2(freq_input,dir_input,matrix,freq_output,dir_output) and griddata(freq_input,dir_input,matrix,freq_output,dir_output) and the results seems wrong.
The course of action you described should work fine, so it's possible that you misinterpreted your results after interpolation when you said "the result seems wrong".
Here's what I mean, assuming your dummy data from the question:
% interpolate using griddata
matrix_output = griddata(freq_input,dir_input,matrix_input,freq_output.',dir_output);
% need 2d arrays later for scatter plotting the result
[freq_2d,dir_2d] = meshgrid(freq_output,dir_output);
figure;
% plot the original data
surf(freq_input,dir_input,matrix_input);
hold on;
scatter3(freq_2d(:),dir_2d(:),matrix_output(:),'rs');
The result shows the surface plot (based on the original input data) with red squares superimposed on it: the interpolated values
You can see that the linearly interpolated data values follow the bilinear surface drawn by surf perfectly (rotating the figure around in 3d makes this even more obvious). In other words, the interpolation and subsequent plotting is fine.
I'm working with the TDA19988 HDMI framer and having troubles understanding how to translate the EDID info to configure the framer output.
For example, from the EDID I can see the following parsed info:
1280x720 0x41 74.2MHZ
H : 1280 start 1390 end 1430 total 1650 clock 45.0KHZ
V : 720 start 725 end 730 total 750 clock 60.0HZ
Now, the HDMI framer allows the following to be configured:
refpix (preset pixel) = ?
refline (preset line) = ?
npix (number of input pixels) = ?
nline (number of input lines) = ?
vs_line_start_1 (vertical synchronization line start) = ?
vs_pix_start_1 (vertical synchronization pixel start) = ?
vs_line_end_1 (vertical synchronization line end) = ?
vs_pix_end_1 (vertical synchronization pixel end) = ?
hs_pix_start (horizontal synchronization pixel number) = ?
vwin_start_1 (vertical window start) = ?
vwin_end_1 (vertical window end) = ?
de_start (data enable start) = ?
de_end (data enable end) = ?
I haven't been able to understand how the EDID info is translated to configure the HDMI framer output. Can someone give me some help?
Thanks in advance!
I don't know too much about EDID, but since there is no answer yet, I'll explain what I know.
The TV signal comes one pixel at a time from left to right and from top to bottom. The pixel frequency is 74.2MHZ, that is there are 74.2 million pixels in a second.
Each line is composed of 1650 pixels, that makes 74.2M / 1650 = 45K lines in a second. That's the 45.0KHz.
Then, each frame is made of 750 lines. That is 45K / 750 = 60 frames per second. That's the 60.0Hz.
From each line of 1650 pixels, only the first 1280 pixels are used for actual pixels in the image. From pixel 1390 to 1430 there is the horizontal synchronizaton signal. From 1280 to 1390 and from 1430 to 1650 there are unused pixels (HBlank).
And from each frame of 750 lines, only the first 720 are used for actual pixels. From 725 to 730 there is the vertical synchronization signal. Ranges 720-725 and 730-750 are also unused (VBlank).
About your parameters, the *start* and *end* parameters should be quite obvious. The other ones... well, I don't know.
I was reading dp, dip, px, sp measurements, but I still have some questions about dp/dpi vs ppi vs px vs inch. I am not able to compare them... is an inch the largest?
They say 160 dpi means 160 pixels per one inch. Does that mean 1 inch contains 160 pixels?
They also say 1 pixel on a 160 dpi screen = 1 dp. Does that mean 1 pixel and 1 dp are equal?
And lastly, why should we use dp instead of px? I understand that it is ideal, but why?
You should (almost) always use flexible sizing units, like dp, which is Density-Independent Pixels, because 300px on one device is not necessarily the same amount of screen real estate as 300px on another. The biggest practical implication is that your layout would look significantly different on devices with a different density than the one your design targeted.
dp or dip means Density-independent Pixels
dpi or ppi means Dots (or Pixels) Per Inch
inch is a physical measurement connected to actual screen size
px means Pixels — a pixel fills an arbitrary amount of screen area depending on density.
For example, on a 160dpi screen, 1dp == 1px == 1/160in, but on a 240dpi screen, 1dp == 1.5px. So no, 1dp != 1px. There is exactly one case when 1dp == 1px, and that's on a 160dpi screen. Physical measurement units like inches should never be part of your design—that is, unless you're making a ruler.
A simple formula for determining how many pixels 1dp works out to is px = dp * (dpi / 160).
dp is a physical measurement like inches. (Yes, it is. Read on.)
"A dp corresponds to the physical size of a pixel at 160 dpi" (https://developer.android.com/training/multiscreen/screendensities.html#TaskUseD)
The physical size of a pixel at 160 dpi is exactly 1/160th of an inch. Therefore the size of a dp is 1/160th of an inch. 160 dp = 1 inch.
Px is a somewhat arbitrary unit of measurement on a screen.
For examples of what dp converts to in px on different devices, see here:
https://stackoverflow.com/a/39495538/984003
How do dp, dip, dpi, ppi, pixels and inches relate?
For the purpose of android development:
dp = dip
dpi = ppi
inch x dpi = pixels
dp = 160 x inch
dp = 160*pixels/dpi
So, on a 160dpi phone (mdpi):
2 inches = 320 dp
2 inches = 320 pixels
On a 180 dpi phone:
2 inches = 320 dp
2 inches = 360 pixels
Note that 2 inches is ALWAYS 320dp, independent of screen size. A dp is a physical distance of 1/160th of an inch.
The dp to pixels formula is interesting:
dp = 160*pixels/dpi
Is equivalent to:
dp = pixels/(dpi/160)
dpi/160 is an interesting factor. Its the relative density compared to android's mdpi bin and the amount you must scale your graphics by for the various resource bins. You'll see that factor mentioned a few times on this page, 0.75 being the factor to ldpi.
I will explain using an example.
float density = context.getResources().getDisplayMetrics().density;
float px = someDpValue * density;
float dp = somePxValue / density;
density equals
.75 on ldpi (120 dpi)
1.0 on mdpi (160 dpi; baseline)
1.5 on hdpi (240 dpi)
2.0 on xhdpi (320 dpi)
3.0 on xxhdpi (480 dpi)
4.0 on xxxhdpi (640 dpi)
so for example,
I have a Samsung S5 with 432 dpi (http://dpi.lv/#1920×1080#5.1″).
So, density = 432/160 = phone's dpi/baseline = 2.7
Let say my top bar is 48dp. This is referenced to baseline (160dpi).
So, w.r.t my S5, it will be 48dp * 2.7.
Then if I want to see the actual height:
It will be (48dp * 2.7) / 432 dpi = 0.3 inches.
DP is the resolution when you only factor the physical size of the screen. When you use DP it will scale your layout to other similar sized screens with different pixel densities.
Occasionally you actually want pixels though, and when you deal with dimensions in code you are always dealing with real pixels, unless you convert them.
When not referring to android, but rather to monitors,
DP actually means Dot Pitch, which originally came about from CRT monitors. It refers to the diagonal distance between 2 pixels in mm. In LCD monitors, a pixel is larger, and assuming the pixels are right next to each other without gap (usually there is a very small gap, but for simplicity, we will assume it is zero), the diagonal distance between the 2 centers of each pixel is equal to the diagonal size of the pixel. The lower the DP, the crisper the image.
DP = 25.4÷ppi
0.25 DP is standard, jagged edge
0.20 DP is considered much clearer
160 ppi = 0.158 DP
So DiP is actually a rounded approximation of 1000 x DP, and the 2 are not equivalent, just very close approximations.
As mentioned before, you should not base things off of pixel size since you can zoom. This is for how clear something will appear on the screen.
In monitors, if you want clarity at 20 inches (average distance between monitor to eye) (< 0.20 DP medium clarity/0.16 DP ultra sharp), this would equate to:
1920x1080 (HD) 17.4 inch/ 14 inch
3840x2160 (4K) 35 inch / 27.8 inch
A high resolution phone might have a DP of 0.05 (approximately 500 ppi), or 3 times higher than that of a ultra sharp monitor but viewed 3 times closer.
Anything larger than these dimensions for the monitor size will appear pixelated, smaller would be clearer.
Also noteworthy is that 72 pixels per inch is a Mac standard, and very old. 96 ppi is what Windows resolution is referenced to. Photoshop was originally designed for the Mac.
As we go up the musical scale the note frequency increases;
#define A4 440 // These are the frequencies of the notes in herts
#define AS4 466
#define B4 494
#define C5 523
#define CS5 554
#define D5 587
I am generating the tones mechanically, I tell a step motor to step, delay, step, delay etc etc very quickly.
The longer the delay between steps, the lower the note. Is there some smart maths I could use to inverse the frequencies so as I climb up the scale the numbers come out lower and lower?
This way I could use the frequencies to help calculate the correct delay to generate a note.
So what you're saying is you want the numbers to represent the time between steps rather than a frequency?
440 Hz means 440 cycles/second. What you want is the number of seconds/cycle (i.e. time between steps). That's just 1 / <frequency>. That means all you have to do is define your values as 1/440, 1/466, etc. (or, if you want the values to be milliseconds, 1000/440, 1000/466 etc.)
If that is too fast (or doesn't match the actual notes), you can multiply each value by a scale factor and the relationships between the audible tones should remain the same.
For example, lets say that you empirically discover that for your machine to make an "A4" tone, the delay between steps is 10 milliseconds. To figure out the scale factor, solve for x:
x / 440 = 10
x = 4400
So define scale = 4400, and define each of your notes as scale / 440, scale / 466 etc.
Yes, that sounds possible! Let's have a look... (some of this you will know but I'll post it anyway)
In what's called an equal tempered scale, you can calculate Hertz values by multiplying by the twelfth root of two for every semitone you go up. There are 12 semitones in a whole octave, and multiplying by this value twelve times doubles the frequency, which raises the tone by an octave.
So, if you wanted to calculate descending semitone frequencies from e.g. A 440, you can calculate double x = pow(2.0, 1.0/12.0) (assuming C), and then repeatedly divide by that value (remember to do the divisions as doubles not ints :) ) and then you'll get your descending scale.
Aside: If you want to do a major scale rather than a chromatic (semitone) scale, this is the pattern of tones and semitones to use: (e.g. in C Major - using T for Tone, S for semitone)
C [T] D [T] E [S] F [T] G [T] A [T] B [S] C