FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
RDPSessionView.m
1/*
2 RDP Session View
3
4 Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
6 This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7 If a copy of the MPL was not distributed with this file, You can obtain one at
8 http://mozilla.org/MPL/2.0/.
9 */
10
11#import "RDPSessionView.h"
12
13@implementation RDPSessionView
14
15- (void)setSession:(RDPSession *)session
16{
17 _session = session;
18}
19
20- (void)awakeFromNib
21{
22 [super awakeFromNib];
23 _session = nil;
24}
25
26- (void)drawRect:(CGRect)rect
27{
28 if (_session != nil && [_session bitmapContext])
29 {
30 CGContextRef context = UIGraphicsGetCurrentContext();
31 CGImageRef cgImage = CGBitmapContextCreateImage([_session bitmapContext]);
32
33 CGContextTranslateCTM(context, 0, [self bounds].size.height);
34 CGContextScaleCTM(context, 1.0, -1.0);
35 CGContextClipToRect(context,
36 CGRectMake(rect.origin.x,
37 [self bounds].size.height - rect.origin.y - rect.size.height,
38 rect.size.width, rect.size.height));
39 CGContextDrawImage(context,
40 CGRectMake(0, 0, [self bounds].size.width, [self bounds].size.height),
41 cgImage);
42
43 CGImageRelease(cgImage);
44 }
45 else
46 {
47 // just clear the screen with black
48 [[UIColor blackColor] set];
49 UIRectFill([self bounds]);
50 }
51}
52
53- (void)dealloc
54{
55 [super dealloc];
56}
57
58@end