Oolite
Loading...
Searching...
No Matches
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 38 of file OOPixMapChannelOperations.m.

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

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

Referenced by OOTextureLoader(OOPrivate)::applySettings, and OOCombinedEmissionMapGenerator::loadTexture.

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

◆ OOPixMapAddPixMap()

BOOL OOPixMapAddPixMap ( OOPixMap * ioDstPixMap,
OOPixMap otherPixMap )

Definition at line 278 of file OOPixMapChannelOperations.m.

279{
280 if (EXPECT_NOT(ioDstPixMap == NULL || !OOIsValidPixMap(*ioDstPixMap)))
281 return NO;
282 if (EXPECT_NOT(!OOIsValidPixMap(otherPixMap) || otherPixMap.format != kOOPixMapRGBA))
283 return NO;
284 if (EXPECT_NOT(!OOPixMapToRGBA(ioDstPixMap)))
285 return NO;
286 if (EXPECT_NOT(ioDstPixMap->width != otherPixMap.width || ioDstPixMap->height != otherPixMap.height))
287 return NO;
288
289 AddPixMap_4(*ioDstPixMap, otherPixMap);
290
291 return YES;
292}
static void AddPixMap_4(OOPixMap mainPx, OOPixMap otherPx)
BOOL OOPixMapToRGBA(OOPixMap *ioPixMap)
OOPixMapDimension height
Definition OOPixMap.h:45

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

Referenced by OOCombinedEmissionMapGenerator::loadTexture.

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

◆ OOPixMapModulatePixMap()

BOOL OOPixMapModulatePixMap ( OOPixMap * ioDstPixMap,
OOPixMap otherPixMap )

Definition at line 220 of file OOPixMapChannelOperations.m.

221{
222 if (EXPECT_NOT(ioDstPixMap == NULL || !OOIsValidPixMap(*ioDstPixMap)))
223 return NO;
224 if (EXPECT_NOT(!OOIsValidPixMap(otherPixMap) || otherPixMap.format != kOOPixMapRGBA))
225 return NO;
226 if (EXPECT_NOT(!OOPixMapToRGBA(ioDstPixMap)))
227 return NO;
228 if (EXPECT_NOT(ioDstPixMap->width != otherPixMap.width || ioDstPixMap->height != otherPixMap.height))
229 return NO;
230
231 ModulatePixMap_4(*ioDstPixMap, otherPixMap);
232
233 return YES;
234}
static void ModulatePixMap_4(OOPixMap mainPx, OOPixMap otherPx)

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

Referenced by OOCombinedEmissionMapGenerator::loadTexture.

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

◆ OOPixMapModulateUniform()

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

Definition at line 166 of file OOPixMapChannelOperations.m.

167{
168 if (EXPECT_NOT(ioPixMap == NULL || !OOIsValidPixMap(*ioPixMap)))
169 return NO;
170 if (EXPECT_NOT(!OOPixMapToRGBA(ioPixMap)))
171 return NO;
172
173 ModulateUniform_4(*ioPixMap, f0 * 256.0f, f1 * 256.0f, f2 * 256.0f, f3 * 256.0f);
174
175 return YES;
176}
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().

Referenced by OOCombinedEmissionMapGenerator::loadTexture.

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

◆ OOPixMapToRGBA()

BOOL OOPixMapToRGBA ( OOPixMap * ioPixMap)

Definition at line 78 of file OOPixMapChannelOperations.m.

79{
80 if (EXPECT_NOT(ioPixMap == NULL || !OOIsValidPixMap(*ioPixMap)))
81 return NO;
82 if (ioPixMap->format == kOOPixMapRGBA)
83 return YES;
84
85 OOPixMap temp = OOAllocatePixMap(ioPixMap->width, ioPixMap->height, 4, 0, 0);
86 if (EXPECT_NOT(OOIsNullPixMap(temp)))
87 return NO;
88
89 BOOL OK = NO;
90 switch (ioPixMap->format) {
92 ToRGBA_1(*ioPixMap, temp);
93 OK = YES;
94 break;
95
97 ToRGBA_2(*ioPixMap, temp);
98 OK = YES;
99 break;
100
101 case kOOPixMapRGBA:
103 OK = NO;
104 break;
105 // No default, because -Wswitch-enum is our friend.
106 }
107
108 if (OK) {
109 free(ioPixMap->pixels);
110 *ioPixMap = temp;
111 } else {
112 free(temp.pixels);
113 }
114
115 return OK;
116}
static void ToRGBA_2(OOPixMap srcPx, OOPixMap dstPx)
static void ToRGBA_1(OOPixMap srcPx, OOPixMap dstPx)
@ kOOPixMapInvalidFormat
Definition OOPixMap.h:37
@ kOOPixMapGrayscaleAlpha
Definition OOPixMap.h:39
OOPixMap OOAllocatePixMap(OOPixMapDimension width, OOPixMapDimension height, OOPixMapFormat format, size_t rowBytes, size_t bufferSize)
Definition OOPixMap.m:66
OOINLINE BOOL OOIsNullPixMap(OOPixMap pixMap)
Definition OOPixMap.h:53
void * pixels
Definition OOPixMap.h:44

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 OOTextureLoader(OOPrivate)::applySettings, OOCombinedEmissionMapGenerator::loadTexture, OOPixMapAddPixMap(), OOPixMapModulatePixMap(), and OOPixMapModulateUniform().

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