Example #1
0
BitmapUtils* BitmapUtils::Create(const DynamicFormat& dst_format,
								 const DynamicFormat& src_format,
								 bool need_source) {
	if (!maps_initialized) {
		for (const BitmapUtilsP* pp = bitmap_utils; *pp != NULL; pp++) {
			BitmapUtilsP p = *pp;
			const DynamicFormat& dfmt = p->GetDstFormat();
			const DynamicFormat& sfmt = p->GetSrcFormat();
			int dkey = dfmt.code(true);
			int skey = sfmt.code(true);
			unary_map[dkey] = p;
			binary_map[int_pair(dkey, skey)] = p;
		}

		maps_initialized = true;
	}

	if (need_source) {
		std::map<int_pair, BitmapUtils*>::const_iterator it;

		// static dst, static src
		int_pair key1(dst_format.code(true), src_format.code(true));
		it = binary_map.find(key1);
		if (it != binary_map.end())
			return it->second;

		// dynamic dst, static src
		int_pair key2(dst_format.code(false), src_format.code(true));
		it = binary_map.find(key2);
		if (it != binary_map.end()) {
			it->second->SetDstFormat(dst_format);
			return it->second;
		}

		// static dst, dynamic src
		int_pair key3(dst_format.code(true), src_format.code(false));
		it = binary_map.find(key3);
		if (it != binary_map.end()) {
			it->second->SetSrcFormat(src_format);
			return it->second;
		}

		// dynamic dst, dynamic src
		int_pair key4(dst_format.code(false), src_format.code(false));
		it = binary_map.find(key4);
		if (it != binary_map.end()) {
			it->second->SetDstFormat(dst_format);
			it->second->SetSrcFormat(src_format);
			return it->second;
		}
	}
	else {
		std::map<int, BitmapUtils*>::const_iterator it;

		int key1 = dst_format.code(true);
		it = unary_map.find(key1);
		if (it != unary_map.end())
			return it->second;

		int key2 = dst_format.code(false);
		it = unary_map.find(key2);
		if (it != unary_map.end()) {
			it->second->SetDstFormat(dst_format);
			return it->second;
		}
	}

	Output::Error("Couldn't find a renderer");

	return NULL;
}
Example #2
0
QSize KExiv2::getImageDimensions() const
{
    try
    {
        long width=-1, height=-1;

        // Try to get Exif.Photo tags

        Exiv2::ExifData exifData(d->exifMetadata());
        Exiv2::ExifKey key("Exif.Photo.PixelXDimension");
        Exiv2::ExifData::iterator it = exifData.findKey(key);
        if (it != exifData.end() && it->count())
            width = it->toLong();

        Exiv2::ExifKey key2("Exif.Photo.PixelYDimension");
        Exiv2::ExifData::iterator it2 = exifData.findKey(key2);
        if (it2 != exifData.end() && it2->count())
            height = it2->toLong();

        if (width != -1 && height != -1)
            return QSize(width, height);

        // Try to get Exif.Image tags

        width  = -1;
        height = -1;

        Exiv2::ExifKey key3("Exif.Image.ImageWidth");
        Exiv2::ExifData::iterator it3 = exifData.findKey(key3);
        if (it3 != exifData.end() && it3->count())
            width = it3->toLong();

        Exiv2::ExifKey key4("Exif.Image.ImageLength");
        Exiv2::ExifData::iterator it4 = exifData.findKey(key4);
        if (it4 != exifData.end() && it4->count())
            height = it4->toLong();

        if (width != -1 && height != -1)
            return QSize(width, height);

#ifdef _XMP_SUPPORT_

        // Try to get Xmp.tiff tags

        width    = -1;
        height   = -1;
        bool wOk = false;
        bool hOk = false;

        QString str = getXmpTagString("Xmp.tiff.ImageWidth");
        if (!str.isEmpty())
            width = str.toInt(&wOk);

        str = getXmpTagString("Xmp.tiff.ImageLength");
        if (!str.isEmpty())
            height = str.toInt(&hOk);

        if (wOk && hOk)
            return QSize(width, height);

        // Try to get Xmp.exif tags

        width  = -1;
        height = -1;
        wOk    = false;
        hOk    = false;

        str = getXmpTagString("Xmp.exif.PixelXDimension");
        if (!str.isEmpty())
            width = str.toInt(&wOk);

        str = getXmpTagString("Xmp.exif.PixelYDimension");
        if (!str.isEmpty())
            height = str.toInt(&hOk);

        if (wOk && hOk)
            return QSize(width, height);

#endif // _XMP_SUPPORT_

    }
    catch( Exiv2::Error& e )
    {
        d->printExiv2ExceptionError("Cannot parse image dimensions tag using Exiv2 ", e);
    }
    catch(...)
    {
        kError() << "Default exception from Exiv2";
    }

    return QSize();
}
Example #3
0
rowTutor::rowTutor(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::rowTutor)
{
    // set up the GUI
    ui->setupUi(this);
    row.append('C');
    row.append('C');
    row.append('C');
    row.append('D');
    row.append('E');
    row.append('E');
    row.append('D');
    row.append('E');
    row.append('F');
    row.append('G');
    row.append('c');
    row.append('c');
    row.append('c');
    row.append('G');
    row.append('G');
    row.append('G');
    row.append('E');
    row.append('E');
    row.append('E');
    row.append('C');
    row.append('C');
    row.append('C');
    row.append('G');
    row.append('F');
    row.append('E');
    row.append('D');
    row.append('C');


    Song = new QSound("sounds/row.wav");
    connect(ui->aButton, SIGNAL(clicked()), this, SLOT(key1()));
    keyA = new QSound("sounds/C.wav");
    connect(ui->wButton, SIGNAL(clicked()), this, SLOT(key2()));
    keyW = new QSound("sounds/C#.wav");
    connect(ui->sButton, SIGNAL(clicked()), this, SLOT(key3()));
    keyS = new QSound("sounds/D.wav");
    connect(ui->eButton, SIGNAL(clicked()), this, SLOT(key4()));
    keyE = new QSound("sounds/D#.wav");
    connect(ui->dButton, SIGNAL(clicked()), this, SLOT(key5()));
    keyD = new QSound("sounds/E.wav");
    connect(ui->fButton, SIGNAL(clicked()), this, SLOT(key6()));
    keyF = new QSound("sounds/F.wav");
    connect(ui->tButton, SIGNAL(clicked()), this, SLOT(key7()));
    keyT = new QSound("sounds/F#.wav");
    connect(ui->gButton, SIGNAL(clicked()), this, SLOT(key8()));
    keyG = new QSound("sounds/G.wav");
    connect(ui->yButton, SIGNAL(clicked()), this, SLOT(key9()));
    keyY = new QSound("sounds/G#.wav");
    connect(ui->hButton, SIGNAL(clicked()), this, SLOT(key10()));
    keyH = new QSound("sounds/A.wav");
    connect(ui->uButton, SIGNAL(clicked()), this, SLOT(key11()));
    keyU = new QSound("sounds/A#.wav");
    connect(ui->jButton, SIGNAL(clicked()), this, SLOT(key12()));
    keyJ = new QSound("sounds/B.wav");
    connect(ui->kButton, SIGNAL(clicked()), this, SLOT(key13()));
    keyK = new QSound("sounds/HighC.wav");
    connect(ui->oButton, SIGNAL(clicked()), this, SLOT(key14()));
    keyO = new QSound("sounds/HiC#.wav");
    connect(ui->lButton, SIGNAL(clicked()), this, SLOT(key15()));
    keyL = new QSound("sounds/HiD.wav");
    connect(ui->pButton, SIGNAL(clicked()), this, SLOT(key16()));
    keyP = new QSound("sounds/HiD#.wav");
    connect(ui->semiButton, SIGNAL(clicked()), this, SLOT(key17()));
    keySemi = new QSound("sounds/HiE.wav");
    connect(ui->apostButton, SIGNAL(clicked()), this, SLOT(key18()));
    keyDot = new QSound("sounds/HiF.wav");

    arrayCount=0;
    playTutorSong(row);

       //enable Event Filters
    installEventFilter(this);
}