//
//  ImageView.m
//  Image
//
//  Created by Bill Dudney on 12/12/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//
//
//  Licensed with the Apache 2.0 License
//  http://apache.org/licenses/LICENSE-2.0
//

#import "ImageView.h"


@implementation ImageView

//START:code.drawing.image.drawRect:
- (void)drawRect:(CGRect)rect {
  UIImage *image = [UIImage imageNamed:@"photo.png"]; //<label id="code.ImageView.drawRect.image"/>
  CGFloat idealSize = 300.0f;
  CGFloat ratio = 1.0f;
  CGFloat heightRatio = idealSize / image.size.height;
  CGFloat widthRatio = idealSize / image.size.width;  
  if(heightRatio < widthRatio) { //<label id="code.ImageView.drawRect.ratio"/>
    ratio = heightRatio;
  } else {
    ratio = widthRatio;
  }
  CGRect imageRect = CGRectMake(10.0f, 10.0f, image.size.width * ratio, 
                                image.size.height * ratio);
  [image drawInRect:imageRect blendMode:kCGBlendModeDifference alpha:1.0f];  //<label id="code.ImageView.drawRect.draw"/>
}
//END:code.drawing.image.drawRect:

- (void)dealloc {
    [super dealloc];
}


@end
