本文整理汇总了C++中QBitmap::fromData方法的典型用法代码示例。如果您正苦于以下问题:C++ QBitmap::fromData方法的具体用法?C++ QBitmap::fromData怎么用?C++ QBitmap::fromData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBitmap
的用法示例。
在下文中一共展示了QBitmap::fromData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: timerDone
void MainWindow::timerDone() {
if (!working) {
working = true;
int result;
while((result = video_next(cur)) < -1);
if(result != -1) {
if (result == 0) {
counter++;
ui->statusBar->showMessage(QString("%1").arg(counter) + " frames processed.");
QImage img(cur->pDat->data[0], cur->width, cur->height, QImage::Format_ARGB32);
QBitmap bmp;
bmp.fromData(QSize(cur->width, cur->height), cur->pDat->data[0]);
QColor color;
QColor avgColor;
double avgColorRed = 0;
double avgColorGreen = 0;
double avgColorBlue = 0;
QColor avgColortl;
double avgColorRedtl = 0;
double avgColorGreentl = 0;
double avgColorBluetl = 0;
QColor avgColortr;
double avgColorRedtr = 0;
double avgColorGreentr = 0;
double avgColorBluetr = 0;
QColor avgColorbl;
double avgColorRedbl = 0;
double avgColorGreenbl = 0;
double avgColorBluebl = 0;
QColor avgColorbr;
double avgColorRedbr = 0;
double avgColorGreenbr = 0;
double avgColorBluebr = 0;
QColor brightness;
double avg = 0;
double diffRed = 0;
double diffGreen = 0;
double diffBlue = 0;
double moodRed = 0;
double moodGreen = 0;
double moodBlue = 0;
for (int w = 0; w < img.width(); w++) {
for (int h = 0; h < img.height(); h++) {
color = img.pixel(QPoint(w,h));
if (w < img.width() / 2 && h < img.height() / 2) {
avgColorRedtl += color.red();
avgColorGreentl += color.green();
avgColorBluetl += color.blue();
} else if (w > img.width() / 2 && h < img.height() / 2) {
avgColorRedtr += color.red();
avgColorGreentr += color.green();
avgColorBluetr += color.blue();
} else if (w < img.width() / 2 && h > img.height() / 2) {
avgColorRedbl += color.red();
avgColorGreenbl += color.green();
avgColorBluebl += color.blue();
} else if (w > img.width() / 2 && h > img.height() / 2) {
avgColorRedbr += color.red();
avgColorGreenbr += color.green();
avgColorBluebr += color.blue();
}
avgColorRed += color.red();
avgColorGreen += color.green();
avgColorBlue += color.blue();
avg += ((color.red() + color.green() + color.blue()) / 3);
if (!imageSave.isNull() && (int)counter % 2) {
QColor subtractColor = imageSave.pixel(QPoint(w,h));
diffRed += color.red();
diffGreen += color.green();
diffBlue += color.blue();
}
// MoodBar
if (h < img.height() / 3) {
moodRed += color.red();
} else if (h > (img.height() / 3) *2) {
moodBlue += color.green();
} else {
moodGreen += color.blue();
}
}
}
// Average Color (Whole Image)
avgColor.setRed(avgColorRed / (img.width() * img.height()));
avgColor.setGreen(avgColorGreen / (img.width() * img.height()));
avgColor.setBlue(avgColorBlue / (img.width() * img.height()));
avgColorList << avgColor;
QImage avgColorDisplayImage(avgColorList.size(),20,QImage::Format_RGB32);
QPainter a(&avgColorDisplayImage);
for (int i = 0; i < avgColorList.size(); i+=1) {
//.........这里部分代码省略.........