0

I have a feature, I want to take a screenshot of a UIView(called "arrangeView" in my codes). and send the picture to my server, and then I will print it, so I want a high quantity picture..

My codes:

 UIGraphicsBeginImageContext(arrangeView.frame.size);
    [arrangeView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    //save and send method
    [self saveImage:newImage WithName:imgTitle];

With these codes I have 2 issues:

  1. the picture quality is too low. because after I uploaded to the server, I will print it. but the picture I got with the codes only 20~40k, it is too small to print.

  2. one friend told me that the app store don't alow app take a screenshot and send it to the server. he told me to use bitmap.

And I searched in google, I don't find a good solution for it. Would someone help?

Thank you very much.

yang wang
  • 9
  • 3

2 Answers2

1

Screen shot you get will be of same resolution as you main screen size i.e If it is iPhone 5s it will be 640 x 1136. Best way to get screen shot is:

UIView *screenShotView = [arrangeView snapshotViewAfterScreenUpdates:YES];

sschunara
  • 2,265
  • 23
  • 31
-1

Please try to use the code below.you may save first in photo album and then you can send to server

UIView* captureView = self.view;

/* Capture the screen shoot at native resolution */
UIGraphicsBeginImageContextWithOptions(captureView.bounds.size, captureView.opaque, 0.0);
[captureView.layer renderInContext:UIGraphicsGetCurrentContext()];
  UIImage * screenshot = UIGraphicsGetImageFromCurrentImageContext();
 UIGraphicsEndImageContext();

 /* Render the screen shot at custom resolution */
    CGRect cropRect = CGRectMake(0 ,0 ,1435 ,1435);
    UIGraphicsBeginImageContextWithOptions(cropRect.size, captureView.opaque, 1.0f);
  [screenshot drawInRect:cropRect];
    UIImage * customScreenShot = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

  /* Save to the photo album */
   UIImageWriteToSavedPhotosAlbum(customScreenShot , nil, nil, nil);
senthilM
  • 9,414
  • 18
  • 77
  • 140