コード例 #1
0
ファイル: palettestorage.c プロジェクト: curiousbadger/denemo
gint
writePalettes (void)
{
  gint ret = -1;
  xmlDocPtr doc;
  xmlNodePtr parent, child;
  gchar *localpal = NULL;

  localpal = g_build_filename (get_user_data_dir (TRUE), "actions", "palettes.xml", NULL);

  doc = xmlNewDoc ((xmlChar *) "1.0");
  doc->xmlRootNode = parent = xmlNewDocNode (doc, NULL, (xmlChar *) "Denemo", NULL);
    GList *g;
    for( g = Denemo.palettes; g; g = g->next)
        {
        child = xmlNewChild (parent, NULL, (xmlChar *) "palette", NULL);
        save_palette (child, g->data);
        }
    if (xmlSaveFormatFile (localpal, doc, 1) < 0)
    {
      g_warning ("Could not save file %s", localpal);
      ret = -1;
    } else
    ret = 0;
    xmlFreeDoc (doc);
    return ret;
}
コード例 #2
0
ファイル: fade_saver.c プロジェクト: MarginC/kame
static int
fade_saver(video_adapter_t *adp, int blank)
{
	static int count = 0;
	u_char pal[256*3];
	int i;

	if (blank) {
		blanked = TRUE;
		if (ISPALAVAIL(adp->va_flags)) {
			if (count <= 0)
				save_palette(adp, palette);
			if (count < 256) {
				pal[0] = pal[1] = pal[2] = 0;
				for (i = 3; i < 256*3; i++) {
					if (palette[i] - count > 60)
						pal[i] = palette[i] - count;
					else
						pal[i] = 60;
				}
				load_palette(adp, pal);
				count++;
			}
		} else {
	    		(*vidsw[adp->va_index]->blank_display)(adp,
							       V_DISPLAY_BLANK);
		}
	} else {
		if (ISPALAVAIL(adp->va_flags)) {
			load_palette(adp, palette);
			count = 0;
		} else {
	    		(*vidsw[adp->va_index]->blank_display)(adp,
							       V_DISPLAY_ON);
		}
		blanked = FALSE;
	}
	return 0;
}
コード例 #3
0
ファイル: voxel.cpp プロジェクト: Dakror/voxie
void VoxelFile::save_fp(QFile & fp)
{
    QDataStream stream(&fp);
    stream.setByteOrder(QDataStream::LittleEndian);
    stream << x_size;
    stream << y_size;
    stream << z_size;
    stream << x_offset;
    stream << y_offset;
    stream << z_offset;
    stream.writeRawData((char*)data, x_size * y_size * z_size);
    stream.writeRawData((char*)global_palette, 256 * 3);
    stream << quint8(points.size());
    ReferencePoints::const_iterator it;
    for (it = points.begin(); it != points.end(); it++) {
        const ReferencePoint & point = *it;
        write_cstring(stream, point.name);
        stream << point.x;
        stream << point.y;
        stream << point.z;
    }
    save_palette();
}
コード例 #4
0
ファイル: palette.c プロジェクト: clobber/OpenEmu
/******************************************************************************
**  Function   :  convert_palette
**
**  Objective  :  This function converts the file format from atari800 to db
**
**  Parameters :  old_file  - name of file containing atari800 binary array
**                new_name  - name of palette to store
**
**  return     :  Error code
**
******************************************************************************/
int convert_palette ( char *old_file, char *new_name ) {

    int pal[256];
    int i,j,c;
    FILE *fp;

    /*
     * Open the atari800 palette and get values
     */
    if ((fp = fopen(old_file,"rb")) == NULL) {
        sprintf ( msg, "Cound not open Atari800 Pallete file: %s", old_file );
        logger_log_message ( LOG_ERROR, msg, "" );
        return -1;
    }
    for (i = 0; i < 256; ++i ) {
        pal[i] = 0;
        for (j = 16; j >= 0; j -= 8) {
            c = fgetc(fp);
            if (c == EOF) {
                fclose(fp);
                return -1;
            }
            pal[i] |= c << j;
        }
    }
    fclose(fp);

    /*
     * Now save to the new file as kat5200 palette
     */
    if ( save_palette ( new_name, pal ) )
        return -1;

    return 0;

} /* end convert_palette */
コード例 #5
0
ファイル: palettes.cpp プロジェクト: Censacrof/aseprite
void load_default_palette(const std::string& userDefined)
{
    base::UniquePtr<Palette> pal;

    // Load specific palette file defined by the user in the command line.
    std::string palFile = userDefined;
    if (!palFile.empty())
        pal.reset(load_palette(palFile.c_str()));
    // Load default palette file
    else {
        std::string defaultPalName = get_preset_palette_filename(
                                         get_default_palette_preset_name(), ".ase");

        // If there is no palette in command line, we use the default one.
        palFile = defaultPalName;
        if (base::is_file(palFile)) {
            pal.reset(load_palette(palFile.c_str()));
        }
        else {
            // Migrate old default.gpl to default.ase format
            palFile = get_preset_palette_filename(
                          get_default_palette_preset_name(), ".gpl");

            if (base::is_file(palFile)) {
                pal.reset(load_palette(palFile.c_str()));

                // Remove duplicate black entries at the end (as old palettes
                // contains 256 colors)
                if (pal && pal->size() == 256) {
                    doc::color_t black = rgba(0, 0, 0, 255);

                    // Get the last non-black entry
                    int i = 0;
                    for (i=pal->size()-1; i>0; --i) {
                        if (pal->getEntry(i) != black)
                            break;
                    }

                    if (i < pal->size()-1) {
                        // Check if there is a black entry in the first entries.
                        bool hasBlack = false;
                        for (int j=0; j<i; ++j) {
                            if (pal->getEntry(j) == black) {
                                hasBlack = true;
                                break;
                            }
                        }
                        if (!hasBlack)
                            ++i;                // Leave one black entry

                        // Resize the palette
                        if (i < pal->size()-1)
                            pal->resize(i+1);
                    }
                }

                // We could remove the old .gpl file (palFile), but as the
                // user could be using multiple versions of Aseprite, it's a
                // good idea to keep both formats (.gpl for Aseprite <=
                // v1.1-beta5, and .ase for future versions).
            }
            // If the default palette file doesn't exist, we copy db32.gpl
            // as the default one (default.ase).
            else {
                ResourceFinder rf;
                rf.includeDataDir("palettes/db32.gpl");
                if (rf.findFirst()) {
                    pal.reset(load_palette(rf.filename().c_str()));
                }
            }

            // Save default.ase file
            if (pal) {
                palFile = defaultPalName;
                save_palette(palFile.c_str(), pal.get(), 0);
            }
        }
    }

    if (pal)
        set_default_palette(pal.get());

    set_current_palette(nullptr, true);
}
コード例 #6
0
ファイル: colorsel.cpp プロジェクト: bb-generation/gobby
Gobby::ColorSelectionDialog::~ColorSelectionDialog()
{
	save_palette(m_config_entry, *get_colorsel() );
}
コード例 #7
0
ファイル: colorsel.cpp プロジェクト: bb-generation/gobby
Gobby::ColorSelection::~ColorSelection()
{
	save_palette(m_config_entry, *this);
}