divyavamsee / core-plot

Automatically exported from code.google.com/p/core-plot
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

CPTPlotSymbol image cropping on retina display #456

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a CPTPlotSymbol instance with an image as filling:

    UIImage *smallImage=[UIImage imageNamed:@"graph_point_small"];

    CPTPlotSymbol _smallSymbol=[CPTPlotSymbol rectanglePlotSymbol];
    _smallSymbol.fill = [CPTFill fillWithImage:[CPTImage imageWithCGImage:[smallImage CGImage] scale: 1.0]]; //note the scale value
    _smallSymbol.lineStyle=nil;
    _smallSymbol.size=CGSizeMake(20.0, 20.0);

and plot anything with it on both retina and non-retina (or a simulator) 
devices. In my case (iPad 3 and iPad simulator (iOS v 5.1)) i got absolutely 
different plot symbol appearances (see the attachment). It looks as expected on 
simulator and cropped on retina device.
2. Change the scale value to 2.0 and plot again. This makes the image look ok 
on retina device and two times smaller on normal one.

What is the expected output? What do you see instead?
I expected the plot symbol to be the same size on both retina device and 
simulator. I got it two times bigger than normal on the first one.

What version of the product are you using? On what operating system?
I'm using Core-Plot 1.0 on iOS 5.1. 

Please provide any additional information below.

Original issue reported on code.google.com by ar...@stepinmobile.com on 30 Aug 2012 at 3:03

Attachments:

GoogleCodeExporter commented 9 years ago
That's how the scale works. Try this:

_smallSymbol.fill = [CPTFill fillWithImage:[CPTImage 
imageWithCGImage:[smallImage CGImage] scale: [smallImage scale]]];

Original comment by eskr...@mac.com on 31 Aug 2012 at 12:03

GoogleCodeExporter commented 9 years ago
We had the same thing, just one day after you posted this. We fixed it on our 
side. Here is the trick:

CPTImage *redCustomSymbol = [CPTImage imageWithCGImage:[[UIImage 
imageNamed:@"name.png"] CGImage] scale:[[UIImage imageNamed:@"name.png"] 
scale]];

Plus we add another image with double width and height and resolution (so from 
e.g. 20x20 res. 72 -> 40x40 res 144. ) Following the iOS conventing, we name 
that image name@2x.png

Let me know if it works.

Original comment by cornelis...@gmail.com on 31 Aug 2012 at 9:56

GoogleCodeExporter commented 9 years ago
Sorry for late response, confirming, i did the same thing and it worked.

Original comment by ar...@stepinmobile.com on 26 Sep 2012 at 7:08