GeekWorkCode / core-plot

Automatically exported from code.google.com/p/core-plot
0 stars 0 forks source link

Handling of images in CPTFill wrt retina displays #492

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This problem already came up a while ago. See issus #315. However, the 
implementation is not yet really done.

1) When using image.png and image@2x.png XCode might combine them into 
image.tiff, which can no longer be loaded with CPTImage. Se we'd need support 
for tiff images as well or better: use the same approach like NSImage without 
the need to specify an extension.
2) Even if the images would not be combined you cannot easily specify the scale 
factor, because NSImage has no scale member. And even if we find out using e.g. 
NSScreen it has not much value. See point 3.
3) The loaded image is cached and not updated when the backing store changes, 
leading to a wrong fill image.

I'm on a MBP Pro 15" Retina with 10.8.

Original issue reported on code.google.com by mike.lischke on 6 Jan 2013 at 6:44

GoogleCodeExporter commented 8 years ago

Original comment by eskr...@mac.com on 6 Jan 2013 at 7:28

GoogleCodeExporter commented 8 years ago

Original comment by eskr...@mac.com on 1 Feb 2013 at 1:43

GoogleCodeExporter commented 8 years ago
After further research, this feature will have to wait until Core Plot supports 
a Mac OS X 10.6 deployment target (see issue 512). NSImage added some methods 
in 10.6 that will make implementation much easier and more efficient.

Original comment by eskr...@mac.com on 24 Feb 2013 at 5:20

GoogleCodeExporter commented 8 years ago

Original comment by eskr...@mac.com on 24 May 2013 at 6:29

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 6c8d55cd3a7e.

Original comment by eskr...@mac.com on 25 May 2013 at 12:42

GoogleCodeExporter commented 8 years ago
I don't think the solution is correct. It looks like only the scale factor is 
automatically adjusted, but not as if the @2x image would be loaded. Look at 
the screenshots below.

Original comment by mike.lischke on 25 May 2013 at 5:18

Attachments:

GoogleCodeExporter commented 8 years ago
The first image uses a normal resolution, the second one the retina hires.

Original comment by mike.lischke on 25 May 2013 at 5:19

GoogleCodeExporter commented 8 years ago

Original comment by eskr...@mac.com on 25 May 2013 at 9:01

GoogleCodeExporter commented 8 years ago
What method did you use to load the image? I added an +imageNamed: method that 
should work.

Original comment by eskr...@mac.com on 25 May 2013 at 10:18

GoogleCodeExporter commented 8 years ago
That's the code I use to load the image and set up the annotation layer:

    CPTImage *arrowImage = [CPTImage imageForPNGFile: [[NSBundle mainBundle] pathForResource: @"blue arrow" ofType: @"png"]];
    earningsArrowAnnotation = [[CPTLayerAnnotation alloc] initWithAnchorLayer: x1.axisTitle.contentLayer];
    earningsArrowAnnotation.rectAnchor = CPTRectAnchorTopLeft;
    earningsArrowAnnotation.displacement = CGPointMake(-15, -50);

    CPTBorderedLayer *layer = [[CPTBorderedLayer alloc] initWithFrame: CGRectMake(0, 0, 24, 27)];
    layer.fill = [CPTFill fillWithImage: arrowImage];

    earningsArrowAnnotation.contentLayer = layer;
    [earningsMiniPlot addAnnotation: earningsArrowAnnotation];

Original comment by mike.lischke on 26 May 2013 at 8:32

GoogleCodeExporter commented 8 years ago
I see, using imageNamed: the display is correct. So your fix seems to work as 
expected. It might better to deprecate the old API to make the transition more 
obvious.

Original comment by mike.lischke on 26 May 2013 at 8:43

GoogleCodeExporter commented 8 years ago
+imageForPNGFile: and -initForPNGFile: should still work on iOS. I'll see if I 
can fix them on Mac.

Original comment by eskr...@mac.com on 26 May 2013 at 12:10

GoogleCodeExporter commented 8 years ago
This issue was closed by revision d226040c9929.

Original comment by eskr...@mac.com on 7 Jun 2013 at 12:34

GoogleCodeExporter commented 8 years ago
I added + imageWithContentsOfFile: and -initWithContentsOfFile: methods to 
CPTImage. You can use these when Xcode combines your PNG files into a 
multi-part TIFF. +imageNamed: also works.

Original comment by eskr...@mac.com on 7 Jun 2013 at 12:38