Fixed implementation of init methods in MPPMask
This commit is contained in:
parent
4ab1a5de1b
commit
d12dd88f51
|
@ -54,9 +54,9 @@
|
||||||
if (self) {
|
if (self) {
|
||||||
if (shouldCopy) {
|
if (shouldCopy) {
|
||||||
size_t length = _width * _height;
|
size_t length = _width * _height;
|
||||||
_float32DataPtr = std::unique_ptr<float[]>(new float[length]);
|
_uint8DataPtr = std::unique_ptr<UInt8[]>(new UInt8[length]);
|
||||||
_float32Data = _float32DataPtr.get();
|
_uint8Data = _uint8DataPtr.get();
|
||||||
memcpy((float *)_float32Data, float32DataToCopy, length * sizeof(float));
|
memcpy((UInt8 *)_uint8Data, uint8Data, length * sizeof(UInt8));
|
||||||
} else {
|
} else {
|
||||||
_uint8Data = uint8Data;
|
_uint8Data = uint8Data;
|
||||||
}
|
}
|
||||||
|
@ -67,14 +67,14 @@
|
||||||
- (nullable instancetype)initWithFloat32Data:(const float *)float32Data
|
- (nullable instancetype)initWithFloat32Data:(const float *)float32Data
|
||||||
width:(NSInteger)width
|
width:(NSInteger)width
|
||||||
height:(NSInteger)height
|
height:(NSInteger)height
|
||||||
shouldCopy:(BOO)shouldCopy {
|
shouldCopy:(BOOL)shouldCopy {
|
||||||
self = [self initWithWidth:width height:height dataType:MPPMaskDataTypeFloat32 error:nil];
|
self = [self initWithWidth:width height:height dataType:MPPMaskDataTypeFloat32 error:nil];
|
||||||
if (self) {
|
if (self) {
|
||||||
if (shouldCopy) {
|
if (shouldCopy) {
|
||||||
size_t length = _width * _height;
|
size_t length = _width * _height;
|
||||||
_uint8DataPtr = std::unique_ptr<UInt8[]>(new UInt8[length]);
|
_float32DataPtr = std::unique_ptr<float[]>(new float[length]);
|
||||||
_uint8Data = _uint8DataPtr.get();
|
_float32Data = _float32DataPtr.get();
|
||||||
memcpy((UInt8 *)_uint8Data, uint8DataToCopy, length * sizeof(UInt8));
|
memcpy((float *)_float32Data, float32Data, length * sizeof(float));
|
||||||
} else {
|
} else {
|
||||||
_float32Data = float32Data;
|
_float32Data = float32Data;
|
||||||
}
|
}
|
||||||
|
@ -131,12 +131,12 @@
|
||||||
- (id)copyWithZone:(NSZone *)zone {
|
- (id)copyWithZone:(NSZone *)zone {
|
||||||
switch (_dataType) {
|
switch (_dataType) {
|
||||||
case MPPMaskDataTypeUInt8:
|
case MPPMaskDataTypeUInt8:
|
||||||
return [[MPPMask alloc] initWithUInt8DataToCopy:self.uint8Data
|
return [[MPPMask alloc] initWithUInt8Data:self.uint8Data
|
||||||
width:self.width
|
width:self.width
|
||||||
height:self.height
|
height:self.height
|
||||||
shouldCopy:YES];
|
shouldCopy:YES];
|
||||||
case MPPMaskDataTypeFloat32:
|
case MPPMaskDataTypeFloat32:
|
||||||
return [[MPPMask alloc] initWithFloat32DataToCopy:self.float32Data
|
return [[MPPMask alloc] initWithFloat32Data:self.float32Data
|
||||||
width:self.width
|
width:self.width
|
||||||
height:self.height
|
height:self.height
|
||||||
shouldCopy:YES];
|
shouldCopy:YES];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user