compiler/libec: (#205) Fixed integer promotions to follow the C standard (6.3.1.1)
[sdk] / ecere / src / gfx / bitmaps / RGBFormat.ec
1 namespace gfx::bitmaps;
2
3 import "Display"
4
5 static const char * extensions[] = { "rgb", null };
6
7 class RGBFormat : BitmapFormat
8 {
9    class_property(extensions) = extensions;
10
11    bool Load(Bitmap bitmap, File f)
12    {
13       return false;
14    }
15
16    bool Save(Bitmap bitmap, const char * filename, void * options)
17    {
18       return false;
19    }
20
21    ColorAlpha * LoadPalette(const char * fileName, const char * type)
22    {
23       ColorAlpha * result = null;
24       File f = FileOpen(fileName, read);
25       if(f)
26       {
27          byte palette[768];
28          if(f.Read(palette, 768, 1))
29          {
30             if((result = new ColorAlpha[256]))
31             {
32                int c;
33                for(c = 0; c<256; c++)
34                   result[c] = ColorAlpha { 255, { (byte)(palette[c*3]<<2), (byte)(palette[c*3+1]<<2), (byte)(palette[c*3+2]<<2) } };
35             }
36          }
37          delete f;
38       }
39       return result;
40    }
41 }