-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPaletteManager.cs
More file actions
59 lines (46 loc) · 1.35 KB
/
PaletteManager.cs
File metadata and controls
59 lines (46 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
namespace RetroDevStudio
{
internal class PaletteManager
{
public static Palette PaletteFromMachine( MachineType Machine )
{
switch ( Machine )
{
case MachineType.C64:
case MachineType.C128:
default:
return ConstantData.PaletteC64();
case MachineType.MEGA65:
return ConstantData.PaletteMega65();
case MachineType.VC20:
return ConstantData.PaletteVC20();
}
}
public static void ApplyPalette( GR.Image.IImage Image )
{
ApplyPalette( Image, ConstantData.Palette );
}
public static void ApplyPalette( GR.Image.IImage Image, Palette Palette )
{
for ( int i = 0; i < Palette.NumColors; ++i )
{
Image.SetPaletteColor( i,
(byte)( ( Palette.ColorValues[i] & 0x00ff0000 ) >> 16 ),
(byte)( ( Palette.ColorValues[i] & 0x0000ff00 ) >> 8 ),
(byte)( Palette.ColorValues[i] & 0xff ) );
}
}
internal static Palette PaletteFromNumColors( int NumColors )
{
switch ( NumColors )
{
case 16:
default:
return ConstantData.PaletteC64();
case 256:
return ConstantData.PaletteMega65();
}
}
}
}