| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- //
- // ImageDrawable.m
- // pdftest
- //
- // Created by Ray on 10/13/16.
- // Copyright © 2016 United Software Applications, Inc. All rights reserved.
- //
- #import "ImageDrawable.h"
- #import "RAUtils.h"
- @implementation ImageDrawable
- -(CGRect) Query_Rect:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer
- {
- CGRect parentrect = [self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
-
- return parentrect;
- }
- -(CGRect) Draw:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer
- {
- // [super flipContext:context ContextHeight:flip_height];
-
- UIImage* image=nil;
- NSString * source=self.drawableTemplate[@"source_type"];
- if([source isEqualToString:@"const"])
- {
- image= [UIImage imageNamed:self.drawableTemplate[@"source"]];
-
- }
- else
- {
-
- // not impl;
-
- image=[UIImage imageNamed:data[self.drawableTemplate[@"source"]]];
- }
-
-
-
- // CGRect rect=[self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];//CGRectMake(self.rect.origin.x+x, self.rect.origin.y, self.rect.size.width, self.rect.size.height);
- // rect=CGRectMake(rect.origin.x, flip_height-rect.origin.y-rect.size.height, rect.size.width, rect.size.height);
-
- CGRect parentrect = [self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
-
-
-
- CGRect scalerect = [RAUtils scaleToSize:CGRectMake(0, 0, image.size.width, image.size.height) to:parentrect.size];
-
-
- CGRect rect=[RAUtils rectAlign:parentrect rect:scalerect hAlign:self.hAlign vAlign:self.vAlign];
-
- //image=[RAUtils scaleToSize:image size:parentrect.size];
- rect= [self parent_to_pdf_rect:rect contextHeight:flip_height];
- //CGRect rect = [self to_pdf_rect:p_rect pos:self.rect contextHeight:flip_height];
- CGContextDrawImage(context, rect, image.CGImage);
-
-
- [self DrawBound:context dataSource:data ParentRect:p_rect startX:x startY:y flipHeight:flip_height range:between_header_and_footer];
-
- return parentrect;
- // return CGPointMake(parentrect.origin.x+parentrect.size.width, parentrect.origin.y+parentrect.size.height);
-
- // // 切换上下文 Core Graphics 和 UIKit 混用
- // UIGraphicsPushContext(context);
- //
- // // 使用UIKit绘制内容
- // [image drawInRect:rect];
- //
- // // 绘制完位图后,再恢复上下文
- // UIGraphicsPopContext();
-
- // [super restoreFlip:context ContextHeight:flip_height];
- }
- @end
|