1 ////////////////////////////////////////////////////////////////////////////////
3 // File: LoadPalette.cpp
7 // Author: Daniel Switkin
9 // Copyright 2003 (c) by Daniel Switkin. This file is made publically available
10 // under the BSD license, with the stipulations that this complete header must
11 // remain at the top of the file indefinitely, and credit must be given to the
12 // original author in any about box using this software.
14 ////////////////////////////////////////////////////////////////////////////////
16 // Additional authors: John Scipione, <jscipione@gmail.com>
19 #include "LoadPalette.h"
21 #include <GraphicsDefs.h>
22 #include <ByteOrder.h>
25 LoadPalette::LoadPalette() {
27 usetransparent
= false;
29 size
= size_in_bits
= 0;
34 LoadPalette::ColorForIndex(int index
)
36 // never index into pal directly - this function is safe
37 if (index
>= 0 && index
<= size
) {
38 if (usetransparent
&& index
== transparentindex
)
39 return B_TRANSPARENT_MAGIC_RGBA32
;
43 return B_BENDIAN_TO_HOST_INT32(0x000000ff);
48 LoadPalette::SetColor(int index
, uint8 red
, uint8 green
, uint8 blue
)
50 if (index
< 0 || index
> 255)
53 data
[index
] = (blue
<< 24) + (green
<< 16) + (red
<< 8) + 0xff;
54 data
[index
] = B_BENDIAN_TO_HOST_INT32(data
[index
]);