From 4778f56a2461f93aa3312cd9eb425cc300928306 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 28 May 2020 16:58:53 +0300 Subject: [PATCH] Video editor fixes --- .../LegacyComponents/Sources/TGMediaVideoConverter.m | 10 +++++++++- .../LegacyComponents/Sources/TGPhotoPaintColorPicker.m | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/submodules/LegacyComponents/Sources/TGMediaVideoConverter.m b/submodules/LegacyComponents/Sources/TGMediaVideoConverter.m index 4aedabdf17..461b070444 100644 --- a/submodules/LegacyComponents/Sources/TGMediaVideoConverter.m +++ b/submodules/LegacyComponents/Sources/TGMediaVideoConverter.m @@ -10,6 +10,7 @@ #import "TGImageUtils.h" #import "TGPhotoEditorUtils.h" #import "PGPhotoEditor.h" +#import "TGPaintUtils.h" #import "TGPhotoPaintEntity.h" #import "TGVideoEditAdjustments.h" @@ -381,6 +382,7 @@ CIImage *resultImage = request.sourceImage; CGSize size; + CGPoint offset = CGPointZero; if (backgroundCIImage != nil) { resultImage = backgroundCIImage; size = backgroundCIImage.extent.size; @@ -388,7 +390,7 @@ size = resultImage.extent.size; CGRect cropRect = adjustments.cropRect; cropRect = CGRectMake(cropRect.origin.x, size.height - cropRect.size.height - cropRect.origin.y, cropRect.size.width, cropRect.size.height); - resultImage = [resultImage imageByCroppingToRect:cropRect]; + offset = CGPointMake(cropRect.origin.x, -cropRect.origin.y); } else { size = resultImage.extent.size; } @@ -409,10 +411,16 @@ for (CIImage *image in images) { mergedImage = [image imageByCompositingOverImage:mergedImage]; } + if (!CGPointEqualToPoint(offset, CGPointZero)) { + mergedImage = [mergedImage imageByApplyingTransform:CGAffineTransformMakeTranslation(offset.x, offset.y)]; + } [request finishWithImage:mergedImage context:ciContext]; unlock(); }]; } else { + if (!CGPointEqualToPoint(offset, CGPointZero)) { + resultImage = [resultImage imageByApplyingTransform:CGAffineTransformMakeTranslation(offset.x, offset.y)]; + } [request finishWithImage:resultImage context:ciContext]; unlock(); } diff --git a/submodules/LegacyComponents/Sources/TGPhotoPaintColorPicker.m b/submodules/LegacyComponents/Sources/TGPhotoPaintColorPicker.m index d8a40cd323..2b9221453e 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoPaintColorPicker.m +++ b/submodules/LegacyComponents/Sources/TGPhotoPaintColorPicker.m @@ -327,6 +327,11 @@ const CGFloat TGPhotoPaintDefaultColorLocation = 1.0f; { CGFloat colorLocation = MAX(0.0f, MIN(1.0f, self.frame.size.width > self.frame.size.height ? location.x / gestureRecognizer.view.frame.size.width : location.y / gestureRecognizer.view.frame.size.height)); [self setLocation:colorLocation animated:true]; + + if (self.finishedPicking != nil) + self.finishedPicking(); + + [self storeCurrentColorLocation]; } }