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

render graph as UIImage #375

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I need to render graph as an UIImage in iOS, but it doesn't work.

I use this method for parent view.
- (UIImage*) renderToImage
{
    // IMPORTANT: using weak link on UIKit
    if(UIGraphicsBeginImageContextWithOptions != NULL)
    {
        UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, 0.0);
    } else {
        UIGraphicsBeginImageContext(self.frame.size);
    }
    [self.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();  
    return image;
}

The result has only the graph but doesn't have the number on the axis.

I use version 0.9. 

Original issue reported on code.google.com by tarakerat on 1 Dec 2011 at 2:27

Attachments:

GoogleCodeExporter commented 9 years ago
Can you use the -imageOfLayer method on the graph to create your image? If not, 
try -layoutAndRenderInContext: instead of -renderInContext: in your code above.

Original comment by eskr...@mac.com on 2 Dec 2011 at 2:39

GoogleCodeExporter commented 9 years ago
Oh It's work. Thank you so much.

Original comment by tarakerat on 2 Dec 2011 at 8:31

GoogleCodeExporter commented 9 years ago

Original comment by eskr...@mac.com on 2 Dec 2011 at 12:40