2 * Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
6 * Andrew McCall <mccall@@digitalparadise.co.uk>
7 * Mike Berg <mike@berg-net.us>
8 * Julun <host.haiku@gmx.de>
20 ReplaceTransparentColor(BBitmap
* bitmap
, rgb_color with
)
22 // other color spaces not implemented yet
23 ASSERT(bitmap
->ColorSpace() == B_COLOR_8_BIT
);
25 BScreen
screen(B_MAIN_SCREEN_ID
);
26 uint32 withIndex
= screen
.IndexForColor(with
);
28 uchar
* bits
= (uchar
*)bitmap
->Bits();
29 int32 bitsLength
= bitmap
->BitsLength();
30 for (int32 index
= 0; index
< bitsLength
; index
++)
31 if (bits
[index
] == B_TRANSPARENT_8_BIT
)
32 bits
[index
] = withIndex
;