Since I can't find ZoomIn and/or ZoomOut magnifying glass cursor for my program, I created my own cursor of size 32 by 32 4bit with my compiler. However, when I do assign it to my form cursor, it is not displayed at all, whereas 16 by 16 4bit BMP cursor is properly displayed as expected.
Am I missing something or is this size not allowed as of now or do I have to do something to make it work?
Here is how it is set:
Mainform.Cursor := new Cursor(baseDir+'\ZoomIn.Cur');
This is what I see after saving 32 by 32 cursor file in the windows explorer.
Normally, you should see tiny version of the cursor right next the cursor file name, but I see none.
Thanks in advance,
Windows (at least the .NET Cursor class) doesn't appear to like icons that are more than 1-bit black and white images.
32x32 bit are still supported. I tested using one of the old CodeGear Shared\Images\Cursors images, as well as a new cursor created in GreenFish Icon Editor and in the Visual Studio Image Editor (File->New File->Cursor file), using the following code:
method MainForm.MainForm_Load(sender: System.Object; e: System.EventArgs);
begin
self.Cursor := new Cursor('E:\code\XHAIR1.CUR');
end;
So reducing the color depth to 1-bit should make it work for you.
Related
I would happily provide a screenshot of this, however the problem is the captured image, is much larger than my actual desktop.
I am completely frustrated with this as I have tried using BitBlt with the desktop hdc AND the new "Graphics" commands.
My actual desktop resolution is 1920x1080 - 1080p .
BitBlt and "Graphics" both return that my resolution is 1536x864 # 96 DPI.
A form (WinForm), Maximized, borderless, and irrelevant of scaling mode the form is set to, also shows 1536x864 # 96 DPI.
Now the image that is captured, is like it is being done from 1920x1080, but clipping the region 1536x864 as the screenshot.
If I do PrintScreen directly using Prtscn button, I get the entire image, but still it is about 1.5-2x larger than what I actually see.
What I am looking for -- is a resolution for how I can take a picture of what is on my screen in the scale/dpi/whatever is going on here that it visually looks like. I have written a screen capture program, and using a few different examples for the RubberBand form (overlay form to select a region of the screen by drawing a box), and as you can imagine, this scaling crap is causing those box captures to be offset, and the contents are zoomed.
This is very annoying -- even to explain, however I am positive that most of you are familiar with the terms I use, and also know what to expect from taking a screenshot, so my explanation above should be pretty clear as to what my problem is.
Example/Consideration
Imagine, taking a picture of a window that is 300x300, and getting the top left 150x150 of that zoomed to 300x300 completely skipping the remainder of the window. Resulting image is still 300x300, but it's not what you selected.
Now imagine, you grab a picture of your screen by the only dimensions you can get programmatically, and then put the image into a picturebox. Even though both your screen and the picturebox claim to be the same dimensions and dpi, the image in the picturebox requires scrolling even if the picturebox is maximized to fullscreen on a borderless with no borders / etc. -- again, the picture is zoomed, but how is it still reporting that it's the same size as the form XD (comparing Graphics or BitBlt dimensions with the actual form. also tried comparing picturebox contents, and still same effect)
This, is EXACTLY what the effect is that is happening. When I try to capture a region or segment of the screen. I am not sure why windows api/crl is lying about this seemingly trivial stuff, however there must be a way to accurately obtain screenshots/capture regions without this faux zoom effect -- across all resolutions.
Thank you Hans Passant for pointing me in the right direction.
To add "true" dpi scaling support to a winforms application, you can make it so by adding the following block to your manifest :
Project > Add New Item > Visual C# Items > Application Manifest File
One the file has been added, open it up and look for a line like
</asmv1:assembly>
Whatever the "asmv" number is, (in the example above it is 1), use that to format the code:
<asmv1:application>
<asmv1:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv1:windowsSettings>
</asmv1:application>
Paste the above code (changing the asmv1 to whatever version the manifest is), just above the final closing line for the ""
Also, make sure your forms are set to AutoScale to dpi (and all sub-elements).
I have a 16bit texture that is displayed on a model in an xna+silverlight app.
Here is the texture
But, it is rendered like this:
I tried loading png instead of jpg, loading from stream and some other stuff I forgot, but nothing seems to work.
Update:
I tried setting PreferredBackBufferFormat to SurfaceFormat.Color, nothing changed.
Update2:
Xna is displaying in 16bit by default. 5 bit for R, 6G and 5 B. After converting my texture to 565 it looks exactly like the one rendered.
There probably is no solution that would satisfy me, so I'm will be trying some other approach.
On Windows Phone 7, is you want to use 32 bits colors, you have to explicitely activate it in the application manifest.
Open the WMAppManifest.xml file, search the App node, and add the attribute BitsPerPixel="32"
http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff769509(v=vs.105).aspx
My application makes use of a custom cursor loaded from a predefined file (.cur) during runtime. I know windows uses a standard 32x32 pixels cursor or a 48x48 pixel cursor for high DPI devices.
The cursor I want to use in my application however is much larger. A small cursor is displayed correctly when I use Mouse.SetCursor(_CustomCursor). When a larger cursor is chosen, I don't see any cursor. It would seem that the cursor loads correctly but cannot be displayed.
Note: Currently a static .cur cursor is acceptable.
Is there a way to display larger cursors in my application and if there is a limit on the size, what is it?
Is there a restriction to cursor sizes?
Yes, it's a system restriction. Not just for VB.NET...
To get the max size of the Cursor you can use, you should query the SystemParameters.CursorHeight and SystemParameters.CursorWidth properties.
As stated by MSDN these properties are mapped to the SM_CYCURSOR andSM_CXCURSOR properties respectivly.
As you can read in MSDN
SM_CXCURSOR
13
The width of a cursor, in pixels. The system cannot create cursors of other sizes.
and
SM_CYCURSOR
14
The height of a cursor, in pixels. The system cannot create cursors of other sizes.
So I managed to find a work around to the problem on the size restriction.
As mentioned on Cursor from BitMap one can create a cursor of arbitrary size from a bitmap.
The code to achieve this is as follows:
Dim bm As New Bitmap(60, 60) 'Or from a bitmap file
Dim g As Graphics = Graphics.FromImage(bm)
g.FillRectangle(Brushes.Blue, 0, 0, 60, 60) 'For a simple blue rectangle cursor
Dim ptrCur As IntPtr = bm.GetHicon
Dim CustomCursor As Cursor
CustomCursor = New Cursor(ptrCur)
Me.Cursor = CustomCursor 'Set the application cursor to be custom
The hotspot is automatically set to the centre of the bitmap. Here is a preview of the results:
This code works well on a Windows forms application. With a WPF application an 'invalid extension for cursor' exception is thrown. Will be looking into resolving it (any suggestions welcome).
EDIT: In WPF a restriction of 96 pixels is applied to any dimension of the cursor, anything bigger will not display.
I am trying to smooth text rendering using anti-aliasing.
But it's not anti-aliased.
First line is a png image created using pango and cairo.
Second line is just an html <span> tag. It's in firefox, Ubuntu with Gnome DE.
The difference can be better understood if you compare "W" and "v"
between two lines.
The code responsible to draw text can be found on http://pastie.org/1073683
Font options are set on lines 17 and 20 like so:
// setting up antialiasing
cairo_font_options_set_antialias(cfo, CAIRO_ANTIALIAS_GRAY);
// set the font options to cairo
cairo_set_font_options(this->cro, cfo);
Could anyone please tell me how can I make those two lines look the same?
cairo_font_options_set_antialias(cfo, CAIRO_ANTIALIAS_GRAY);
You asked for it, you got it. To get a match you'd need CAIRO_ANTIALIAS_SUBPIXEL. This is however not appropriate when you draw text to an image that might be displayed on another machine. There's no guarantee that the monitor on that machine is an LCD panel with the RGB stripes in a predictable order. Or that it in landscape orientation. Or that it is displayed with the exact original size. When there's a mismatch, the text will look quite poor.
When a child window of my application is opened and I view the ALT+TAB menu, the application icon looks pixellated. I assume that Windows uses a low resolution version of the icon (16x16 pixel I think). What can I do that Windows selects the right version which would be 32x32 pixel?
I assigned an icon to the window in question that has 16x16, 24x24, 32x32, 48x38 and 256x256 in true color. Please note that VS says in the proterties that 32x32 is used and that it works fine for the main window of my application where I assigned the exact same icon.
The caption bar of a Windows application window display icons in 16x16 pixels. The Alt-Tab list, however, shows icons in 32x32 pixels. It uses the same icon as is set for the window. If you only set a 32x32 one, the caption bar has to scale it down, which tends to look ugly as it uses nearest-neighbor interpolation. So how does one support both?
The answer is the ICO file! It supports embedding multiple icons in one file, typically the same (or similar) icon in various sizes and, less commonly, color formats.
Browsers, Windows, and others are typically designed to smartly use the appropriately sized variant within a given ICO file. So the answer is to have an ICO file with both sizes (or more) inside. The result is that the caption bar correctly uses the 16x16 version and Alt-Tab uses the larger 32x32 one.
The methods for saving an ICO file with multiple icons inside varies from program to program. However, GIMP can easily do it (and it's free). The trick is to have your variously-sized icons as separate layers. When you go to save it as an ICO file, GIMP will prompt you with the ability to set the size and color format of each layer. A good tutorial, with images, can be read here.
If anyone has any links or suggestions for creating multi-icon ICO files in other programs, feel free to add them. Also, I'm unsure if the Visual Studio built-in image editor can do it or not — I've rarely bothered with it.
Fixed the problem. I put the icon on the wrong form. As I don't think that this question will be of any help for anybody feel free to delete it.