【Qt】Watermark


【目的】

  • 製作浮水印效果。

【程式】

  • 擷取一部分程式碼, 裡面 QFont/QImage/QColor 請自行指定初值。
    QFont    font;
    QImage   image;
    QColor   color;
    QString  str = tr("test");
    QPainter painter(&image);
    int      x = y = 10;
    
    painter.setFont(font);
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.setPen(QPen(color, 20, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
    QFontMetrics fm = painter.fontMetrics();
    painter.drawText(x, y+ fm.ascent(), str);

【參考】

  1. Qt4 Gossip: QPainter
    http://hi.baidu.com/lincon_lin/blog/item/dfe3672bbeb12e92023bf63b.html
  2. [Qt Topic] – 二维绘图研习,做一个简单批量水印工具
    http://blog.csdn.net/jasonblog/archive/2010/05/02/5551208.aspx
  3. QPen Class Reference
    http://www.vision.ee.ethz.ch/computing/sepp-irix/qt-2.3.1-mo/qpen.html
 

Ed32. Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com