1 /* 2 * Copyright 2005, Jérôme Duval. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Inspired by SoundCapture from Be newsletter (Media Kit Basics: Consumers and Producers) 6 */ 7 8 #ifndef __DRAWING_TIBITS__ 9 #define __DRAWING_TIBITS__ 10 11 #include <GraphicsDefs.h> 12 13 rgb_color ShiftColor(rgb_color , float ); 14 15 bool operator==(const rgb_color &, const rgb_color &); 16 bool operator!=(const rgb_color &, const rgb_color &); 17 18 inline uchar 19 ShiftComponent(uchar component, float percent) 20 { 21 // change the color by <percent>, make sure we aren't rounding 22 // off significant bits 23 if (percent >= 1) 24 return (uchar)(component * (2 - percent)); 25 else 26 return (uchar)(255 - percent * (255 - component)); 27 } 28 29 inline rgb_color 30 Color(int32 r, int32 g, int32 b, int32 alpha = 255) 31 { 32 rgb_color result; 33 result.red = r; 34 result.green = g; 35 result.blue = b; 36 result.alpha = alpha; 37 38 return result; 39 } 40 41 const rgb_color kWhite = { 255, 255, 255, 255}; 42 const rgb_color kBlack = { 0, 0, 0, 255}; 43 44 const float kDarkness = 1.06; 45 const float kDimLevel = 0.6; 46 47 void ReplaceColor(BBitmap *bitmap, rgb_color from, rgb_color to); 48 void ReplaceTransparentColor(BBitmap *bitmap, rgb_color with); 49 50 #endif