Line data Source code
1 0 : /* 2 : 3 : OOPixMapChannelOperations.h 4 : 5 : Utility to convert one channel of an RGBA texture into a greyscale texture. 6 : 7 : 8 : Copyright (C) 2010-2013 Jens Ayton 9 : 10 : Permission is hereby granted, free of charge, to any person obtaining a copy 11 : of this software and associated documentation files (the "Software"), to deal 12 : in the Software without restriction, including without limitation the rights 13 : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 : copies of the Software, and to permit persons to whom the Software is 15 : furnished to do so, subject to the following conditions: 16 : 17 : The above copyright notice and this permission notice shall be included in all 18 : copies or substantial portions of the Software. 19 : 20 : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 : SOFTWARE. 27 : 28 : */ 29 : 30 : #import "OOPixMap.h" 31 : 32 : 33 : /* OOExtractPixMapChannel() 34 : Given a 4-channel pixmap, extract one channel, producing a single-channel 35 : pixmap. This is done in place, destroying the original data. 36 : ChannelIndex specifies which component to extract. This is a per-pixel 37 : byte index: 0 means bytes bytes 0, 4, 8 etc. will be used, 2 means bytes 38 : 2, 6, 10 etc. will be used. 39 : Returns false (without modifying the pixmap) if passed NULL, an invalid 40 : pixmap, a pixmap whose channel count is not 4, or a channel index greater 41 : than 3. 42 : */ 43 0 : BOOL OOExtractPixMapChannel(OOPixMap *ioPixMap, uint8_t channelIndex, BOOL compactWhenDone); 44 : 45 : 46 : /* OOPixMapToRGBA() 47 : Convert a pixmap to RGBA format. 48 : NOTE: if successful, this will free() the original buffer and replace it. 49 : */ 50 0 : BOOL OOPixMapToRGBA(OOPixMap *ioPixMap); 51 : 52 : 53 : /* OOPixMapModulateUniform() 54 : Multiply all pixels by specified per-component factors. Pixmap must be in 55 : RGBA format. The effect of using factors outside the range [0..1] is 56 : undefined. 57 : OOPixMapToRGBA() is called on ioPixMap. 58 : */ 59 0 : BOOL OOPixMapModulateUniform(OOPixMap *ioPixMap, float f0, float f1, float f2, float f3); 60 : 61 : 62 : /* OOPixMapModulatePixMap() 63 : Multiply each pixel of ioDstPixMap by the corresponding pixel of otherPixMap, 64 : writing the result to ioDstPixMap. 65 : OOPixMapToRGBA() is called on ioDstPixMap; otherPixMap must be RGBA. 66 : */ 67 0 : BOOL OOPixMapModulatePixMap(OOPixMap *ioDstPixMap, OOPixMap otherPixMap); 68 : 69 : 70 : /* OOPixMapAddPixMap() 71 : Add each pixel of otherPixMap to the corresponding pixel of ioDstPixMap, 72 : writing the result to ioDstPixMap. 73 : OOPixMapToRGBA() is called on ioDstPixMap; otherPixMap must be RGBA. 74 : */ 75 0 : BOOL OOPixMapAddPixMap(OOPixMap *ioDstPixMap, OOPixMap otherPixMap);