Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions TYSnapshotScroll/TYSnapshotAuxiliary/TYSnapshotAuxiliaryPDFTool.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,18 @@ + (void)getPdfImageWithUrl:(NSURL *)fileUrl finishBlock:(void(^)(UIImage *image)

UIImage *image;
if (!CGRectEqualToRect(rect, CGRectNull)) {
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
CGAffineTransform drawingTransform = CGPDFPageGetDrawingTransform(page, kCGPDFCropBox, rect, 0, true);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextConcatCTM(ctx, drawingTransform);
CGContextDrawPDFPage(ctx, page);
image = UIGraphicsGetImageFromCurrentImageContext();
image = [UIImage imageWithCGImage:image.CGImage scale:1.0f orientation:UIImageOrientationDownMirrored];
UIGraphicsEndImageContext();
if (rect.size.width <= 0.0 || rect.size.height <= 0.0) {
image = nil;
} else {
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
CGAffineTransform drawingTransform = CGPDFPageGetDrawingTransform(page, kCGPDFCropBox, rect, 0, true);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextConcatCTM(ctx, drawingTransform);
CGContextDrawPDFPage(ctx, page);
image = UIGraphicsGetImageFromCurrentImageContext();
image = [UIImage imageWithCGImage:image.CGImage scale:1.0f orientation:UIImageOrientationDownMirrored];
UIGraphicsEndImageContext();
}
}


Expand Down
4 changes: 4 additions & 0 deletions TYSnapshotScroll/TYSnapshotAuxiliary/TYSpellImage.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
@implementation TYSpellImage

+ (UIImage *)tya_spellImageOf:(CGSize )imageSize paths:(NSArray <NSString *> *)paths{
if (imageSize.width <= 0.0 || imageSize.height <= 0.0) {
return nil;
}

UIGraphicsBeginImageContextWithOptions(imageSize, YES, 0.0);

CGFloat drawHeight = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ - (void )tya_scrollToDraw:(NSInteger )index maxIndex:(NSInteger )maxIndex finish

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(self.delayTime * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

if (snapshotSize.width <= 0.0 || snapshotSize.height <= 0.0) {
!finishBlock?:finishBlock();
return;
}
UIGraphicsBeginImageContextWithOptions(snapshotSize, NO, [UIScreen mainScreen].scale);

[snapshotView drawViewHierarchyInRect:snapshotBounds afterScreenUpdates:YES];
Expand Down
4 changes: 4 additions & 0 deletions TYSnapshotScroll/Tools/UIImage+TYSnapshot.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ + (UIImage *)getImageFromImagesArray:(NSArray *)imagesArr
UIImage *image;
@autoreleasepool{
CGSize imageTotalSize = [self getImageTotalSizeFromImagesArray:imagesArr];
if (imageTotalSize.width <= 0.0 || imageTotalSize.height <= 0.0) {
return nil;
}

UIGraphicsBeginImageContextWithOptions(imageTotalSize, NO, [UIScreen mainScreen].scale);

//拼接图片
Expand Down
5 changes: 5 additions & 0 deletions TYSnapshotScroll/UIScrollView+TYSnapshot.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ - (void )snapshotNormalImageWith:(UIView *)snapshotMaskView contentSize:(CGSize

CGFloat delayTime = [TYSnapshotManager defaultManager].delayTime;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayTime * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (self.layer.frame.size.width <= 0.0 || self.layer.frame.size.height <= 0.0) {
if (finishBlock) finishBlock(nil);
return;

}
UIImage* snapshotImage = nil;

self.contentOffset = CGPointZero;
Expand Down
5 changes: 5 additions & 0 deletions TYSnapshotScroll/UIScrollView+TYSplice.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ - (void )snapshotSpliceImageWith:(UIView *)snapshotMaskView contentSize:(CGSize
self.contentOffset = CGPointZero;
scrollViewBounds = self.bounds;
});

if (contentSize.width <= 0.0 || contentSize.height <= 0.0) {
!finishBlock?:finishBlock(nil);
return;
}

//计算快照屏幕数
NSUInteger snapshotScreenCount = floorf(contentSize.height / scrollViewBounds.size.height);
Expand Down
5 changes: 5 additions & 0 deletions TYSnapshotScroll/UITextView+TYSnapshot.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ - (void )snapshotNormalImageWith:(UIView *)snapshotMaskView contentSize:(CGSize

CGFloat delayTime = [TYSnapshotManager defaultManager].delayTime;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayTime * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (self.layer.frame.size.width <= 0.0 || self.layer.frame.size.height <= 0.0) {
if (finishBlock) finishBlock(nil);
return;

}
UIImage* snapshotImage = nil;

self.contentOffset = CGPointZero;
Expand Down
5 changes: 5 additions & 0 deletions TYSnapshotScroll/UIView+TYSnapshot.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ - (void )screenSnapshotNeedMask:(BOOL)needMask addMaskAfterBlock:(void(^)(void))
selfLayer = self.layer;
});

if (bounds.size.width <= 0.0 || bounds.size.height <= 0.0) {
if (finishBlock) finishBlock(nil);
return;
}

UIGraphicsBeginImageContextWithOptions(bounds.size,NO,[UIScreen mainScreen].scale);

CGContextRef context = UIGraphicsGetCurrentContext();
Expand Down