best place for a helper function
Alin M Elena
alinm.elena at gmail.com
Fri Mar 1 09:28:01 UTC 2013
Hi,
I am working on a small feature (set to gray offline users' avatars). For that I
have a small helper function to turn a pixmap in a grayscale image... As it
needs to be used in few places I would not duplicate the code all over (it is
against my non-religious beliefs), so what is the best place to put it?
Do we have a namespace in common internals for something like this?
regards,
Alin
here is the code:
avatarToGray(QPixmap &avatar)
{
QImage image = avatar.toImage();
QBitmap alphaMask=avatar.mask();
for(int i=0;i<image.width();++i){
for (int j=0;j<image.height();++j){
int colour=qGray(image.pixel(i,j));
image.setPixel(i, j, qRgb(colour,colour,colour));
}
}
avatar=avatar.fromImage(image);
avatar.setMask(alphaMask);
}
--
Without Questions there are no Answers!
______________________________________________________________________
Alin Marin ELENA
Advanced Molecular Simulation Research Laboratory
School of Physics, University College Dublin
----
Ardionsamblú Móilíneach Saotharlann Taighde
Scoil na Fisice, An Coláiste Ollscoile, Baile Átha Cliath
-----------------------------------------------------------------------------------
http://alin.elenaworld.net
______________________________________________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Alin M Elena.vcf
Type: text/vcard
Size: 3392 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-telepathy/attachments/20130301/69fe20ef/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2033 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-telepathy/attachments/20130301/69fe20ef/attachment-0001.p7s>
More information about the KDE-Telepathy
mailing list