-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
104 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// RgbScaler.h | ||
// | ||
// | ||
// Created by Radzivon Bartoshyk on 25/09/2023. | ||
// | ||
|
||
#ifndef RgbScaler_h | ||
#define RgbScaler_h | ||
|
||
#import <vector> | ||
|
||
@interface RgbScaler : NSObject | ||
/** | ||
* Converts unsigned uint8_t RGB to RGBA in uint8_t. Depth is always considered as 8 bit | ||
* @author Radzivon Bartoshyk | ||
* | ||
* @param src Source buffer | ||
* @param dst Destination buffer | ||
* @param width width of of the image | ||
* @param height width of of the image | ||
* @param components components count, supported 3 or 4 | ||
* @return true if conversion were successfull | ||
*/ | ||
+(bool)scaleRGBU8:(uint8_t*)src dst:(uint8_t*)dst width:(int)width height:(int)height components:(int)components; | ||
@end | ||
#endif /* Header_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// RgbScaler.m | ||
// | ||
// | ||
// Created by Radzivon Bartoshyk on 25/09/2023. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "RgbScaler.h" | ||
#import "Accelerate/Accelerate.h" | ||
|
||
@implementation RgbScaler | ||
|
||
+(bool)scaleRGBU8:(uint8_t*)src dst:(uint8_t*)dst width:(int)width height:(int)height components:(int)components { | ||
if (components != 3 || components != 4) { | ||
return false; | ||
} | ||
uint16_t whiteColor = (uint16_t)(powf(2.0f, (float)8) - 1); | ||
vImage_Buffer srcBuffer = { | ||
.data = (void*)src, | ||
.width = static_cast<vImagePixelCount>(width), | ||
.height = static_cast<vImagePixelCount>(height), | ||
.rowBytes = width * components * sizeof(uint8_t) | ||
}; | ||
|
||
vImage_Buffer dstBuffer = { | ||
.data = dst, | ||
.width = static_cast<vImagePixelCount>(width), | ||
.height = static_cast<vImagePixelCount>(height), | ||
.rowBytes = width * components * sizeof(uint8_t) | ||
}; | ||
// if components == 3 { | ||
// vImageScale_ARGB8888(<#const vImage_Buffer *src#>, <#const vImage_Buffer *dest#>, <#void *tempBuffer#>, <#vImage_Flags flags#>) | ||
// } | ||
// vImage_Error vEerror = vImageConvert_RGB888toRGBA8888(&srcBuffer, NULL, whiteColor, &dstBuffer, false, kvImageNoFlags); | ||
// if (vEerror != kvImageNoError) { | ||
// return false; | ||
// } | ||
return true; | ||
|
||
return true; | ||
} | ||
|
||
@end |