コード例 #1
0
ファイル: PngImageLoader.cpp プロジェクト: matthewhinkle/bamf
Resource * PngImageLoader::load(uint64_t id, const std::string & path)
{
	pngio_t pngio;
	int notinited = pngio_init(&pngio);
	SDL_assert(!(notinited));

	const char * filename = path.c_str();
	int failed = pngio_read(&pngio, filename);
	if(failed) {
		pngio_destroy(&pngio);
		return NULL;
	}
	
	Resource * resource = new ImageResource(
		id,
		path,
		const_cast<unsigned char *>(pngio_image_data(&pngio)),
		static_cast<unsigned>(pngio_size(&pngio) / sizeof(unsigned char)),
		static_cast<unsigned>(pngio_width(&pngio)),
		static_cast<unsigned>(pngio_height(&pngio)),
		pngio_bit_depth(&pngio),
		getColorType(pngio_color_type(&pngio)));
		
	pngio_destroy(&pngio);
	
	return resource;
}
コード例 #2
0
void SettingsWindow::onSelectorClicked()
{
    Colors emitter = getColorType (QObject::sender());

    /* Configure the color dialog */
    QString color;
    QColorDialog dialog;
    dialog.setCurrentColor (getColorValue (emitter));
    dialog.setOption (QColorDialog::DontUseNativeDialog);

    /* Get new color */
    if (dialog.exec() == QColorDialog::Accepted)
        color = QVariant (dialog.currentColor()).toString();

    /* User clicked the 'Cancel' button in the color dialog */
    else
        return;

    /* Update the line edit that matches the button that called this function */
    switch (emitter)
        {
        case Base:
            m_baseEdit->setText (color);
            break;
        case Highlight:
            m_highlightEdit->setText (color);
            break;
        case Background:
            m_backgroundEdit->setText (color);
            break;
        case Foreground:
            m_foregroundEdit->setText (color);
            break;
        }
}
コード例 #3
0
void SettingsWindow::onColorChanged (QString color)
{
    Colors emitter = getColorType (QObject::sender());

    /* The color is empty, use the previous value */
    if (color.isEmpty())
        color = QVariant (getColorValue (emitter)).toString();

    /* Make sure that the color is formatted as a HEX color */
    if (!color.contains ("#"))
        color = "#" + color;

    /* We use CSS to change the color of the preview box */
    QString style = COLOR_RECTANGLE.arg (color);

    /* Update the preview box that matches the line edit that was changed */
    switch (emitter)
        {
        case Base:
            m_baseEdit->setText (color);
            m_baseColor->setStyleSheet (style);
            break;
        case Highlight:
            m_highlightEdit->setText (color);
            m_highlightColor->setStyleSheet (style);
            break;
        case Background:
            m_backgroundEdit->setText (color);
            m_backgroundColor->setStyleSheet (style);
            break;
        case Foreground:
            m_foregroundEdit->setText (color);
            m_foregroundColor->setStyleSheet (style);
            break;
        }
}