mindbrix / UIImage-PDF

Simple UIImage PDF renderer category for iOS scalable assets

Home Page:http://blog.mindbrix.co.uk/2012/02/10/ios-scalable-assets/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PDF images are displayed upside down

vanderneut opened this issue · comments

Hi Nigel,

I cannot tell you how excited I am to have your UIImage+PDF. This is an amazing tool in simplifying the image asset management, especially now with the introduction of @3x for the iPhone 6 Plus.

Back in January 2012, algal reported having his images displayed upside down. You replied you had never experienced that issue, and he figured out that it was caused by assigning it to the layer's background instead of the view's background.

In my project I have replaced several UIImage creation lines of code with your imageWithPDFNamed:fitSize: and imageWithPDFNamed:atWidth, and the PDFs are displaying beautifully, but strangely enough all upside down :-( So far I have not been able to figure out what I possibly could have done wrong. Would you have any inkling as to how I should go about debugging this..?

I can't attach examples of my PDF files -- it says "Unfortunately, we don't support that file type. Try again with a PNG, GIF, or JPG.", but all my PDFs are small in size.

Thanks so much,
Erik

Same problem here. Trying to use this with SKTexture, but everything
appears upside down.

On Friday, October 10, 2014, Erik van der Neut notifications@github.com
wrote:

Hi Nigel,

I cannot tell you how excited I am to have your UIImage+PDF. This is an
amazing tool in simplifying the image asset management, especially now with
the introduction of @3x https://github.com/3x for the iPhone 6 Plus.

Back in January 2012, algal reported having his images displayed upside
down. You replied you had never experienced that issue, and he figured out
that it was caused by assigning it to the layer's background instead of the
view's background.

In my project I have replaced several UIImage creation lines of code with
your imageWithPDFNamed:fitSize: and imageWithPDFNamed:atWidth, and the PDFs
are displaying beautifully, but strangely enough all upside down :-( So far
I have not been able to figure out what I possibly could have done wrong.
Would you have any inkling as to how I should go about debugging this..?

I can't attach examples of my PDF files -- it says "Unfortunately, we
don't support that file type. Try again with a PNG, GIF, or JPG.", but all
my PDFs are small in size.

Thanks so much,
Erik


Reply to this email directly or view it on GitHub
#30.

What I'm doing is I think really basic stuff, for example setting button images:

UIImage *replayButtonImage = [UIImage imageWithPDFNamed:@"ec-control-button-replay.pdf" atWidth:120];
[_replayButton setImage:replayButtonImage forState:UIControlStateNormal];

Or something as simple as setting the image on a UIImageView:

_backgroundImageView.image = [UIImage imageWithPDFNamed:@"ec_background_mode.pdf" atSize:self.frame.size];

All images are rendering beautifully and at the right size. It's just that they are all upside down.
I'll keep moving forward with my implementation, but I will need a solution for this to complete this.

Anybody else out there who has experienced this and might have an idea what it could be?

Erik

Hi Erik. Thanks for your feedback. I've just pushed a commit: 3be234d that should fix your problem.

Nigel.

Hi Nigel,

I just came back here to tell you that if I commented out the following two lines, that all images appear correctly:

CGContextScaleCTM( ctx, 1, -1 );
CGContextTranslateCTM( ctx, 0, -size.height );

And now I see you have made that same change already and committed it.

Thanks so much!

Now, I'm just curious why that code was in there. In the 2012 thread with algal I see now that you referred to those lines as well. There must have been a deliberate intent behind that flipping.

Thanks for any further insights you can share. Either way: your UIImage+PDF is making me extremely happy - just so you know :-)

Erik

Hi Erik. Great minds think alike ;-)

The flipping code is now redundant, as I now create the drawing context with CGBitmapContextCreate() instead of UIGraphicsBeginImageContextWithOptions(). The latter transforms the context differently.

Nigel.