Logo Search packages:      
Sourcecode: kbarcode version File versions  Download package

QPixmap BarCode::addMargin ( QPixmap *  pic,
int  margin 
) [private]

Add a margin to the QPixmap pic.

Parameters:
pic the QPixmap pic which should get a margin
margin the margin size in pixels.

Definition at line 343 of file mybarcode.cpp.

References hasFeature().

{
    QPixmap p;

    /* We have to handle UPC special because of the checksum character
     * which is printed on the right margin.
     * The samve goes for ISBN codes.
     * Any other formats??
     */

    bool gnubarcode = BarCode::hasFeature( barcode.type, GNU_BARCODE );
    double barm = gnubarcode ? BARCODE_MARGIN * barcode.scale : 0;

    // Add margin
    double sx = barm;
    double sy = barm;
    double sw = pic->width() - barm * 2;
    double sh = pic->height() - barm * 2;

    if( gnubarcode && (barcode.type == "upc" || barcode.type == "isbn") ) {
        sw = pic->width() - barm;

        p.resize( pic->width() + int(margin*2 - barm), pic->height() + int(margin * 2 - barm * 2) );
    } else
        p.resize( pic->width() + int(margin*2 - barm * 2), pic->height() + int(margin * 2 - barm * 2) );

    p.fill( Qt::white ); // barcode.bg
    QPainter painter( &p );
    painter.drawPixmap( margin, margin, *pic, (int)sx, (int)sy, (int)sw, (int)sh );
    painter.end();

    return p;
}


Generated by  Doxygen 1.6.0   Back to index