void Screen::saveBmp(char * outputFilename) const { clock_t startTimer, endTimer; printf("Saving file to \"%s\"...", outputFilename); fflush(stdout); startTimer = clock(); int pixelCount = height * width; C_FLT * redChannel = new C_FLT[pixelCount], * greenChannel = new C_FLT[pixelCount], * blueChannel = new C_FLT[pixelCount]; for (int i = 0, j = pixelCount - 1; i < pixelCount; i++, j--) { redChannel[i] = pixels[j].r; greenChannel[i] = pixels[j].g; blueChannel[i] = pixels[j].b; } bitmap_image bmpImage(width, height); bmpImage.import_rgb(redChannel, greenChannel, blueChannel); bmpImage.save_image(outputFilename); delete [] redChannel; delete [] greenChannel; delete [] blueChannel; endTimer = clock(); printf("completed (%.3f seconds).\n", clockTime(startTimer, endTimer)); }
QPixmap QSettingColorTableItem::CreatePixmap() const { if (m_pSetting == NULL || (m_pSetting->GetType() & 0xF) != Setting::SettingTypeColor) return QPixmap(); else { QPixmap bmpImage(sizeHint().height() - 4, sizeHint().height() - 4); QPainter dcImage; QColor clrBackground(m_pSetting->GetValue().strValue); dcImage.begin(&bmpImage, table()->viewport()); dcImage.setBackgroundColor(clrBackground.isValid() ? clrBackground : QColor(0, 0, 0)); dcImage.eraseRect(bmpImage.rect()); dcImage.drawRect(bmpImage.rect()); dcImage.end(); return bmpImage; } }