I am a bit confused by the loading of the BNR logo 2x in this exercise.
I have come across two different ways of loading the image and they seem to load a different size. Can anyone explain why?
- The below code produces an image size of 57 x 57.
Note: HomeDriveFilePath is a place holder for the actual file path on my hard drive.
BNRLogo = [[UIImage alloc] initWithContentsOfFile:@"<HomeDriveFilePath>/XcodeProjects/iOS Programming 3e Solutions/00. Resources/Icon@2x.png"]; CGSize logoSize = [BNRLogo size]; NSLog(@" Logo Size Width %f, Logo Size Height %f", logoSize.width, logoSize.height);
- The following code produces an image size of 114 x 114.
BNRLogo = [UIImage imageNamed:@"Icon@2x.png"]; CGSize logoSize = [BNRLogo size]; NSLog(@" Logo Size Width %f, Logo Size Height %f", logoSize.width, logoSize.height);
Lastly, I am curious as to the definition of the hypotenuse that is divided by 4.0 to find the max radius that fits within the rectangle. I used the size of my image (114 x 114) and found the circle was too small. Ultimately, i had to adjust to 3.0. Is the equation an estimation and therefore will require some adjustment for each rectangle size?
//The center point is determined by the Origin + .5 the height/width CGPoint logoCenter; logoCenter.x = 0 + logoSize.width/2.0; logoCenter.y = 0 + logoSize.height/2.0; float maxRadius = hypot((0 + logoSize.width), (0 + logoSize.height))/3.0;
However, the farther i move my origin away from (0,0) the better my circle fits around the image using the 4.0 value.
The same code is below updated with a starting origin of (35, 35) and fits perfectly.
CGPoint logoCenter; logoCenter.x = 35 + logoSize.width/2.0; logoCenter.y = 35 + logoSize.height/2.0; float maxRadius = hypot((35 + logoSize.width), (35 + logoSize.height))/4.0; //...more code... CGContextClip(ctx); [BNRLogo drawAtPoint:CGPointMake(35,35)];