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