Oolite 1.91.0.7604-240417-a536cbe
Loading...
Searching...
No Matches
Functions
OOPixMapChannelOperations.h File Reference
import "OOPixMap.h"
+ Include dependency graph for OOPixMapChannelOperations.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

BOOL OOExtractPixMapChannel (OOPixMap *ioPixMap, uint8_t channelIndex, BOOL compactWhenDone)
 
BOOL OOPixMapToRGBA (OOPixMap *ioPixMap)
 
BOOL OOPixMapModulateUniform (OOPixMap *ioPixMap, float f0, float f1, float f2, float f3)
 
BOOL OOPixMapModulatePixMap (OOPixMap *ioDstPixMap, OOPixMap otherPixMap)
 
BOOL OOPixMapAddPixMap (OOPixMap *ioDstPixMap, OOPixMap otherPixMap)
 

Function Documentation

◆ OOExtractPixMapChannel()

BOOL OOExtractPixMapChannel ( OOPixMap * ioPixMap,
uint8_t channelIndex,
BOOL compactWhenDone )

Definition at line 40 of file OOPixMapChannelOperations.m.

41{
42 if (EXPECT_NOT(ioPixMap == NULL || !OOIsValidPixMap(*ioPixMap) || ioPixMap->format != kOOPixMapRGBA || channelIndex > 3))
43 {
44 return NO;
45 }
46
47 ExtractChannel_4(ioPixMap, channelIndex);
48
49 ioPixMap->format = kOOPixMapGrayscale;
50 ioPixMap->rowBytes = ioPixMap->width;
51
52 if (compactWhenDone)
53 {
54 OOCompactPixMap(ioPixMap);
55 }
56
57 return YES;
58}
#define EXPECT_NOT(x)
static void ExtractChannel_4(OOPixMap *ioPixMap, uint8_t channelIndex)
@ kOOPixMapGrayscale
Definition OOPixMap.h:41
@ kOOPixMapRGBA
Definition OOPixMap.h:43
BOOL OOIsValidPixMap(OOPixMap pixMap)
Definition OOPixMap.m:42
OOINLINE void OOCompactPixMap(OOPixMap *ioPixMap)
Definition OOPixMap.h:103
size_t rowBytes
Definition OOPixMap.h:52
OOPixMapDimension width
Definition OOPixMap.h:50
OOPixMapFormat format
Definition OOPixMap.h:51

References EXPECT_NOT, ExtractChannel_4(), OOPixMap::format, kOOPixMapGrayscale, kOOPixMapRGBA, OOCompactPixMap(), OOIsValidPixMap(), OOPixMap::rowBytes, and OOPixMap::width.

+ Here is the call graph for this function:

◆ OOPixMapAddPixMap()

BOOL OOPixMapAddPixMap ( OOPixMap * ioDstPixMap,
OOPixMap otherPixMap )

Definition at line 301 of file OOPixMapChannelOperations.m.

302{
303 if (EXPECT_NOT(ioDstPixMap == NULL || !OOIsValidPixMap(*ioDstPixMap))) return NO;
304 if (EXPECT_NOT(!OOIsValidPixMap(otherPixMap) || otherPixMap.format != kOOPixMapRGBA)) return NO;
305 if (EXPECT_NOT(!OOPixMapToRGBA(ioDstPixMap))) return NO;
306 if (EXPECT_NOT(ioDstPixMap->width != otherPixMap.width || ioDstPixMap->height != otherPixMap.height)) return NO;
307
308 AddPixMap_4(*ioDstPixMap, otherPixMap);
309
310 return YES;
311}
static void AddPixMap_4(OOPixMap mainPx, OOPixMap otherPx)
BOOL OOPixMapToRGBA(OOPixMap *ioPixMap)
OOPixMapDimension height
Definition OOPixMap.h:50

References AddPixMap_4(), EXPECT_NOT, OOPixMap::format, OOPixMap::height, kOOPixMapRGBA, OOIsValidPixMap(), OOPixMapToRGBA(), and OOPixMap::width.

+ Here is the call graph for this function:

◆ OOPixMapModulatePixMap()

BOOL OOPixMapModulatePixMap ( OOPixMap * ioDstPixMap,
OOPixMap otherPixMap )

Definition at line 242 of file OOPixMapChannelOperations.m.

243{
244 if (EXPECT_NOT(ioDstPixMap == NULL || !OOIsValidPixMap(*ioDstPixMap))) return NO;
245 if (EXPECT_NOT(!OOIsValidPixMap(otherPixMap) || otherPixMap.format != kOOPixMapRGBA)) return NO;
246 if (EXPECT_NOT(!OOPixMapToRGBA(ioDstPixMap))) return NO;
247 if (EXPECT_NOT(ioDstPixMap->width != otherPixMap.width || ioDstPixMap->height != otherPixMap.height)) return NO;
248
249 ModulatePixMap_4(*ioDstPixMap, otherPixMap);
250
251 return YES;
252}
static void ModulatePixMap_4(OOPixMap mainPx, OOPixMap otherPx)

References EXPECT_NOT, OOPixMap::format, OOPixMap::height, kOOPixMapRGBA, ModulatePixMap_4(), OOIsValidPixMap(), OOPixMapToRGBA(), and OOPixMap::width.

+ Here is the call graph for this function:

◆ OOPixMapModulateUniform()

BOOL OOPixMapModulateUniform ( OOPixMap * ioPixMap,
float f0,
float f1,
float f2,
float f3 )

Definition at line 185 of file OOPixMapChannelOperations.m.

186{
187 if (EXPECT_NOT(ioPixMap == NULL || !OOIsValidPixMap(*ioPixMap))) return NO;
188 if (EXPECT_NOT(!OOPixMapToRGBA(ioPixMap))) return NO;
189
190 ModulateUniform_4(*ioPixMap, f0 * 256.0f, f1 * 256.0f, f2 * 256.0f, f3 * 256.0f);
191
192 return YES;
193}
static void ModulateUniform_4(OOPixMap pixMap, uint16_t f0, uint16_t f1, uint16_t f2, uint16_t f3)

References EXPECT_NOT, ModulateUniform_4(), OOIsValidPixMap(), and OOPixMapToRGBA().

+ Here is the call graph for this function:

◆ OOPixMapToRGBA()

BOOL OOPixMapToRGBA ( OOPixMap * ioPixMap)

Definition at line 87 of file OOPixMapChannelOperations.m.

88{
89 if (EXPECT_NOT(ioPixMap == NULL || !OOIsValidPixMap(*ioPixMap))) return NO;
90 if (ioPixMap->format == kOOPixMapRGBA) return YES;
91
92 OOPixMap temp = OOAllocatePixMap(ioPixMap->width, ioPixMap->height, 4, 0, 0);
93 if (EXPECT_NOT(OOIsNullPixMap(temp))) return NO;
94
95 BOOL OK = NO;
96 switch (ioPixMap->format)
97 {
99 ToRGBA_1(*ioPixMap, temp);
100 OK = YES;
101 break;
102
104 ToRGBA_2(*ioPixMap, temp);
105 OK = YES;
106 break;
107
108 case kOOPixMapRGBA:
110 OK = NO;
111 break;
112 // No default, because -Wswitch-enum is our friend.
113 }
114
115 if (OK)
116 {
117 free(ioPixMap->pixels);
118 *ioPixMap = temp;
119 }
120 else
121 {
122 free(temp.pixels);
123 }
124
125 return OK;
126}
static void ToRGBA_2(OOPixMap srcPx, OOPixMap dstPx)
static void ToRGBA_1(OOPixMap srcPx, OOPixMap dstPx)
@ kOOPixMapInvalidFormat
Definition OOPixMap.h:40
@ kOOPixMapGrayscaleAlpha
Definition OOPixMap.h:42
OOPixMap OOAllocatePixMap(OOPixMapDimension width, OOPixMapDimension height, OOPixMapFormat format, size_t rowBytes, size_t bufferSize)
Definition OOPixMap.m:73
OOINLINE BOOL OOIsNullPixMap(OOPixMap pixMap)
Definition OOPixMap.h:60
void * pixels
Definition OOPixMap.h:49

References EXPECT_NOT, OOPixMap::format, OOPixMap::height, kOOPixMapGrayscale, kOOPixMapGrayscaleAlpha, kOOPixMapInvalidFormat, kOOPixMapRGBA, OOAllocatePixMap(), OOIsNullPixMap(), OOIsValidPixMap(), OOPixMap::pixels, ToRGBA_1(), ToRGBA_2(), and OOPixMap::width.

Referenced by OOPixMapAddPixMap(), OOPixMapModulatePixMap(), and OOPixMapModulateUniform().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: