📄 qxpmhandler.cpp
字号:
/******************************************************************************** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.**** This file is part of the QtGui module of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file. Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://trolltech.com/products/qt/licenses/licensing/opensource/**** If you are unsure which license is appropriate for your use, please** review the following information:** http://trolltech.com/products/qt/licenses/licensing/licensingoverview** or contact the sales department at sales@trolltech.com.**** In addition, as a special exception, Trolltech gives you certain** additional rights. These rights are described in the Trolltech GPL** Exception version 1.0, which can be found at** http://www.trolltech.com/products/qt/gplexception/ and in the file** GPL_EXCEPTION.txt in this package.**** In addition, as a special exception, Trolltech, as the sole copyright** holder for Qt Designer, grants users of the Qt/Eclipse Integration** plug-in the right for the Qt/Eclipse Integration to link to** functionality provided by Qt Designer and its related libraries.**** Trolltech reserves all rights not expressly granted herein.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#include "private/qxpmhandler_p.h"#ifndef QT_NO_IMAGEFORMAT_XPM#include <private/qcolor_p.h>#include <qimage.h>#include <qmap.h>#include <qtextstream.h>#include <qvariant.h>#if defined(Q_CC_BOR)// needed for qsort() because of a std namespace problem on Borland#include "qplatformdefs.h"#endif#include <stdlib.h>static quint64 xpmHash(const QString &str){ unsigned int hashValue = 0; for (int i = 0; i < str.size(); ++i) { hashValue <<= 8; hashValue += (unsigned int)str.at(i).unicode(); } return hashValue;}static quint64 xpmHash(char *str){ unsigned int hashValue = 0; while (*str != '\0') { hashValue <<= 8; hashValue += (unsigned int)*str; ++str; } return hashValue;}#ifdef QRGB#undef QRGB#endif#define QRGB(r,g,b) (r*65536 + g*256 + b)static const int xpmRgbTblSize = 657;static const struct XPMRGBData { uint value; const char *name;} xpmRgbTbl[] = { { QRGB(240,248,255), "aliceblue" }, { QRGB(250,235,215), "antiquewhite" }, { QRGB(255,239,219), "antiquewhite1" }, { QRGB(238,223,204), "antiquewhite2" }, { QRGB(205,192,176), "antiquewhite3" }, { QRGB(139,131,120), "antiquewhite4" }, { QRGB(127,255,212), "aquamarine" }, { QRGB(127,255,212), "aquamarine1" }, { QRGB(118,238,198), "aquamarine2" }, { QRGB(102,205,170), "aquamarine3" }, { QRGB( 69,139,116), "aquamarine4" }, { QRGB(240,255,255), "azure" }, { QRGB(240,255,255), "azure1" }, { QRGB(224,238,238), "azure2" }, { QRGB(193,205,205), "azure3" }, { QRGB(131,139,139), "azure4" }, { QRGB(245,245,220), "beige" }, { QRGB(255,228,196), "bisque" }, { QRGB(255,228,196), "bisque1" }, { QRGB(238,213,183), "bisque2" }, { QRGB(205,183,158), "bisque3" }, { QRGB(139,125,107), "bisque4" }, { QRGB( 0, 0, 0), "black" }, { QRGB(255,235,205), "blanchedalmond" }, { QRGB( 0, 0,255), "blue" }, { QRGB( 0, 0,255), "blue1" }, { QRGB( 0, 0,238), "blue2" }, { QRGB( 0, 0,205), "blue3" }, { QRGB( 0, 0,139), "blue4" }, { QRGB(138, 43,226), "blueviolet" }, { QRGB(165, 42, 42), "brown" }, { QRGB(255, 64, 64), "brown1" }, { QRGB(238, 59, 59), "brown2" }, { QRGB(205, 51, 51), "brown3" }, { QRGB(139, 35, 35), "brown4" }, { QRGB(222,184,135), "burlywood" }, { QRGB(255,211,155), "burlywood1" }, { QRGB(238,197,145), "burlywood2" }, { QRGB(205,170,125), "burlywood3" }, { QRGB(139,115, 85), "burlywood4" }, { QRGB( 95,158,160), "cadetblue" }, { QRGB(152,245,255), "cadetblue1" }, { QRGB(142,229,238), "cadetblue2" }, { QRGB(122,197,205), "cadetblue3" }, { QRGB( 83,134,139), "cadetblue4" }, { QRGB(127,255, 0), "chartreuse" }, { QRGB(127,255, 0), "chartreuse1" }, { QRGB(118,238, 0), "chartreuse2" }, { QRGB(102,205, 0), "chartreuse3" }, { QRGB( 69,139, 0), "chartreuse4" }, { QRGB(210,105, 30), "chocolate" }, { QRGB(255,127, 36), "chocolate1" }, { QRGB(238,118, 33), "chocolate2" }, { QRGB(205,102, 29), "chocolate3" }, { QRGB(139, 69, 19), "chocolate4" }, { QRGB(255,127, 80), "coral" }, { QRGB(255,114, 86), "coral1" }, { QRGB(238,106, 80), "coral2" }, { QRGB(205, 91, 69), "coral3" }, { QRGB(139, 62, 47), "coral4" }, { QRGB(100,149,237), "cornflowerblue" }, { QRGB(255,248,220), "cornsilk" }, { QRGB(255,248,220), "cornsilk1" }, { QRGB(238,232,205), "cornsilk2" }, { QRGB(205,200,177), "cornsilk3" }, { QRGB(139,136,120), "cornsilk4" }, { QRGB( 0,255,255), "cyan" }, { QRGB( 0,255,255), "cyan1" }, { QRGB( 0,238,238), "cyan2" }, { QRGB( 0,205,205), "cyan3" }, { QRGB( 0,139,139), "cyan4" }, { QRGB( 0, 0,139), "darkblue" }, { QRGB( 0,139,139), "darkcyan" }, { QRGB(184,134, 11), "darkgoldenrod" }, { QRGB(255,185, 15), "darkgoldenrod1" }, { QRGB(238,173, 14), "darkgoldenrod2" }, { QRGB(205,149, 12), "darkgoldenrod3" }, { QRGB(139,101, 8), "darkgoldenrod4" }, { QRGB(169,169,169), "darkgray" }, { QRGB( 0,100, 0), "darkgreen" }, { QRGB(169,169,169), "darkgrey" }, { QRGB(189,183,107), "darkkhaki" }, { QRGB(139, 0,139), "darkmagenta" }, { QRGB( 85,107, 47), "darkolivegreen" }, { QRGB(202,255,112), "darkolivegreen1" }, { QRGB(188,238,104), "darkolivegreen2" }, { QRGB(162,205, 90), "darkolivegreen3" }, { QRGB(110,139, 61), "darkolivegreen4" }, { QRGB(255,140, 0), "darkorange" }, { QRGB(255,127, 0), "darkorange1" }, { QRGB(238,118, 0), "darkorange2" }, { QRGB(205,102, 0), "darkorange3" }, { QRGB(139, 69, 0), "darkorange4" }, { QRGB(153, 50,204), "darkorchid" }, { QRGB(191, 62,255), "darkorchid1" }, { QRGB(178, 58,238), "darkorchid2" }, { QRGB(154, 50,205), "darkorchid3" }, { QRGB(104, 34,139), "darkorchid4" }, { QRGB(139, 0, 0), "darkred" }, { QRGB(233,150,122), "darksalmon" }, { QRGB(143,188,143), "darkseagreen" }, { QRGB(193,255,193), "darkseagreen1" }, { QRGB(180,238,180), "darkseagreen2" }, { QRGB(155,205,155), "darkseagreen3" }, { QRGB(105,139,105), "darkseagreen4" }, { QRGB( 72, 61,139), "darkslateblue" }, { QRGB( 47, 79, 79), "darkslategray" }, { QRGB(151,255,255), "darkslategray1" }, { QRGB(141,238,238), "darkslategray2" }, { QRGB(121,205,205), "darkslategray3" }, { QRGB( 82,139,139), "darkslategray4" }, { QRGB( 47, 79, 79), "darkslategrey" }, { QRGB( 0,206,209), "darkturquoise" }, { QRGB(148, 0,211), "darkviolet" }, { QRGB(255, 20,147), "deeppink" }, { QRGB(255, 20,147), "deeppink1" }, { QRGB(238, 18,137), "deeppink2" }, { QRGB(205, 16,118), "deeppink3" }, { QRGB(139, 10, 80), "deeppink4" }, { QRGB( 0,191,255), "deepskyblue" }, { QRGB( 0,191,255), "deepskyblue1" }, { QRGB( 0,178,238), "deepskyblue2" }, { QRGB( 0,154,205), "deepskyblue3" }, { QRGB( 0,104,139), "deepskyblue4" }, { QRGB(105,105,105), "dimgray" }, { QRGB(105,105,105), "dimgrey" }, { QRGB( 30,144,255), "dodgerblue" }, { QRGB( 30,144,255), "dodgerblue1" }, { QRGB( 28,134,238), "dodgerblue2" }, { QRGB( 24,116,205), "dodgerblue3" }, { QRGB( 16, 78,139), "dodgerblue4" }, { QRGB(178, 34, 34), "firebrick" }, { QRGB(255, 48, 48), "firebrick1" }, { QRGB(238, 44, 44), "firebrick2" }, { QRGB(205, 38, 38), "firebrick3" }, { QRGB(139, 26, 26), "firebrick4" }, { QRGB(255,250,240), "floralwhite" }, { QRGB( 34,139, 34), "forestgreen" }, { QRGB(220,220,220), "gainsboro" }, { QRGB(248,248,255), "ghostwhite" }, { QRGB(255,215, 0), "gold" }, { QRGB(255,215, 0), "gold1" }, { QRGB(238,201, 0), "gold2" }, { QRGB(205,173, 0), "gold3" }, { QRGB(139,117, 0), "gold4" }, { QRGB(218,165, 32), "goldenrod" }, { QRGB(255,193, 37), "goldenrod1" }, { QRGB(238,180, 34), "goldenrod2" }, { QRGB(205,155, 29), "goldenrod3" }, { QRGB(139,105, 20), "goldenrod4" }, { QRGB(190,190,190), "gray" }, { QRGB( 0, 0, 0), "gray0" }, { QRGB( 3, 3, 3), "gray1" }, { QRGB( 26, 26, 26), "gray10" }, { QRGB(255,255,255), "gray100" }, { QRGB( 28, 28, 28), "gray11" }, { QRGB( 31, 31, 31), "gray12" }, { QRGB( 33, 33, 33), "gray13" }, { QRGB( 36, 36, 36), "gray14" }, { QRGB( 38, 38, 38), "gray15" }, { QRGB( 41, 41, 41), "gray16" }, { QRGB( 43, 43, 43), "gray17" }, { QRGB( 46, 46, 46), "gray18" }, { QRGB( 48, 48, 48), "gray19" }, { QRGB( 5, 5, 5), "gray2" }, { QRGB( 51, 51, 51), "gray20" }, { QRGB( 54, 54, 54), "gray21" }, { QRGB( 56, 56, 56), "gray22" }, { QRGB( 59, 59, 59), "gray23" }, { QRGB( 61, 61, 61), "gray24" }, { QRGB( 64, 64, 64), "gray25" }, { QRGB( 66, 66, 66), "gray26" }, { QRGB( 69, 69, 69), "gray27" }, { QRGB( 71, 71, 71), "gray28" }, { QRGB( 74, 74, 74), "gray29" }, { QRGB( 8, 8, 8), "gray3" }, { QRGB( 77, 77, 77), "gray30" }, { QRGB( 79, 79, 79), "gray31" }, { QRGB( 82, 82, 82), "gray32" }, { QRGB( 84, 84, 84), "gray33" }, { QRGB( 87, 87, 87), "gray34" }, { QRGB( 89, 89, 89), "gray35" }, { QRGB( 92, 92, 92), "gray36" }, { QRGB( 94, 94, 94), "gray37" }, { QRGB( 97, 97, 97), "gray38" }, { QRGB( 99, 99, 99), "gray39" }, { QRGB( 10, 10, 10), "gray4" }, { QRGB(102,102,102), "gray40" }, { QRGB(105,105,105), "gray41" }, { QRGB(107,107,107), "gray42" }, { QRGB(110,110,110), "gray43" }, { QRGB(112,112,112), "gray44" }, { QRGB(115,115,115), "gray45" }, { QRGB(117,117,117), "gray46" }, { QRGB(120,120,120), "gray47" }, { QRGB(122,122,122), "gray48" }, { QRGB(125,125,125), "gray49" }, { QRGB( 13, 13, 13), "gray5" }, { QRGB(127,127,127), "gray50" }, { QRGB(130,130,130), "gray51" }, { QRGB(133,133,133), "gray52" }, { QRGB(135,135,135), "gray53" }, { QRGB(138,138,138), "gray54" }, { QRGB(140,140,140), "gray55" }, { QRGB(143,143,143), "gray56" }, { QRGB(145,145,145), "gray57" }, { QRGB(148,148,148), "gray58" }, { QRGB(150,150,150), "gray59" }, { QRGB( 15, 15, 15), "gray6" }, { QRGB(153,153,153), "gray60" }, { QRGB(156,156,156), "gray61" }, { QRGB(158,158,158), "gray62" }, { QRGB(161,161,161), "gray63" }, { QRGB(163,163,163), "gray64" }, { QRGB(166,166,166), "gray65" }, { QRGB(168,168,168), "gray66" }, { QRGB(171,171,171), "gray67" }, { QRGB(173,173,173), "gray68" }, { QRGB(176,176,176), "gray69" }, { QRGB( 18, 18, 18), "gray7" }, { QRGB(179,179,179), "gray70" }, { QRGB(181,181,181), "gray71" }, { QRGB(184,184,184), "gray72" }, { QRGB(186,186,186), "gray73" }, { QRGB(189,189,189), "gray74" }, { QRGB(191,191,191), "gray75" }, { QRGB(194,194,194), "gray76" }, { QRGB(196,196,196), "gray77" }, { QRGB(199,199,199), "gray78" }, { QRGB(201,201,201), "gray79" }, { QRGB( 20, 20, 20), "gray8" }, { QRGB(204,204,204), "gray80" }, { QRGB(207,207,207), "gray81" }, { QRGB(209,209,209), "gray82" }, { QRGB(212,212,212), "gray83" }, { QRGB(214,214,214), "gray84" }, { QRGB(217,217,217), "gray85" }, { QRGB(219,219,219), "gray86" }, { QRGB(222,222,222), "gray87" }, { QRGB(224,224,224), "gray88" }, { QRGB(227,227,227), "gray89" }, { QRGB( 23, 23, 23), "gray9" }, { QRGB(229,229,229), "gray90" }, { QRGB(232,232,232), "gray91" }, { QRGB(235,235,235), "gray92" }, { QRGB(237,237,237), "gray93" }, { QRGB(240,240,240), "gray94" }, { QRGB(242,242,242), "gray95" }, { QRGB(245,245,245), "gray96" }, { QRGB(247,247,247), "gray97" }, { QRGB(250,250,250), "gray98" }, { QRGB(252,252,252), "gray99" }, { QRGB( 0,255, 0), "green" }, { QRGB( 0,255, 0), "green1" }, { QRGB( 0,238, 0), "green2" }, { QRGB( 0,205, 0), "green3" }, { QRGB( 0,139, 0), "green4" }, { QRGB(173,255, 47), "greenyellow" }, { QRGB(190,190,190), "grey" }, { QRGB( 0, 0, 0), "grey0" }, { QRGB( 3, 3, 3), "grey1" }, { QRGB( 26, 26, 26), "grey10" }, { QRGB(255,255,255), "grey100" }, { QRGB( 28, 28, 28), "grey11" }, { QRGB( 31, 31, 31), "grey12" }, { QRGB( 33, 33, 33), "grey13" }, { QRGB( 36, 36, 36), "grey14" }, { QRGB( 38, 38, 38), "grey15" }, { QRGB( 41, 41, 41), "grey16" }, { QRGB( 43, 43, 43), "grey17" }, { QRGB( 46, 46, 46), "grey18" }, { QRGB( 48, 48, 48), "grey19" }, { QRGB( 5, 5, 5), "grey2" }, { QRGB( 51, 51, 51), "grey20" }, { QRGB( 54, 54, 54), "grey21" }, { QRGB( 56, 56, 56), "grey22" }, { QRGB( 59, 59, 59), "grey23" }, { QRGB( 61, 61, 61), "grey24" }, { QRGB( 64, 64, 64), "grey25" }, { QRGB( 66, 66, 66), "grey26" }, { QRGB( 69, 69, 69), "grey27" }, { QRGB( 71, 71, 71), "grey28" }, { QRGB( 74, 74, 74), "grey29" }, { QRGB( 8, 8, 8), "grey3" }, { QRGB( 77, 77, 77), "grey30" }, { QRGB( 79, 79, 79), "grey31" }, { QRGB( 82, 82, 82), "grey32" }, { QRGB( 84, 84, 84), "grey33" }, { QRGB( 87, 87, 87), "grey34" }, { QRGB( 89, 89, 89), "grey35" }, { QRGB( 92, 92, 92), "grey36" }, { QRGB( 94, 94, 94), "grey37" }, { QRGB( 97, 97, 97), "grey38" }, { QRGB( 99, 99, 99), "grey39" }, { QRGB( 10, 10, 10), "grey4" }, { QRGB(102,102,102), "grey40" }, { QRGB(105,105,105), "grey41" }, { QRGB(107,107,107), "grey42" }, { QRGB(110,110,110), "grey43" }, { QRGB(112,112,112), "grey44" }, { QRGB(115,115,115), "grey45" }, { QRGB(117,117,117), "grey46" }, { QRGB(120,120,120), "grey47" }, { QRGB(122,122,122), "grey48" }, { QRGB(125,125,125), "grey49" }, { QRGB( 13, 13, 13), "grey5" }, { QRGB(127,127,127), "grey50" }, { QRGB(130,130,130), "grey51" }, { QRGB(133,133,133), "grey52" }, { QRGB(135,135,135), "grey53" }, { QRGB(138,138,138), "grey54" }, { QRGB(140,140,140), "grey55" }, { QRGB(143,143,143), "grey56" }, { QRGB(145,145,145), "grey57" }, { QRGB(148,148,148), "grey58" }, { QRGB(150,150,150), "grey59" }, { QRGB( 15, 15, 15), "grey6" }, { QRGB(153,153,153), "grey60" }, { QRGB(156,156,156), "grey61" }, { QRGB(158,158,158), "grey62" }, { QRGB(161,161,161), "grey63" }, { QRGB(163,163,163), "grey64" }, { QRGB(166,166,166), "grey65" }, { QRGB(168,168,168), "grey66" }, { QRGB(171,171,171), "grey67" }, { QRGB(173,173,173), "grey68" }, { QRGB(176,176,176), "grey69" }, { QRGB( 18, 18, 18), "grey7" }, { QRGB(179,179,179), "grey70" }, { QRGB(181,181,181), "grey71" }, { QRGB(184,184,184), "grey72" }, { QRGB(186,186,186), "grey73" }, { QRGB(189,189,189), "grey74" }, { QRGB(191,191,191), "grey75" }, { QRGB(194,194,194), "grey76" }, { QRGB(196,196,196), "grey77" }, { QRGB(199,199,199), "grey78" }, { QRGB(201,201,201), "grey79" }, { QRGB( 20, 20, 20), "grey8" }, { QRGB(204,204,204), "grey80" },
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -