mirror of
https://github.com/purplecabbage/phonegap-plugins.git
synced 2026-01-13 00:18:13 -05:00
32 lines
989 B
Objective-C
32 lines
989 B
Objective-C
//
|
|
// Screenshot.h
|
|
//
|
|
// Created by Simon Madine on 29/04/2010.
|
|
// Copyright 2010 The Angry Robot Zombie Factory.
|
|
// MIT licensed
|
|
//
|
|
|
|
#import "Screenshot.h"
|
|
@implementation Screenshot
|
|
|
|
- (void)saveScreenshot:(NSArray*)arguments withDict:(NSDictionary*)options
|
|
{
|
|
CGRect screenRect = [[UIScreen mainScreen] bounds];
|
|
CGRect imageRect = CGRectMake(0, 0, CGRectGetWidth(screenRect), CGRectGetHeight(screenRect));
|
|
UIGraphicsBeginImageContext(imageRect.size);
|
|
|
|
CGContextRef ctx = UIGraphicsGetCurrentContext();
|
|
[[UIColor blackColor] set];
|
|
CGContextTranslateCTM(ctx, 0, 0);
|
|
CGContextFillRect(ctx, imageRect);
|
|
|
|
[webView.layer renderInContext:ctx];
|
|
|
|
UIImage *image1 = UIGraphicsGetImageFromCurrentImageContext();
|
|
UIImageWriteToSavedPhotosAlbum(image1, nil, nil, nil);
|
|
UIGraphicsEndImageContext();
|
|
UIAlertView *alert= [[UIAlertView alloc] initWithTitle:nil message:@"Image Saved" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
|
|
[alert show];
|
|
[alert release];
|
|
}
|
|
@end |