CGDisplayCopyAllDisplayModes() does not give a complete list of available modes - objective-c

I've been trying to write a simple app that resets display resolution for an iMac and a connected projector to 1024x768, 85 Hz and 32bit color.
When the projector is directly connected to the mac with VGA or HDMI, the CGDisplayCopyAllDisplayModes() function gives a list of modes which includes the settings I want to apply. But my college uses Extron VGA wall box thing to connect VGA wires to projectors, which leads to CGDisplayCopyAllDisplayModes() giving a much smaller (only 800x600 and 640X480) list of modes. Also, the name of the display when using the wall box is just VGA Display as opposed to Np-511 or whatever the name of the projector is. The weird thing is that System Preferences->Display shows a 1024x768 setting even then and lets me apply it too.
Is there any way to either get a larger list of modes for the projector, create a 1024x768 mode from scratch and apply it (I've already confirmed that the projector supports it) or simply make System preferences choose that mode for me? I've already written an applescript to do the latter but the disply preferences changes according to the projector connected so I need a more general solution.
Looking forward to your help! I've added some code I used and can include more of it if it'd help.
CGGetOnlineDisplayList (MAX_DISPLAYS, displays, &numDisplays); // to get list of display ids
// ... now iterating over list of displays
CFArrayRef modeList = CGDisplayCopyAllDisplayModes (displays[i], NULL);

Related

Why do a .net form and controls not size properly on a given user's machine?

We received a large net desktop application from another agency to implement at our agency. It's messy, but works. It uses a midi form with forms opening inside that, and panels. We compiled and deployed in Visual Studio 2015. It's VB.
All users have Windows 7 64 Pro. For one user, when forms open, the lower portion is cut off. If restored (un maximized), the form shrinks to a tiny window in the upper left of the midi window. If borders are dragged the form will expand, but only a small portion of the form at the upper left will contain anything, as if inside a shrunken panel with scroll bars.
I changed the application so forms have a minimum size that should prevent them from shrinking down, but that doesn't work on her machine. I also changed a couple of panels to "fill" similar to adjacent panels. On other machines the application works excellent, even if display is changed to larger 150%. On the problem machine, the application only works if the display is set to smaller 100% and will not work on medium or larger. The user chooses to have larger.
I can place code on resize events and try to force everything to display correctly, but should not have to do that. The application works correctly everywhere else. Something is different about the problem machine where window metrics are not being computed properly or something similar. All machines are made from the same image and have the same drivers. I cannot see any additional software installed.
I would like to know if anyone else has seen this issue and how it was resolved.

Automatically select video source from dialog? VB.net

I've been playing with a generic usb camera to take snapshots every few seconds. With the help of this SO question, I was able to get the camera working; however, when you click the button to connect to the camera, a dialog box appears.
The difference between the other question and my question is that I have two video sources: a built in webcam and a usb camera. I also intend to have multiple cameras connected, all taking pictures. It appears that when you have multiple devices, you always get the dialog box where you have to choose the device. I'm trying to automatically choose the camera (and eventually cameras, plural) without this dialog box.
There are other pieces of sample code that I have played with - samples that have a device listbox that is populated; I thought this was what I needed (and I'd just remove the listbox control and process the list and what to connect to in code), but every one of these samples populates the listbox with "Microsoft WDM Image Capture (Win32)" instead of the devices listed in the dialog after attempting to connect to this "device."
Surely there's a way to automate the webcam(s) I'm connecting to instead of having to choose it from a dropdown in a Windows dialog, right? How would I go about doing this?
The solution ultimately was to use EMGU to access the camera; this also allows for connecting to multiple cameras at the same time.

Screenshot of a virtual terminal when it is not focused (in the background)

This is on Ubuntu. I have two xsessions, one on tty7 (display :0) and one on tty8 (display :1). For the record, :0 is Unity and :1 is Fluxbox. I would like to be able to take a screenshot on display :1 while working on display :0.
I'm using the Java Robot class. I've written a small screen scraping bot. The mouse movements work when I'm switched to the other virtual terminal, but the screengrabs are coming out all black (the bot has no image to act on).
I'm spawning the second xsession with:
startx /usr/bin/fluxbox -- :1
Is there a way to make the screenshots work? Is there a workaround for keeping the display active (remote desktop to it?)? Would someone be kind enough to explain why these go black when the virtual terminal is not focused?
I'm looking for the least intensive way to have a second display, mouse, and keyboard running. The path of least resistance would be a way to keep the display active when not focused.
Thanks! Sorry if any of my terminology is off, new to using a second virtual terminal.
You get a black image simply because the image you want to capture does not exist anywhere.
When a virtual terminal is active, each program that is on your display will generate its own image, and the image gets put into the video memory. When the virtual terminal is not active, the programs do not generate their image (since it would be superfluous), nothing stores those images, so you cannot capture them.

XAML designer in VS2012/Blend not redrawing properly

I have a dev box with Windows 8 + VS2012 Update 2 on top. Ever since I had this system, the XAML designer has been behaving weird (for Win8 and WPF as well): it redraws only every second time.
Meaning that if I place a control, it does not update (the control cannot be seen, but its outline can be, if I hover over it); but if I place another control, or change the zoom level, or do any other action, then it refreshes. When I do a third action, no update; when I do a fourth action, it redraws. And so on, it is 100% repro-able.
Pretty bad for productivity.
I have the latest drivers and updates, I have loads of RAM (16GB) and a discrete Nvidia video card, I restarted umpteen times, the usual fixes do nothing.
A screenshot: http://sdrv.ms/13BJSof
Anyone with similar experience?
OK, I found a solution - my laptop uses nVidia Optimus (it's a Lenovo W520) and that was the source of this error (amongst others, such as being unable to properly "duplicate" my display to a projector). I solved it by simply turning off Optimus in the BIOS and enabling only the Discrete card.

how does f.lux work?

i am trying to figure out how this software works:
http://www.stereopsis.com/flux/
specifically, i would like to know how it changes the colors on your machine, and also was wondering if this would be possible to do in vb.net?
Most likely they play around with color management. Graphical operating systems allow for color calibration which changes the look of colors on a display. This is primarily used so the display has exactly the same color gamut as printers for design purposes or that the display has natural-looking colors. In this case it is used to adjust the color temperature programmatically.
In the FAQ they state "Currently, we don't recommend running f.lux on calibrated systems running Windows" which seems to reinforce the idea that they are messing with the color calibration (and are probably replacing the one you did previously).
Windows has support for this beginning with Vista and you probably can use this with VB.NET but not natively from .NET, meaning you will have to use the API directly. Here is an introduction about the Windows Color System on MSDN.
Note: Tried it out. Yes, they do mess with the color calibration. And they're pretty aggressive in that regard. Whenever I click "Reload current calibrations" in the color management panel to get my own calibration back (Windows 7 here) it gets reset by f.lux. It seems they are setting this about once a second. Now imagine there are two programs doing this :-)