vfs: check userland buffers before reading them.
[haiku.git] / src / preferences / time / Bitmaps.cpp
blobb4d348d25e13bebeee2fde6f5b15caf9e30999c3
1 /*
2 * Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Andrew McCall <mccall@@digitalparadise.co.uk>
7 * Mike Berg <mike@berg-net.us>
8 * Julun <host.haiku@gmx.de>
12 #include "Bitmaps.h"
15 #include <Debug.h>
16 #include <Screen.h>
19 void
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;