dzenbot / DZNPhotoPickerController

A photo search/picker for iOS using popular image providers like 500px, Flickr, Instagram, Giphy, Google & Bing Images
https://www.cocoacontrols.com/controls/dznphotopickercontroller
MIT License
1.51k stars 266 forks source link

Is there something wrong with the method - (UIImage *)trimmedImage:(UIImage *)image in DZNPhotoEditorViewController.m? #127

Open foolish-boy opened 8 years ago

foolish-boy commented 8 years ago

I use this method in my project and found some error.

I have some questions for this methods:

1: what does "loc" mean? why compute it like that?

2: In my project, i found that the top/bottom value may be wrong, which results in black edge in pic.

3: should cropRect.size be ((right.x - left.x + 1)/scale, (bottom.y - top.y + 1)/scale)?

i.stack.imgur.com/sFxlr.jpg i.stack.imgur.com/JOz1Z.jpg

foolish-boy commented 8 years ago

I finally found that the width is incorrect, and that just results in black edge.

in my project, i got 690 by method following: width = CGImageGetWidth(CGImageRef ) but i got 690 by other method like this: size_t bpr = CGImageGetBytesPerRow(inImage); //2784 size_t bpp = CGImageGetBitsPerPixel(inImage); // 32 size_t bpc = CGImageGetBitsPerComponent(inImage); //8 size_t bytes_per_pixel = bpp / bpc; // 4 size_t width = bpr / bytes_per_pixel;

I dont know why they are not equal.

dzenbot commented 8 years ago

The attachments do not work.

foolish-boy commented 8 years ago

yes, the attachments do not work, you just need know that there are black edges on bottom or top of pic.

I have fixed the problem by compute width like this: size_t width = bpr / bytes_per_pixel;

I dont know why, is it a bug?