ImageData.m 479 Bytes
Newer Older
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

#import "ImageData.h"

// This structure aims to be used in an immutable way
@implementation ImageData
{
  GLubyte *_data;
  int _width;
  int _height;
}

- (instancetype)initWithData: (GLubyte *)data withWidth:(int)width withHeight:(int)height
{
  self = [super init];
  if (self) {
    _data = data;
    _width = width;
    _height = height;
  }
  return self;
}

- (void)dealloc
{
  if (_data) {
    free(_data);
    _data = nil;
    _width = 0;
    _height = 0;
  }
}

@end