public void read(Reader reader, int rows = 2) { int palRows = rows > 0 ? rows : (((int)reader.BaseStream.Length / 8) / 6); colors = new Palette.Color[palRows][]; for (int r = 0; r < palRows; r++) { colors[r] = new Palette.Color[COLORS_PER_ROW]; for (int c = 0; c < COLORS_PER_ROW; ++c) { colors[r][c] = new Palette.Color(reader); } } }
public Palette(int rows = 2) { int palRows = rows; colors = new Palette.Color[palRows][]; for (int r = 0; r < palRows; r++) { colors[r] = new Palette.Color[COLORS_PER_ROW]; for (int c = 0; c < COLORS_PER_ROW; ++c) { colors[r][c] = new Palette.Color(); } } }
protected override OpenGLContext CreateContext() { ControlGLContext ctxt = new ControlGLContext(this); int i, n = ctxt.NumPixelFormats; // try hard to have a palette... for (i = 0; i < n; i++) { DisplayType dt = ctxt.GetPixelFormat(i); if (!dt.isRgba && dt.cColorBits <= 16) { if ((int)(dt.flags & DisplayFlags.DRAW_TO_WINDOW) == 0) { continue; } ctxt.Create(i, null); break; } } if (i == n) { ctxt.Create(new DisplayType(0, 0), null); } Console.WriteLine(ctxt.PixelFormat); Palette pal = ctxt.Palette; if (pal != null) { pal[23] = new Palette.Color(0, 128, 0); pal.Sync(); isPaletized = true; } else { isPaletized = false; } Console.WriteLine(isPaletized ? "use palette" : "no palette"); ctxt.Grab(); InitGLContext(); return(ctxt); }