C# “Parameter is not valid.” creating new bitmap

Keep in mind, that is a LOT of memory you are trying to allocate with that Bitmap. Refer to http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/37684999-62c7-4c41-8167-745a2b486583/ .NET is likely refusing to create an image that uses up that much contiguous memory all at once. Slightly harder to read, but this reference helps as well: http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.framework.drawing/2005-06/msg00176.html Each image in the system has … Read more

How to get the size of the current screen in WPF?

I created a little wrapper around the Screen from System.Windows.Forms, currently everything works… Not sure about the “device independent pixels”, though. public class WpfScreen { public static IEnumerable<WpfScreen> AllScreens() { foreach (Screen screen in System.Windows.Forms.Screen.AllScreens) { yield return new WpfScreen(screen); } } public static WpfScreen GetScreenFrom(Window window) { WindowInteropHelper windowInteropHelper = new WindowInteropHelper(window); Screen screen … Read more

Set variable text column width in printf

You can do this as follows: printf(“%*d”, width, value); From Lee’s comment: You can also use a * for the precision: printf(“%*.*f”, width, precision, value); Note that both width and precision must have type int as expected by printf for the * arguments, type size_t is inappropriate as it may have a different size and … Read more

How Big can a Python List Get?

According to the source code, the maximum size of a list is PY_SSIZE_T_MAX/sizeof(PyObject*). PY_SSIZE_T_MAX is defined in pyport.h to be ((size_t) -1)>>1 On a regular 32bit system, this is (4294967295 / 2) / 4 or 536870912. Therefore the maximum size of a python list on a 32 bit system is 536,870,912 elements. As long as … Read more