157e2f323SJérôme Duval /*
257e2f323SJérôme Duval * Copyright 2005, Jérôme Duval. All rights reserved.
357e2f323SJérôme Duval * Distributed under the terms of the MIT License.
457e2f323SJérôme Duval *
557e2f323SJérôme Duval * Inspired by SoundCapture from Be newsletter (Media Kit Basics: Consumers and Producers)
657e2f323SJérôme Duval */
757e2f323SJérôme Duval
857e2f323SJérôme Duval #ifndef __DRAWING_TIBITS__
957e2f323SJérôme Duval #define __DRAWING_TIBITS__
1057e2f323SJérôme Duval
1157e2f323SJérôme Duval #include <GraphicsDefs.h>
1257e2f323SJérôme Duval
1357e2f323SJérôme Duval rgb_color ShiftColor(rgb_color , float );
1457e2f323SJérôme Duval
1557e2f323SJérôme Duval bool operator==(const rgb_color &, const rgb_color &);
1657e2f323SJérôme Duval bool operator!=(const rgb_color &, const rgb_color &);
1757e2f323SJérôme Duval
1857e2f323SJérôme Duval inline uchar
ShiftComponent(uchar component,float percent)1957e2f323SJérôme Duval ShiftComponent(uchar component, float percent)
2057e2f323SJérôme Duval {
2157e2f323SJérôme Duval // change the color by <percent>, make sure we aren't rounding
2257e2f323SJérôme Duval // off significant bits
2357e2f323SJérôme Duval if (percent >= 1)
2457e2f323SJérôme Duval return (uchar)(component * (2 - percent));
2557e2f323SJérôme Duval else
2657e2f323SJérôme Duval return (uchar)(255 - percent * (255 - component));
2757e2f323SJérôme Duval }
2857e2f323SJérôme Duval
2957e2f323SJérôme Duval inline rgb_color
3057e2f323SJérôme Duval Color(int32 r, int32 g, int32 b, int32 alpha = 255)
3157e2f323SJérôme Duval {
3257e2f323SJérôme Duval rgb_color result;
3357e2f323SJérôme Duval result.red = r;
3457e2f323SJérôme Duval result.green = g;
3557e2f323SJérôme Duval result.blue = b;
3657e2f323SJérôme Duval result.alpha = alpha;
3757e2f323SJérôme Duval
3857e2f323SJérôme Duval return result;
3957e2f323SJérôme Duval }
4057e2f323SJérôme Duval
4157e2f323SJérôme Duval const rgb_color kWhite = { 255, 255, 255, 255};
4257e2f323SJérôme Duval const rgb_color kBlack = { 0, 0, 0, 255};
4357e2f323SJérôme Duval
4457e2f323SJérôme Duval const float kDarkness = 1.06;
4557e2f323SJérôme Duval const float kDimLevel = 0.6;
4657e2f323SJérôme Duval
4757e2f323SJérôme Duval void ReplaceColor(BBitmap *bitmap, rgb_color from, rgb_color to);
4857e2f323SJérôme Duval void ReplaceTransparentColor(BBitmap *bitmap, rgb_color with);
4957e2f323SJérôme Duval
5057e2f323SJérôme Duval #endif
51*34bd8bf5SJérôme Duval
52