C++ (Qt) QImage img; QRect removedRect; // .. получаем картинку и вычисляем регион QPainter p(&img); p.fillRect(removedRect, Qt::transparent);
C++ (Qt) int startX = removedRect.topLeft().x(); for (int i = 0; i < removedRect.height(); ++i) { uchar *scanline = img->scanLine(i); scanline += startX * 4; for (int x = 0; x < removedRect.width(); ++x) { *(scanline + x) = (uchar)0x00; *(scanline + x + 1) = (uchar)0x00; *(scanline + x + 2) = (uchar)0x00; *(scanline + x + 3) = (uchar)0x00; } }
C++ (Qt)while(!asleep()) sheep++;
C++ (Qt) p.fillRect(removedRect, Qt::transparent);
C++ (Qt)#include <QApplication>#include <QLabel>#include <QPainter>#include <QImage> int main(int argc, char *argv[]){ QApplication a(argc, argv); QImage img(QSize(500, 500), QImage::Format_ARGB32_Premultiplied); img.fill(Qt::green); { QPainter p(&img); p.fillRect(QRect(QPoint(0, 0), QSize(250, 250)), Qt::red); p.fillRect(QRect(QPoint(255, 255), QSize(250, 250)), Qt::transparent); } QLabel label; label.setPixmap(QPixmap::fromImage(img)); label.show(); return a.exec();}
C++ (Qt)p.setCompositionMode(QPainter::CompositionMode_Clear);p.fillRect(QRect(QPoint(255, 255), QSize(250, 250)), Qt::transparent);
C++ (Qt)p.setCompositionMode(QPainter::CompositionMode_Clear);