Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 9
    • Component/s: client-libs
    • Labels:
    • Resolved In Build:
      b06

      Backports

        Description

        This is a request for HiDPI support for custom cursors.
        See http://mail.openjdk.java.net/pipermail/macosx-port-dev/2013-November/006211.html

        http://docs.oracle.com/javase/6/docs/api/java/awt/Toolkit.html#createCustom
        Cursor(java.awt.Image, java.awt.Point, java.lang.String)
        1. image.png
          0.1 kB
        2. image2.png
          0.1 kB

          Issue Links

            Activity

            Hide
            alexsch Alexander Scherbatiy (Inactive) added a comment -
            I have 2 files which contain a cursor image with different sizes.
            If NSImage is created with representations from these files and set NSCursor, the first image is always shown on both non-Retian and Retina display (I use the Quartz Debug).
            If representations size is divided by the screen scale factor
            ---------
              NSSize size = [imgRep size];
              [imgRep setSize:NSMakeSize(size.width /scaleFactor, size.height / scaleFactor)];
            --------
            the high-resolution image is correctly shown for the NSCursor on Retina display.

            See the samples.

            NSImage representations are not scaled. The bigger image is not shown for the cursor on Retina:
            ------------------------------------
            - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
            {
                [self performSelector:@selector(doChangeCursor) withObject:nil afterDelay:1];
            }


            - (void) showRepresentations: (NSImage *) image {

                NSImageRep *img = nil;
                NSArray *images = [image representations];
                NSEnumerator *imageEnumerator = [images objectEnumerator];
                while ((img = [imageEnumerator nextObject]) != nil) {
                    NSSize size = [img size];
                    NSLog(@"Image variant size[%f, %f]", size.width, size.height);
                }

            }

            - (void) doChangeCursor
            {
                
                NSString *file = @"/tmp/cursor/image.png";
                NSString *file2x = @"/tmp/cursor/image2.png";
                NSImage *image = [[NSImage alloc] initWithContentsOfFile:file];
                NSImage *image2x = [[NSImage alloc] initWithContentsOfFile:file2x];
                
                [image addRepresentations: [image2x representations]];
                [self showRepresentations:image];
                //[self rescaleRepresentations:image];
                
                NSCursor *cursor = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint(0, 0)];
                [cursor set];
                
            }
            ------------------------------------

            NSImage representations are scaled. The bigger image is correctly shown for the cursor on Retina:
            ------------------------------------
            - (void) rescaleRepresentations: (NSImage *) image {
                
                NSImageRep *img = nil;
                NSArray *images = [image representations];
                NSEnumerator *imageEnumerator = [images objectEnumerator];
                int scaleFactor = 1;
                while ((img = [imageEnumerator nextObject]) != nil) {
                    NSSize size = [img size];
                    NSLog(@"Image variant size[%f, %f]", size.width, size.height);
                    [img setSize:NSMakeSize(size.width /scaleFactor, size.height / scaleFactor)];
                    size = [img size];
                    NSLog(@"Image updated size[%f, %f]", size.width, size.height);
                    scaleFactor++;
                }
            }

            - (void) doChangeCursor
            {
                
                NSString *file = @"/tmp/cursor/image.png";
                NSString *file2x = @"/tmp/cursor/image2.png";
                NSImage *image = [[NSImage alloc] initWithContentsOfFile:file];
                NSImage *image2x = [[NSImage alloc] initWithContentsOfFile:file2x];
                
                [image addRepresentations: [image2x representations]];
                //[self showRepresentations:image];
                [self rescaleRepresentations:image];
                
                NSCursor *cursor = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint(0, 0)];
                [cursor set];
                
            }
            Show
            alexsch Alexander Scherbatiy (Inactive) added a comment - I have 2 files which contain a cursor image with different sizes. If NSImage is created with representations from these files and set NSCursor, the first image is always shown on both non-Retian and Retina display (I use the Quartz Debug). If representations size is divided by the screen scale factor ---------   NSSize size = [imgRep size];   [imgRep setSize:NSMakeSize(size.width /scaleFactor, size.height / scaleFactor)]; -------- the high-resolution image is correctly shown for the NSCursor on Retina display. See the samples. NSImage representations are not scaled. The bigger image is not shown for the cursor on Retina: ------------------------------------ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {     [self performSelector:@selector(doChangeCursor) withObject:nil afterDelay:1]; } - (void) showRepresentations: (NSImage *) image {     NSImageRep *img = nil;     NSArray *images = [image representations];     NSEnumerator *imageEnumerator = [images objectEnumerator];     while ((img = [imageEnumerator nextObject]) != nil) {         NSSize size = [img size];         NSLog(@"Image variant size[%f, %f]", size.width, size.height);     } } - (void) doChangeCursor {          NSString *file = @"/tmp/cursor/image.png";     NSString *file2x = @"/tmp/cursor/image2.png";     NSImage *image = [[NSImage alloc] initWithContentsOfFile:file];     NSImage *image2x = [[NSImage alloc] initWithContentsOfFile:file2x];          [image addRepresentations: [image2x representations]];     [self showRepresentations:image];     //[self rescaleRepresentations:image];          NSCursor *cursor = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint(0, 0)];     [cursor set];      } ------------------------------------ NSImage representations are scaled. The bigger image is correctly shown for the cursor on Retina: ------------------------------------ - (void) rescaleRepresentations: (NSImage *) image {          NSImageRep *img = nil;     NSArray *images = [image representations];     NSEnumerator *imageEnumerator = [images objectEnumerator];     int scaleFactor = 1;     while ((img = [imageEnumerator nextObject]) != nil) {         NSSize size = [img size];         NSLog(@"Image variant size[%f, %f]", size.width, size.height);         [img setSize:NSMakeSize(size.width /scaleFactor, size.height / scaleFactor)];         size = [img size];         NSLog(@"Image updated size[%f, %f]", size.width, size.height);         scaleFactor++;     } } - (void) doChangeCursor {          NSString *file = @"/tmp/cursor/image.png";     NSString *file2x = @"/tmp/cursor/image2.png";     NSImage *image = [[NSImage alloc] initWithContentsOfFile:file];     NSImage *image2x = [[NSImage alloc] initWithContentsOfFile:file2x];          [image addRepresentations: [image2x representations]];     //[self showRepresentations:image];     [self rescaleRepresentations:image];          NSCursor *cursor = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint(0, 0)];     [cursor set];      }
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/9ec9b887673e
            User: alexsch
            Date: 2014-01-09 14:39:09 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/9ec9b887673e User: alexsch Date: 2014-01-09 14:39:09 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/9ec9b887673e
            User: lana
            Date: 2014-03-25 20:49:04 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/9ec9b887673e User: lana Date: 2014-03-25 20:49:04 +0000

              People

              • Assignee:
                alexsch Alexander Scherbatiy (Inactive)
                Reporter:
                alexsch Alexander Scherbatiy (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: