mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2025-07-22 12:13:35 +00:00
67 lines
1.7 KiB
Objective-C
67 lines
1.7 KiB
Objective-C
//
|
|
// StreamView.m
|
|
// Limelight-iOS
|
|
//
|
|
// Created by Diego Waxemberg on 1/18/14.
|
|
// Copyright (c) 2014 Diego Waxemberg. All rights reserved.
|
|
//
|
|
|
|
#import "StreamView.h"
|
|
|
|
@implementation StreamView {
|
|
size_t width;
|
|
size_t height;
|
|
size_t bitsPerComponent;
|
|
size_t bytesPerRow;
|
|
CGColorSpaceRef colorSpace;
|
|
CGContextRef bitmapContext;
|
|
CGImageRef image;
|
|
unsigned char* pixelData;
|
|
}
|
|
|
|
- (id)initWithFrame:(CGRect)frame
|
|
{
|
|
self = [super initWithFrame:frame];
|
|
|
|
// Initialization code
|
|
|
|
width = 1280;
|
|
height = 720;
|
|
bitsPerComponent = 8;
|
|
bytesPerRow = (bitsPerComponent / 8) * width * 4;
|
|
pixelData = malloc(width * height * 4);
|
|
colorSpace = CGColorSpaceCreateDeviceRGB();
|
|
|
|
return self;
|
|
}
|
|
|
|
|
|
|
|
// Only override drawRect: if you perform custom drawing.
|
|
// An empty implementation adversely affects performance during animation.
|
|
- (void)drawRect:(CGRect)rect
|
|
{
|
|
/*if (![VideoRenderer isRendering]) {
|
|
return;
|
|
}*/
|
|
|
|
bitmapContext = CGBitmapContextCreate(pixelData, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little);
|
|
image = CGBitmapContextCreateImage(bitmapContext);
|
|
|
|
struct CGContext* context = UIGraphicsGetCurrentContext();
|
|
|
|
CGContextSetBlendMode(context, kCGBlendModeCopy);
|
|
CGContextSetInterpolationQuality(context, kCGInterpolationNone);
|
|
CGContextSetShouldAntialias(context, false);
|
|
CGContextRotateCTM(context, -M_PI_2);
|
|
CGContextScaleCTM(context, -(float)self.frame.size.width/self.frame.size.height, (float)self.frame.size.height/self.frame.size.width);
|
|
CGContextDrawImage(context, rect, image);
|
|
|
|
CGImageRelease(image);
|
|
|
|
[super drawRect:rect];
|
|
}
|
|
|
|
|
|
@end
|