MCPcopy Create free account
hub / github.com/c3d/tao3D / AddImage

Method AddImage

tao/widget.cpp:10037–10099  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10035 }
10036
10037 void AddImage(QString file)
10038 {
10039 QFileInfo fi(file);
10040 if (fi.isDir())
10041 {
10042 QDir dir(file);
10043 QStringList subdirs = dir.entryList(QDir::Dirs | QDir::Files |
10044 QDir::Readable |
10045 QDir::NoDotAndDotDot);
10046 foreach (QString d, subdirs)
10047 AddImage(dir.cleanPath(dir.absoluteFilePath(d)));
10048 }
10049 else
10050 {
10051 QImage image(file);
10052 if (image.isNull())
10053 {
10054 QString qualified = "texture:" + file;
10055 image.load(qualified);
10056 }
10057 if (!image.isNull())
10058 {
10059 uint w = image.width();
10060 uint h = image.height();
10061
10062 if (w > maxWidth)
10063 {
10064 image = image.scaledToWidth(maxWidth,
10065 Qt::SmoothTransformation);
10066 w = image.width();
10067 h = image.height();
10068 }
10069 if (h > maxHeight)
10070 {
10071 image = image.scaledToHeight(maxHeight,
10072 Qt::SmoothTransformation);
10073 w = image.width();
10074 h = image.height();
10075 }
10076
10077 BinPacker::Rect rect;
10078 if (bp.Allocate(w + padWidth, h + padHeight, rect))
10079 {
10080 QPainter painter(&composite);
10081 painter.setBrush(Qt::transparent);
10082 painter.setPen(Qt::white);
10083 painter.drawImage(rect.x1, rect.y1, image);
10084 painter.end();
10085 }
10086 else
10087 {
10088 IFTRACE(picturepack)
10089 std::cerr << "No room for image " << +file
10090 << "(" << w << "x" << h << " pixels)\n";
10091 }
10092 }
10093 else
10094 {

Callers

nothing calls this directly

Calls 7

isNullMethod · 0.80
IFTRACEFunction · 0.70
loadMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45
AllocateMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected