Giter VIP home page Giter VIP logo

aggeometrykit's People

Contributors

artembartle avatar ciphercom avatar coeur avatar gavrix avatar hfossli avatar hfossli-agens avatar jalmaas-agens avatar jflinter avatar mariovillamizar avatar mikeabdullah avatar richardtop avatar skagedal avatar snown avatar valeriyvan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aggeometrykit's Issues

tvOS

Can you add support for tvOS on the podspec ?

Thanks.

imageWithPerspectiveCorrectionFromQuad scale problem.

I noticed an issue with UIImage scale and "imageWithPerspectiveCorrectionFromQuad". If I pass an image with scale factor 3.0f (iPhone6 Plus) it crops only portion of an image. As far as I traced the rects it appears to act weird here:

(Line 164:) UIImage *correctedImage = [self imageWithTransform:transform anchorPoint:CGPointZero];
(Line 165:) UIImage *resultImage = [correctedImage imageByCroppingToRect:destinationRect];

Here, imageWithTransform returns an image with scale 1.0f (so its size in points = size in pixels) and destinationRect is still in points. So the result image is 1/3 upper part of the source image.

Of course, you can always transform your @3x image into @1x by drawing it to image context with scale 1.0 and triple source size. However in situation where you're really low on available memory this could be a hussle.

Incorrect definition for AGKQuadInsetBottom

AGKQuad AGKQuadInsetBottom(AGKQuad q, CGFloat inset)
{
q.tl.y -= inset;
q.tr.y -= inset;
return q;
}

Shouldn't this say q.bl.y and q.br.y ? Can you please push a new fix on CocoaPods or should I create a pull request with the fix?

README sample / example animation code probably needs updating

You basically can't just copy/paste the README sample code. Took me looking at this for a minute to see the difference, but in the readme the animateFromPresentedStateToQuadrilateral:... method signature uses interpolationFunction:, but in the actual method, it's easeFunction:.

Also, and this is only tangentially related: (Note that I don't use cocoapods, so I don't know what happens if you use that, but...) I basically just drug the AGGeometryKit folder into my project, and that was a sub-par experience for a couple of reasons:

  1. It added all the tests to my project, which require SenTestingKit
  2. It didn't include those handy easing functions in easing.h & .c

Not sure if you want to do anything about those issues, they were easy to fix, just mentioning 'em.

Demo Quad Example Crashes with Xcode 6 Beta and Simulator

Firstly, I would like to state that I understand that this issue is in the Xcode beta, and therefore should be treated as low priority. I did check that this issue does not occur in Xcode 5 with the iOS 7.1 Simulator.

That being said I am experiencing an issue with Xcode 6 and the iOS 8 Simulator and the quad demo where dragging from any corner other than the upper left results in a crash. Here's what I'm seeing:
screenshot 2014-06-11 17 30 40

And the console in text:

2014-06-11 17:30:17.257 AGGeometryKit[14762:346482] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSSetM addObject:]: object cannot be nil'
*** First throw call stack:
(
    0   CoreFoundation                      0x01e1b916 __exceptionPreprocess + 182
    1   libobjc.A.dylib                     0x01ab98d9 objc_exception_throw + 44
    2   CoreFoundation                      0x01d3152b -[__NSSetM addObject:] + 699
    3   UIKit                               0x0032570c _UIApplicationHandleEventFromQueueEvent + 1522
    4   UIKit                               0x002feb64 _UIApplicationHandleEventQueue + 1561
    5   CoreFoundation                      0x01d4030f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    6   CoreFoundation                      0x01d34c99 __CFRunLoopDoSources0 + 249
    7   CoreFoundation                      0x01d341f8 __CFRunLoopRun + 952
    8   CoreFoundation                      0x01d33b7b CFRunLoopRunSpecific + 443
    9   CoreFoundation                      0x01d339ab CFRunLoopRunInMode + 123
    10  GraphicsServices                    0x03922500 GSEventRunModal + 192
    11  GraphicsServices                    0x0392233d GSEventRun + 104
    12  UIKit                               0x00302dee UIApplicationMain + 3727
    13  AGGeometryKit                       0x0000b11c main + 76
    14  libdyld.dylib                       0x034a9ac5 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Dragging from the upper left handle seemed to work. Additionally all of the other demos seemed to work.

Thanks for taking a look, please let me know if I can provide any more information, or help out in any way.

Anti-aliasing approaches

Hi and first of all thanks for that magnificent library!
I've started playing around with it a bit and realized that the edges of my transformed image happen to be quite.. rough.
Do you have any suggestions how it would be possible to implement some anti-aliasing, especially for the edges? Thanks a lot for any hints.

Memory leaks

  1. "AGKMatrix.h"
- (NSNumber *)defaultMember {
	if (!_defaultMember) { // **Converting a pointer value of type 'NSNumber *' to a primitive boolean value; instead, either compare the pointer to nil or call -boolValue**
		_defaultMember = @0; 
	}
	
	return [_defaultMember copy];
}

- (void)resetMatrixToDefault:(NSNumber *)defaultValue {
    if (defaultValue) { // **Converting a pointer value of type 'NSNumber *' to a primitive boolean value; instead, either compare the pointer to nil or call -boolValue**
        self.defaultMember = defaultValue;
    }
	self.members = nil;
}

- (NSArray *)allMembers {
    NSMutableArray *allMembers = [NSMutableArray arrayWithCapacity:self.count];
    for (NSUInteger index = 0; index < self.count; index++) {
        [allMembers addObject:self[index]]; // **Argument to 'NSMutableArray' method 'addObject:' cannot be nil**
    }
    
    return allMembers;
}
  1. "UIImage+AGKQuad.h"
- (UIImage *)imageByCroppingToRect:(CGRect)rect
{
    CGImageRef croppedImage = CGImageCreateWithImageInRect([self CGImage], rect);
    return [UIImage imageWithCGImage:croppedImage scale:self.scale orientation:self.imageOrientation]; // **Potential leak of an object stored into 'croppedImage'**
}

Save image to album

Hello, first congratulations for the project. Sorry for my English.

I tried to save the image in the album but does not save the transformed image.

UIImageWriteToSavedPhotosAlbum([self captureView:self.view], self, @selector(image:didFinishSavingWithError:contextInfo:), nil);

- (UIImage *)captureView:(UIView *)view
{
    CGRect rect = [self.view bounds]; 
    UIGraphicsBeginImageContextWithOptions(rect.size, YES, 0.0);
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return viewImage;
}

Thank you very much.

Linker errors building Demo

Getting a bunch of linker errors trying to run Demo on a device (iPad mini, iOS 8.2).
Can't guess how to fix this.

Possible to perspective-distort an image?

I need to take an image and transform it into a new quad to give the image a perspective distortion. I want to take a rectangular image and skew. So far I haven't been able to determine how to do this. Ideally this transformation would not require the image to be added to a view since my purposes don't require me to display the image on the screen but do require me to process hundreds of these as fast as possible.

I appreciate any help or advice, thanks!

How can I get the final result as UIView or UIImageView

I would like to make 3D transform with one image, then merge with another image and save the final result into photo album.

But I can't get the transformed quad view as I want. It only get the original view.

Any help?

NSValue+AGQuad is not NSCoder friendly

Hi, thank you for this very useful project.

I've run into a minor issue resolving which would make the library better: NSValue+AGQuad encoding is based on union type and thus not NSCoder friendly.

I'm not sure what is the most elegant way of fixing this.

Rendering CATransform3d image has issues

Hello , Thanks for providing AGGeometryKit ,
Well i am facing issues in saving CAtransformed3d Image view i am using the following code

AGQuad quad = AGQuadMakeWithCGPoints(self.topLeftControl.frame.origin,
self.topRightControl.frame.origin,
self.bottomRightControl.frame.origin,
self.bottomLeftControl.frame.origin);
UIImage *rawImage = [self.imageView.image imageWithQuad:quad scale:1];

but the return image has cropped corner
after saving the bottom right corner issue
original image after transforming

Rotate around point and scale

Hello. Thanks for a great work.

I'd like to implement some additional functionality. I want user to interact with view by pinch and rotate gestures. I've implemented it.

var initialQuadrilateral: AGKQuad?

@IBAction func handlePinch(_ recognizer : UIPinchGestureRecognizer) {
    if (recognizer.state == .began) {
        initialQuadrilateral = target.layer.quadrilateral
    }
    
    let transform = CGAffineTransform.identity.scaledBy(x: recognizer.scale, y: recognizer.scale)
    target.layer.quadrilateral = AGKQuadApplyCGAffineTransform(initialQuadrilateral!, transform)
    
    updateControlPoints()
}

@IBAction func handleRotation(_ recognizer : UIRotationGestureRecognizer) {
    if (recognizer.state == .began) {
        initialQuadrilateral = target.layer.quadrilateral
    }
    
    target.layer.quadrilateral = AGKQuadRotateAroundPoint(initialQuadrilateral!, target.frame, recognizer.rotation)
    
    updateControlPoints()
}

The only problem is that view rotates and scales around zero anchor point instead of center. Could you provide an example of how to implement expected behavior.

AGTransformPixelMapper does not work with padded images

AGTransformPixelMapper assumes that bytesPerRow == 4 * width. This frequently isn't the case - CGImages are often padded for 16byte alignment. For example, 300x150 UIImage captured with UIGraphicsGetImageFromCurrentImageContext has row width of 1216. Thus, CGImageGetBytesPerRow should be used to determine alignment of input bitmap.

imageWithPerspectiveCorrectionFromQuad corrupts source image

Hi!
I've been playing with 'imageWithPerspectiveCorrectionFromQuad' function to perform perspective correction for images and faced lots of cases when source image was corrupted. I spent some time debugging and found out that "aspectRatioForQuad" returned 'NaN' sometimes. Further digging led me to 'NaN' in sqrt operation caused by negative 'f2' param in '' f2 = step1 * (step2 + step3) ", where 'step1' and 'step2' were positive and 'step3' was negative.
Here's the quad:
AGKQuad {
tl: {212.51999437014263, 233.44500000000016},
tr: {877.67997674942012, 217.19250000000011},
br: {1023.9599728743235, 1668.0975000000001},
bl: {91.079997587203991, 1693.2150000000001}
}
Source image size is: (width = 1242, height = 1773))

Unfortunately, this is a gamestopper for me.
I hope this info is usefull.

3D Transform with UIImage Quad Calculation Methods

In the example code you have a tab that transforms a skewed section of a given UIImage back to square (the "AGKCATransform3DWithUIImageExample"). In that example you provide a couple hard coded quads with a comment that you are working on a way to calculate those numbers for image adjustment.

Has there been any progress in this area? Or do you have any math resources that I could look at and maybe provide a pull request?

Thanks!

Cocoapods Installation Issue

When attempting to install via cocoapods, I get the following error running pod install:

[!] Unable to satisfy the following requirements:

  • AGAssert (~> 0.2) required by AGGeometryKit/Dependencies (1.0.4)

Multiple Drag points + Video

In your demo video you show an image with 4 corners being dragged and morphed.
Is it possible to have more than one drag point to transform the view ? also is it possible to load a video inside instead of an image ?

Issue with UIButton as subview after quad animation

I have a UIView that I'm moving around with the following:

    [self.layer animateFromPresentedStateToQuadrilateral:quad
                                                 forNumberOfFrames:duration * 60
                                                          duration:duration
                                                             delay:0.0
                                                           animKey:@"demo"
                                                      easeFunction:interpolationFunction
                                                        onComplete:onComplete];

(Code mostly stolen from the sample project.)

Anyway, the UIView contains a UIButton, and the button essentially does not receive touches after the quad animation. I've tried a couple of things in the onComplete, and verified that the button is still enabled, but using the following workaround for now:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint touchLocation = [touch locationInView:self.view];
    if ([self.gameMenuButton.layer.presentationLayer hitTest:touchLocation])
    {
        [self gameMenuButtonPressed:nil];
    }
}

Auto-layout

When you apply auto-layout and make all constrains, everything broke for crop action.

Transformation not applied?

Hey,

first of all thanks for this great toolkit!
I tried to use AGGeometryKit in Playground, but no transformation seems to be applied, if I look at the result. What I'm doing wrong? Thanks in advance!

Here is my code:

import UIKit
import XCPlayground
import AGGeometryKit

var rect = CGRectMake(0, 0, 200, 200)
var rect2 = CGRectMake(0, 0, 100, 100)

var topView: UIView = UIView(frame: rect);
var test: UIView;
test = UIView(frame: rect2);
test.backgroundColor = UIColor.blueColor()
test.layer.anchorPoint = CGPoint(x: 0,y: 0);

var quad: AGKQuad;
quad = test.layer.quadrilateral;
quad.tr.x += 200; // shift bottom right x-value with 20 pixels
quad.br.y += 20; // shift bottom right y-value with 50 pixels

test.layer.quadrilateral = quad;
topView.addSubview(test);
topView.bringSubviewToFront(test)

Repo moved

We've moved the repo to agens-no organization. Let me know if there's any issues regarding this transfer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.