Saving colours

Last changed 1995.02.17


Version
Not specified
Terms
TPalette; fpstream; fpstream::readBytes; fpstream::writeBytes; opstream

   // Here's how to save the colors.
   void TVApp::saveColors(void)
   {
       fpstream *f = new fpstream("ANYFILE", ios::trunc |
           ios::binary);

       opstream &strm = *f;

       // Store the palettes
       short curr_palette = appPalette;
       for(short i = 0; i < 3; i++)
       {
           appPalette = i;
           TPalette *palette = &getPalette();
           strm.writeBytes(palette->data, palette->data[0] + 1);
       }
       appPalette = curr_palette;
   }

   // Here's how to load the colors.
   void TVApp::loadColors(void)
   {
       fpstream *f = new fpstream("ANYFILE", ios::in |
           ios::nocreate | ios::binary);

       ipstream &strm = *f;

       // Read palettes from the configuration file.
       short curr_palette = appPalette;
       for(short i = 0; i < apTotalPalettes; i++)
       {
           appPalette = i;
           TPalette *palette = &getPalette();
          strm.readBytes(palette->data, palette->data[0] + 1);
       }
       appPalette = curr_palette;
   }