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 13rgb_color ShiftColor(rgb_color , float ); 14 15bool operator==(const rgb_color &, const rgb_color &); 16bool operator!=(const rgb_color &, const rgb_color &); 17 18inline uchar 19ShiftComponent(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 29inline rgb_color 30Color(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 41const rgb_color kWhite = { 255, 255, 255, 255}; 42const rgb_color kBlack = { 0, 0, 0, 255}; 43 44const float kDarkness = 1.06; 45const float kDimLevel = 0.6; 46 47void ReplaceColor(BBitmap *bitmap, rgb_color from, rgb_color to); 48void ReplaceTransparentColor(BBitmap *bitmap, rgb_color with); 49 50#endif 51 52