1/*
2 * Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Andrew McCall <mccall@@digitalparadise.co.uk>
7 *		Mike Berg <mike@berg-net.us>
8 *		Julun <host.haiku@gmx.de>
9 *
10 */
11
12#include "Bitmaps.h"
13
14
15#include <Debug.h>
16#include <Screen.h>
17
18
19void
20ReplaceTransparentColor(BBitmap* bitmap, rgb_color with)
21{
22	// other color spaces not implemented yet
23	ASSERT(bitmap->ColorSpace() == B_COLOR_8_BIT);
24
25	BScreen screen(B_MAIN_SCREEN_ID);
26	uint32 withIndex = screen.IndexForColor(with);
27
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;
33}
34