diff --git a/CMakeLists.txt b/CMakeLists.txt index b3969c96..99ae7a72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,13 +10,6 @@ include(KDE4Defaults) set(LIBRARY_TYPE SHARED) -find_package(PNG) -set_package_properties(PNG PROPERTIES - DESCRIPTION "An Open, Extensible Image Format with Lossless Compression" - URL "http://www.libpng.org/" - TYPE REQUIRED -) - # kdelibs requires 0.91 find_package(SharedMimeInfo 0.91) set_package_properties(SharedMimeInfo PROPERTIES @@ -57,11 +50,9 @@ if(Q_WS_X11) add_feature_info("libXTest" X11_XTest_FOUND "The X11 Testing Resource extension library is useful for automated testing of X clients") add_feature_info("libXcomposite" X11_Xcomposite_FOUND "The X11 Composite extension library may be used by Plasma and KWin") - add_feature_info("libXShm" X11_XShm_FOUND "The X11 shared-memory fences library may be used by ksplash") add_feature_info("libxf86misc" X11_xf86misc_FOUND "The X11 miscellaneous library may be used by keyboard KCM") # TODO: unused? add_feature_info("libXSync" X11_XSync_FOUND "The X11 synchronization may be used by KWin") add_feature_info("libXinput" X11_Xinput_FOUND "The X11 XINPUT extension library may be used by keyboard KCM") - add_feature_info("libXinerama" X11_Xinerama_FOUND "The X11 XINERAMA extension library may be used by ksplash") add_feature_info("libXRes" X11_XRes_FOUND "The X Resource library may be used by ksysguard") add_feature_info("libXext" X11_dpms_FOUND "The X extensions library may be used by kscreensaver") @@ -287,8 +278,6 @@ add_subdirectory(kwin) add_subdirectory(ksmserver) add_subdirectory(kscreensaver) -add_subdirectory(ksplash) - add_subdirectory(qguiplatformplugin_kde) add_subdirectory(ksysguard) @@ -296,7 +285,6 @@ add_subdirectory(kcontrol) add_subdirectory(klipper) add_subdirectory(kmenuedit) add_subdirectory(krunner) -add_subdirectory(kstartupconfig) add_subdirectory(freespacenotifier) add_subdirectory(kinfocenter) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 601c641c..0fac753d 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -18,14 +18,12 @@ check_function_exists(nice HAVE_NICE) check_include_files(malloc.h HAVE_MALLOC_H) kde4_bool_to_01(FONTCONFIG_FOUND HAVE_FONTCONFIG) # kcontrol/fonts kde4_bool_to_01(FREETYPE_FOUND HAVE_FREETYPE) # kcontrol/fonts -kde4_bool_to_01(X11_XShm_FOUND HAVE_XSHM) # ksplash kde4_bool_to_01(X11_XTest_FOUND HAVE_XTEST) # khotkeys, kxkb kde4_bool_to_01(X11_Xcomposite_FOUND HAVE_XCOMPOSITE) # plasma, kwin kde4_bool_to_01(X11_Xcursor_FOUND HAVE_XCURSOR) # many uses kde4_bool_to_01(X11_Xdamage_FOUND HAVE_XDAMAGE) # kwin kde4_bool_to_01(X11_Xfixes_FOUND HAVE_XFIXES) # klipper, kicker, kwin kde4_bool_to_01(X11_Xkb_FOUND HAVE_XKB) # kglobalaccel, kcontrol/keyboard -kde4_bool_to_01(X11_Xinerama_FOUND HAVE_XINERAMA) kde4_bool_to_01(X11_Xrandr_FOUND HAVE_XRANDR) # kwin kde4_bool_to_01(X11_Xrender_FOUND HAVE_XRENDER) # kcontrol/style, kicker kde4_bool_to_01(X11_xf86misc_FOUND HAVE_XF86MISC) # kcontrol/keyboard diff --git a/config-X11.h.cmake b/config-X11.h.cmake index 08dff0b7..9b3bd07f 100644 --- a/config-X11.h.cmake +++ b/config-X11.h.cmake @@ -13,12 +13,6 @@ /* Define if you have the XKB extension */ #cmakedefine HAVE_XKB 1 -/* Define if you have the Xinerama extension */ -#cmakedefine HAVE_XINERAMA 1 - -/* Define if you have the XSHM (MIT SHM) extension */ -#cmakedefine HAVE_XSHM 1 - /* Define if you have the XComposite extension */ #cmakedefine HAVE_XCOMPOSITE 1 diff --git a/kcminit/main.cpp b/kcminit/main.cpp index d8d3c5f6..78a07c08 100644 --- a/kcminit/main.cpp +++ b/kcminit/main.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -36,15 +37,14 @@ #include #include #include +#include #include -#include + #ifdef Q_WS_X11 #include #include #endif -#include - static int ready[ 2 ]; static bool startup = false; @@ -199,14 +199,6 @@ KCMInit::KCMInit( KCmdLineArgs* args ) if( startup ) { runModules( 0 ); - XEvent e; - e.xclient.type = ClientMessage; - e.xclient.message_type = XInternAtom( QX11Info::display(), "_KDE_SPLASH_PROGRESS", False ); - e.xclient.display = QX11Info::display(); - e.xclient.window = QX11Info::appRootWindow(); - e.xclient.format = 8; - strcpy( e.xclient.data.b, "kcminit" ); - XSendEvent( QX11Info::display(), QX11Info::appRootWindow(), False, SubstructureNotifyMask, &e ); sendReady(); QTimer::singleShot( 300 * 1000, qApp, SLOT(quit())); // just in case qApp->exec(); // wait for runPhase1() and runPhase2() diff --git a/kcontrol/CMakeLists.txt b/kcontrol/CMakeLists.txt index 128d7890..f67eb932 100644 --- a/kcontrol/CMakeLists.txt +++ b/kcontrol/CMakeLists.txt @@ -20,7 +20,6 @@ add_subdirectory( colors ) add_subdirectory( krdb ) add_subdirectory( style ) add_subdirectory( desktoptheme ) -add_subdirectory( splash ) add_subdirectory( standard_actions ) add_subdirectory( keys ) add_subdirectory( workspaceoptions ) diff --git a/kcontrol/input/mouse.desktop b/kcontrol/input/mouse.desktop index d7ebefb5..67c2b7f9 100644 --- a/kcontrol/input/mouse.desktop +++ b/kcontrol/input/mouse.desktop @@ -6,7 +6,7 @@ X-KDE-ServiceTypes=KCModule,KCModuleInit X-DocPath=kcontrol/mouse/index.html X-KDE-Library=kcm_input -X-KDE-Init-Symbol=mouse +X-KDE-Init-Symbol=kcminit_mouse X-KDE-Init-Phase=0 X-KDE-ParentApp=kcontrol diff --git a/kcontrol/randr/krandrmodule.cpp b/kcontrol/randr/krandrmodule.cpp index 84058fbc..c717fa0b 100644 --- a/kcontrol/randr/krandrmodule.cpp +++ b/kcontrol/randr/krandrmodule.cpp @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include #include "randr.h" @@ -36,6 +38,28 @@ K_PLUGIN_FACTORY(KSSFactory, registerPlugin();) K_EXPORT_PLUGIN(KSSFactory("krandr")) +extern "C" +{ + KDE_EXPORT void kcminit_randr() + { + // TODO: drop legacy config support + KConfig config("krandrrc"); + KConfigGroup group = config.group("Display"); + const bool applyonstartup = group.readEntry("ApplyOnStartup", false); + if (applyonstartup) { + const QStringList commands = group.readEntry("StartupCommands").split("\n"); + foreach (const QString &command, commands) { + KProcess kproc; + kproc.setShellCommand(command); + kproc.start(); + if (!kproc.waitForStarted() || !kproc.waitForFinished()) { + kWarning() << kproc.readAllStandardError(); + } + } + } + } +} + KRandRModule::KRandRModule(QWidget *parent, const QVariantList&) : KCModule(KSSFactory::componentData(), parent) { diff --git a/kcontrol/randr/randr.desktop b/kcontrol/randr/randr.desktop index 5c1460c4..c0762243 100644 --- a/kcontrol/randr/randr.desktop +++ b/kcontrol/randr/randr.desktop @@ -2,8 +2,10 @@ Exec=kcmshell4 randr Icon=preferences-desktop-display-randr Type=Service -X-KDE-ServiceTypes=KCModule +X-KDE-ServiceTypes=KCModule,KCModuleInit X-KDE-Library=kcm_randr +X-KDE-Init-Symbol=kcminit_randr +X-KDE-Init-Phase=0 X-KDE-ParentApp=kcontrol #This is always false when kbuildsycoca runs, probably because it is now a QCoreApplication #Hidden[$e]=$(if xdpyinfo|grep RANDR > /dev/null; then echo "false"; else echo "true"; fi) diff --git a/kcontrol/splash/CMakeLists.txt b/kcontrol/splash/CMakeLists.txt deleted file mode 100644 index e2c8b71a..00000000 --- a/kcontrol/splash/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ - -add_subdirectory( pics ) -include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${KDE4_INCLUDES} ) - -########### next target ############### - -set(kcm_ksplashthemes_PART_SRCS installer.cpp main.cpp ) -kde4_add_plugin(kcm_ksplashthemes ${kcm_ksplashthemes_PART_SRCS}) -target_link_libraries(kcm_ksplashthemes ${KDE4_KIO_LIBS} ${KDE4_KARCHIVE_LIBS}) -install(TARGETS kcm_ksplashthemes DESTINATION ${KDE4_PLUGIN_INSTALL_DIR} ) - -########### install files ############### - -install( FILES ksplashthememgr.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR} ) diff --git a/kcontrol/splash/Messages.sh b/kcontrol/splash/Messages.sh deleted file mode 100644 index ca41323b..00000000 --- a/kcontrol/splash/Messages.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -$XGETTEXT *.cpp -o $podir/ksplashthemes.pot diff --git a/kcontrol/splash/installer.cpp b/kcontrol/splash/installer.cpp deleted file mode 100644 index be697a40..00000000 --- a/kcontrol/splash/installer.cpp +++ /dev/null @@ -1,555 +0,0 @@ -/*************************************************************************** - * Copyright Ravikiran Rajagopal 2003 * - * ravi@ee.eng.ohio-state.edu * - * Copyright (c) 1998 Stefan Taferner * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License (version 2) as * - * published by the Free Software Foundation. * - * * - ***************************************************************************/ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "installer.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -ThemeListBox::ThemeListBox(QWidget *parent) - : KListWidget(parent) -{ - setAcceptDrops(true); -} - -void ThemeListBox::dragEnterEvent(QDragEnterEvent* event) -{ - event->setAccepted((event->source() != this) && KUrl::List::canDecode(event->mimeData())); -} - -void ThemeListBox::dragMoveEvent(QDragMoveEvent* event) -{ - event->setAccepted((event->source() != this) && KUrl::List::canDecode(event->mimeData())); -} - -void ThemeListBox::dropEvent(QDropEvent* event) -{ - KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); - if (!urls.isEmpty()) - { - emit filesDropped(urls); - } -} - -void ThemeListBox::mousePressEvent(QMouseEvent *e) -{ - if ((e->buttons() & Qt::LeftButton) != 0) - { - mOldPos = e->globalPos();; - mDragFile.clear(); - int cur = row(itemAt(e->pos())); - if (cur >= 0) - mDragFile = text2path[item(cur)->text()]; - } - KListWidget::mousePressEvent(e); -} - -void ThemeListBox::mouseMoveEvent(QMouseEvent *e) -{ - if (((e->buttons() & Qt::LeftButton) != 0) && !mDragFile.isEmpty()) - { - int delay = KGlobalSettings::dndEventDelay(); - QPoint newPos = e->globalPos(); - if(newPos.x() > mOldPos.x()+delay || newPos.x() < mOldPos.x()-delay || - newPos.y() > mOldPos.y()+delay || newPos.y() < mOldPos.y()-delay) - { - KUrl url; - url.setPath(mDragFile); - KUrl::List urls; - urls.append(url); - QDrag *drag = new QDrag(this); - QMimeData *mime = new QMimeData(); - urls.populateMimeData(mime); - drag->setMimeData(mime); - drag->start(); - } - } - KListWidget::mouseMoveEvent(e); -} - -//----------------------------------------------------------------------------- -SplashInstaller::SplashInstaller (QWidget *aParent, const char *aName, bool aInit) - : QWidget(aParent), mGui(!aInit) -{ - setObjectName(aName); - KGlobal::dirs()->addResourceType("ksplashthemes", "data", "ksplash/Themes"); - - if (!mGui) - return; - - QHBoxLayout* hbox = new QHBoxLayout( this ); - hbox->setMargin( 0 ); - - QVBoxLayout* leftbox = new QVBoxLayout( ); - hbox->addLayout( leftbox ); - hbox->setStretchFactor( leftbox, 1 ); - - mThemesList = new ThemeListBox(this); - mThemesList->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding ); - connect(mThemesList, SIGNAL(currentRowChanged(int)), SLOT(slotSetTheme(int))); - connect(mThemesList, SIGNAL(filesDropped(KUrl::List)), SLOT(slotFilesDropped(KUrl::List))); - leftbox->addWidget(mThemesList); - - mBtnAdd = new KPushButton( KIcon("document-import"), i18n("Install Theme File..."), this ); - mBtnAdd->setToolTip(i18n("Install a theme archive file you already have locally")); - mBtnAdd->setWhatsThis(i18n("If you already have a theme archive locally, this button will unpack it and make it available for KDE applications")); - leftbox->addWidget( mBtnAdd ); - connect(mBtnAdd, SIGNAL(clicked()), SLOT(slotAdd())); - - mBtnRemove = new KPushButton( KIcon("edit-delete"), i18n("Remove Theme"), this ); - mBtnRemove->setToolTip(i18n("Remove the selected theme from your disk")); - mBtnRemove->setWhatsThis(i18n("This will remove the selected theme from your disk.")); - mBtnRemove->setEnabled( false ); - leftbox->addWidget( mBtnRemove ); - connect(mBtnRemove, SIGNAL(clicked()), SLOT(slotRemove())); - - mBtnTest = new KPushButton( KIcon("document-preview"), i18n("Test Theme"), this ); - mBtnTest->setToolTip(i18n("Test the selected theme")); - mBtnTest->setWhatsThis(i18n("This will test the selected theme.")); - mBtnTest->setEnabled( false ); - leftbox->addWidget( mBtnTest ); - connect(mBtnTest, SIGNAL(clicked()), SLOT(slotTest())); - - QVBoxLayout* rightbox = new QVBoxLayout( ); - hbox->addLayout( rightbox ); - hbox->setStretchFactor( rightbox, 3 ); - - QScrollArea* scrollarea = new QScrollArea(this); - scrollarea->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); - mPreview = new QLabel(this); - scrollarea->setWidget(mPreview); - mPreview->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - mPreview->setMinimumSize(QSize(320,240)); - mPreview->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); - rightbox->addWidget(scrollarea); - rightbox->setStretchFactor( scrollarea, 3 ); - - mText = new QTextEdit(this); - mText->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - mText->setMinimumSize(mText->sizeHint().width(), 7 * mText->fontMetrics().height()); - mText->setReadOnly(true); - rightbox->addWidget(mText); - rightbox->setStretchFactor( mText, 1 ); - - - readThemesList(); - load(); -} - - -//----------------------------------------------------------------------------- -SplashInstaller::~SplashInstaller() -{ -} - -int SplashInstaller::addTheme(const QString &path, const QString &name) -{ - qDebug() << "SplashInstaller::addTheme: " << path << " " << name; - QString tmp(i18n( name.toUtf8() )); - int i = mThemesList->count(); - while((i > 0) && (mThemesList->item(i-1)->text() > tmp)) - i--; - if ((i > 0) && (mThemesList->item(i-1)->text() == tmp)) - return i-1; - mThemesList->insertItem(i , tmp); - mThemesList->text2path.insert( tmp, path+'/'+name ); - return i; -} - -// Copy theme package into themes directory -void SplashInstaller::addNewTheme(const KUrl &srcURL) -{ - const QString dir = KGlobal::dirs()->saveLocation("ksplashthemes"); - - KUrl url; - QStringList themeNames; - QString filename = srcURL.fileName(); - int i = filename.lastIndexOf('.'); - // Convert extension to lower case. - if (i >= 0) - filename = filename.left(i)+filename.mid(i).toLower(); - url.setPath(KStandardDirs::locateLocal("tmp",filename)); - - // Remove file from temporary directory if it aleady exists - usually the result of a failed install. - if ( KIO::NetAccess::exists( url, KIO::NetAccess::SourceSide, 0 ) ) - KIO::NetAccess::del( url, 0 ); - - if (srcURL.fileName().toLower() == "theme.rc" ) // uncompressed theme selected - { - QString themeName; - // Get the name of the Theme from the theme.rc file - KConfig _cnf(srcURL.path()); - KConfigGroup cnf(&_cnf, QString("KSplash Theme: %1").arg(themeName) ); - - // copy directory of theme.rc to ThemesDir - KIO::NetAccess::dircopy(KUrl(srcURL.directory()), KUrl(dir + themeName)); - - themeNames << themeName; - } - else - { - bool rc = KIO::NetAccess::file_copy(srcURL, url, 0); - if (!rc) - { - kWarning() << "Failed to copy theme " << srcURL.fileName() - << " into temporary directory " << url.path() << endl; - return; - } - - // extract into theme directory: we may have multiple themes in one tarball! - KArchive tarFile(url.path()); - if (!tarFile.isReadable()) - { - kWarning() << "Unable to open archive: " << url.path(); - KIO::NetAccess::del( url, 0 ); - return; - } - - // find theme directory entries. - foreach(const KArchiveEntry &e, tarFile.list()) - { - if( e.pathname.endsWith("/Theme.rc") ) - { - // each directory may contain one theme - themeNames << QFileInfo(e.pathname).path(); - } - } - if (themeNames.count() < 1) - { - kWarning() << "No directory in archive: " << url.path(); - KIO::NetAccess::del( url, 0 ); - return; - } - - // find all theme directory files - QStringList themeFiles; - foreach(const QString &t, themeNames) - { - foreach(const KArchiveEntry &e, tarFile.list(t + QDir::separator())) - { - themeFiles << QFile::decodeName(e.pathname); - } - } - - // copy the theme into the "ksplashthemes" directory - if (!tarFile.extract(themeFiles, dir)) { - kWarning() << "Could not extract: " << themeFiles; - } - - KIO::NetAccess::del( url, 0 ); - } - - readThemesList(); - mThemesList->setCurrentRow(findTheme(themeNames.first())); - if (mThemesList->currentItem()) - { - mThemesList->currentItem()->setSelected(true); - } -} - -//----------------------------------------------------------------------------- -void SplashInstaller::readThemesList() -{ - mThemesList->clear(); - - // Read local themes - const QStringList entryList = KGlobal::dirs()->resourceDirs("ksplashthemes"); - //kDebug() << "readThemesList: " << entryList; - QDir dir; - QStringList subdirs; - QStringList::ConstIterator name; - for(name = entryList.constBegin(); name != entryList.constEnd(); name++) - { - dir = *name; - if (!dir.exists()) - continue; - subdirs = dir.entryList( QDir::Dirs ); - // kDebug() << "readThemesList: " << subdirs; - // TODO: Make sure it contains a *.rc file. - for (QStringList::const_iterator l = subdirs.constBegin(); l != subdirs.constEnd(); l++ ) - if ( !(*l).startsWith(QString(".")) ) - { - mThemesList->blockSignals( true ); // Don't activate any theme until all themes are loaded. - addTheme(dir.path(),*l); - mThemesList->blockSignals( false ); - } - } -} - -//----------------------------------------------------------------------------- -void SplashInstaller::defaults() -{ - mThemesList->setCurrentRow(findTheme("Default")); - emit changed( true ); -} - -void SplashInstaller::load() -{ - KConfig _cnf( "ksplashrc" ); - KConfigGroup cnf(&_cnf, "KSplash"); - QString curTheme = cnf.readEntry("Theme","Default"); - mThemesList->setCurrentRow(findTheme(curTheme)); - emit changed( false ); -} - -//----------------------------------------------------------------------------- -void SplashInstaller::save() -{ - KConfig _cnf( "ksplashrc" ); - KConfigGroup cnf(&_cnf, "KSplash"); - int cur = mThemesList->currentRow(); - if (cur < 0) - return; - QString path = mThemesList->item(cur)->text(); - if ( mThemesList->text2path.contains( path ) ) - path = mThemesList->text2path[path]; - cur = path.lastIndexOf('/'); - cnf.writeEntry("Theme", path.mid(cur+1) ); - // save also the engine, so that it's known at KDE startup which splash implementation to use - cnf.writeEntry("Engine", mEngineOfSelected ); - cnf.sync(); - emit changed( false ); -} - -//----------------------------------------------------------------------------- -void SplashInstaller::slotRemove() -{ - int cur = mThemesList->currentRow(); - if (cur < 0) - return; - - bool rc = false; - const QString themeName = mThemesList->item(cur)->text(); - const QString themeDir = mThemesList->text2path[themeName]; - if (!themeDir.isEmpty()) - { - KUrl url; - url.setPath(themeDir); - if (KMessageBox::warningContinueCancel(this,i18n("Delete folder %1 and its contents?", themeDir),"",KGuiItem(i18n("&Delete"),"edit-delete"))==KMessageBox::Continue) - rc = KIO::NetAccess::del(url,this); - else - return; - } - if (!rc) - { - KMessageBox::sorry(this, i18n("Failed to remove theme '%1'", themeName)); - return; - } - //mThemesList->removeItem(cur); - readThemesList(); - cur = (cur >= mThemesList->count())?mThemesList->count()-1:cur; - mThemesList->setCurrentRow(cur); -} - - -//----------------------------------------------------------------------------- -void SplashInstaller::slotSetTheme(int id) -{ - bool enabled; - QString path = QString(); - QString infoTxt; - - if (id < 0) - { - mPreview->setText(QString()); - mText->setText(QString()); - enabled = false; - } - else - { - QString error = i18n("(Could not load theme)"); - path = mThemesList->item(id)->text(); - if ( mThemesList->text2path.contains( path ) ) - path = mThemesList->text2path[path]; - enabled = false; - KUrl url; - QString themeName; - if (!path.isEmpty()) - { - // Make sure the correct plugin is installed. - int i = path.lastIndexOf('/'); - if (i >= 0) - themeName = path.mid(i+1); - url.setPath( path + "/Theme.rc" ); - if (!KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0)) - { - url.setPath( path + "/Theme.RC" ); - if (!KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0)) - { - url.setPath( path + "/theme.rc" ); - if (!KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0)) - url.setPath( path + '/' + themeName + ".rc" ); - } - } - if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0)) - { - KConfig _cnf(url.path()); - KConfigGroup cnf(&_cnf, QString("KSplash Theme: %1").arg(themeName) ); - - // Get theme information. - infoTxt = ""; - if ( cnf.hasKey( "Name" ) ) - infoTxt += i18n( "Name: %1", cnf.readEntry( "Name", i18nc( "Unknown name", "Unknown" ) ) ) + "
"; - if ( cnf.hasKey( "Description" ) ) - infoTxt += i18n( "Description: %1", cnf.readEntry( "Description", i18nc( "Unknown description", "Unknown" ) ) ) + "
"; - if ( cnf.hasKey( "Version" ) ) - infoTxt += i18n( "Version: %1", cnf.readEntry( "Version", i18nc( "Unknown version", "Unknown" ) ) ) + "
"; - if ( cnf.hasKey( "Author" ) ) - infoTxt += i18n( "Author: %1", cnf.readEntry( "Author", i18nc( "Unknown author", "Unknown" ) ) ) + "
"; - if ( cnf.hasKey( "Homepage" ) ) - infoTxt += i18n( "Homepage: %1", cnf.readEntry( "Homepage", i18nc( "Unknown homepage", "Unknown" ) ) ) + "
"; - infoTxt += "
"; - - QString pluginName( cnf.readEntry( "Engine", "KSplashX" ).trimmed() ); - if( pluginName == "Simple" - || pluginName == "None" - || pluginName == "KSplashX" - || pluginName == "KSplashQML" - ) - enabled = true; // these are not plugins - else if ((KServiceTypeTrader::self()->query("KSplash/Plugin", QString("[X-KSplash-PluginName] == '%1'").arg(pluginName))).isEmpty()) - { - enabled = false; - error = i18n("This theme requires the plugin %1 which is not installed.", pluginName); - } - else - enabled = true; // Hooray, there is at least one plugin which can handle this theme. - mEngineOfSelected = pluginName; - } - else - { - error = i18n("Could not load theme configuration file."); - } - } - mBtnTest->setEnabled(enabled && themeName != "None" ); - mText->setHtml(infoTxt); - if (!enabled) - { - url.setPath( path + '/' + "Preview.png" ); - if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0)) - mPreview->setPixmap(QPixmap(url.path())); - else - mPreview->setText(i18n("(Could not load theme)")); - KMessageBox::sorry(this, error); - } - else - { - url.setPath( path + '/' + "Preview.png" ); - if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0)) - mPreview->setPixmap(QPixmap(url.path())); - else - mPreview->setText(i18n("No preview available.")); - emit changed(true); - } - } - mBtnRemove->setEnabled( !path.isEmpty() && QFileInfo(path).isWritable()); -} - -//----------------------------------------------------------------------------- -void SplashInstaller::slotAdd() -{ - static QString path; - if (path.isEmpty()) path = QDir::homePath(); - - KFileDialog dlg(path, "*.tgz *.tar.gz *.tar.bz2 theme.rc|" + i18n( "KSplash Theme Files" ), this); - dlg.setCaption(i18n("Add Theme")); - if (!dlg.exec()) - return; - - path = dlg.baseUrl().url(); - addNewTheme(dlg.selectedUrl()); -} - -//----------------------------------------------------------------------------- -void SplashInstaller::slotFilesDropped(const KUrl::List &urls) -{ - for(KUrl::List::ConstIterator it = urls.constBegin(); - it != urls.end(); - ++it) - addNewTheme(*it); -} - -//----------------------------------------------------------------------------- -int SplashInstaller::findTheme( const QString &theme ) -{ - // theme is untranslated, but the listbox contains translated items - QString tmp(i18n( theme.toUtf8() )); - int id = mThemesList->count()-1; - - while (id >= 0) - { - if (mThemesList->item(id)->text() == tmp) - return id; - id--; - } - - return 0; -} - -//----------------------------------------------------------------------------- -void SplashInstaller::slotTest() -{ - int i = mThemesList->currentRow(); - if (i < 0) - return; - QString themeName = mThemesList->text2path[mThemesList->item(i)->text()]; - int r = themeName.lastIndexOf('/'); - if (r >= 0) - themeName = themeName.mid(r+1); - - // special handling for none and simple splashscreens - qDebug() << "the engine is " << mEngineOfSelected << "for" << themeName; - if( mEngineOfSelected == "None" ) - return; - else if( mEngineOfSelected == "KSplashX" ) - { - if (QProcess::execute("ksplashx", QStringList() << themeName << "--test") != 0) - KMessageBox::error(this,i18n("Failed to successfully test the splash screen.")); - return; - } - else if( mEngineOfSelected == "KSplashQML" ) - { - if (QProcess::execute("ksplashqml", QStringList() << themeName << "--test") != 0) - KMessageBox::error(this,i18n("Failed to successfully test the splash screen.")); - return; - } - else // KSplashML engines - { - if (QProcess::execute("ksplash", QStringList() << "--test" << "--theme" << themeName) != 0) - KMessageBox::error(this,i18n("Failed to successfully test the splash screen.")); - } -} - -//----------------------------------------------------------------------------- -#include "moc_installer.cpp" diff --git a/kcontrol/splash/installer.h b/kcontrol/splash/installer.h deleted file mode 100644 index bdfb891b..00000000 --- a/kcontrol/splash/installer.h +++ /dev/null @@ -1,90 +0,0 @@ -/*************************************************************************** - * Copyright Ravikiran Rajagopal 2003 * - * ravi@ee.eng.ohio-state.edu * - * Copyright (c) 1998 Stefan Taferner * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License (version 2) as * - * published by the Free Software Foundation. * - * * - ***************************************************************************/ -#ifndef SPLASHINSTALLER_H -#define SPLASHINSTALLER_H - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -class ThemeListBox; - -class SplashInstaller : public QWidget -{ - Q_OBJECT -public: - SplashInstaller(QWidget *parent=0, const char *aName=0, bool aInit=false); - ~SplashInstaller(); - - virtual void load(); - virtual void save(); - virtual void defaults(); - -Q_SIGNALS: - void changed( bool state ); - -protected Q_SLOTS: - virtual void slotAdd(); - virtual void slotRemove(); - virtual void slotTest(); - virtual void slotSetTheme(int); - void slotFilesDropped(const KUrl::List &urls); - -protected: - /** Scan Themes directory for available theme packages */ - virtual void readThemesList(); - /** add a theme to the list, returns the list index */ - int addTheme(const QString &path, const QString &name); - void addNewTheme(const KUrl &srcURL); - int findTheme( const QString &theme ); - -private: - bool mGui; - ThemeListBox *mThemesList; - QString mEngineOfSelected; - QPushButton *mBtnAdd, *mBtnRemove, *mBtnTest; - QTextEdit *mText; - QLabel *mPreview; -}; - -class ThemeListBox: public KListWidget -{ - Q_OBJECT -public: - ThemeListBox(QWidget *parent); - QMap text2path; - -Q_SIGNALS: - void filesDropped(const KUrl::List &urls); - -protected: - void dragEnterEvent(QDragEnterEvent* event); - void dragMoveEvent(QDragMoveEvent* event); - void dropEvent(QDropEvent* event); - void mouseMoveEvent(QMouseEvent *e); - void mousePressEvent(QMouseEvent *e); - -private: - QString mDragFile; - QPoint mOldPos; - -}; - -#endif diff --git a/kcontrol/splash/ksplashthememgr.desktop b/kcontrol/splash/ksplashthememgr.desktop deleted file mode 100644 index e285b9cb..00000000 --- a/kcontrol/splash/ksplashthememgr.desktop +++ /dev/null @@ -1,226 +0,0 @@ -[Desktop Entry] -Icon=preferences-system-splash -Exec=kcmshell4 ksplashthememgr -X-DocPath=kcontrol/splashscreen/index.html - -Type=Service -X-KDE-ServiceTypes=KCModule - -X-KDE-Library=kcm_ksplashthemes -X-KDE-ParentApp=kcontrol - -X-KDE-System-Settings-Parent-Category=desktop-appearance -X-KDE-Weight=200 - -Name=Splash Screen -Name[af]=Spat Skerm -Name[ar]=شاشة البداية -Name[ast]=Pantalla Splash -Name[be]=Застаўка загрузкі -Name[be@latin]=Zastaŭka -Name[bg]=Начален екран -Name[bn]=স্প্ল্যাশ স্ক্রীণ -Name[br]=Skramm-degemer -Name[bs]=Uvodni ekran -Name[ca]=Pantalla de presentació -Name[ca@valencia]=Pantalla d'inici -Name[cs]=Úvodní obrazovka -Name[csb]=Ekran na przëwitanié -Name[cy]=Sgrîn Croeso -Name[da]=Splashskærm -Name[de]=Startbildschirm -Name[el]=Αρχική οθόνη -Name[en_GB]=Splash Screen -Name[eo]=Salutŝildo -Name[es]=Pantalla anunciadora -Name[et]=Käivitusekraan -Name[eu]=Harrerako pantaila -Name[fa]=رنگ‌پاشی پرده -Name[fi]=Tervetuloruutu -Name[fr]=Écran de démarrage -Name[fy]=Begjinskerm -Name[ga]=Splancscáileán -Name[gl]=Pantalla de benvida -Name[gu]=સ્પ્લેશ સ્ક્રિન -Name[he]=מצג פתיחה -Name[hi]=स्प्लैश स्क्रीन -Name[hne]=स्प्लैस स्क्रीन -Name[hr]=Pozdravni zaslon -Name[hsb]=Powitanka -Name[hu]=Nyitókép-témák -Name[ia]=Schermo de Splash -Name[id]=Layar Splash -Name[is]=Upphafsskjár -Name[kk]=Бейнепердесі -Name[km]=អេក្រង់​ស្វាគមន៍ -Name[kn]=ಸ್ಪ್ಲಾಷ್ ತೆರೆ -Name[ko]=시작 화면 -Name[ku]=Splash Screen -Name[lt]=Pasveikinimo ekranas -Name[lv]=Šļaksta ekrāns -Name[mai]=स्प्लैश स्क्रीन -Name[mk]=Поздравен екран -Name[ml]=മുഖചിത്രം -Name[mr]=स्प्लॅश स्क्रीन -Name[ms]=Splash Screen -Name[nb]=Velkomstbilde -Name[nds]=Startschirm -Name[ne]=स्प्लयास पर्दा -Name[nl]=Opstartscherm -Name[nn]=Velkomst­bilete -Name[pa]=ਸਵਾਗਤੀ ਸਕਰੀਨ -Name[pl]=Ekran powitalny -Name[pt]=Ecrã Inicial -Name[pt_BR]=Tela de apresentação -Name[ro]=Ecran de întîmpinare -Name[ru]=Заставка -Name[se]=Álgošearbma -Name[si]=ස්ප්ලෑෂ් තිරය -Name[sk]=Úvodná obrazovka -Name[sl]=Pozdravno okno -Name[sr]=Уводни екран -Name[sr@ijekavian]=Уводни екран -Name[sr@ijekavianlatin]=Uvodni ekran -Name[sr@latin]=Uvodni ekran -Name[sv]=Startskärm -Name[ta]=தோன்றும் திரை -Name[te]=స్ప్లాష్ స్క్రీన్ -Name[tg]=Пардаи боркунии экран -Name[th]=หน้าจอเริ่มการทำงาน -Name[tr]=Açılış ekranı -Name[ug]=مەرھابا ئېكرانى -Name[uk]=Вікно вітання -Name[uz]=Splesh oynasi -Name[uz@cyrillic]=Сплэш ойнаси -Name[vi]=Màn hình Chào mừng -Name[wa]=Waitroûle d' enondaedje -Name[x-test]=xxSplash Screenxx -Name[zh_CN]=欢迎屏幕 -Name[zh_TW]=啟動畫面 -Comment=Manager for Splash Screen Themes -Comment[af]=Bestuurder vir Spat Skerm Temas -Comment[ar]=مدير سمِات شاشة البداية -Comment[ast]=Xestor pa los temes de la pantalla splash -Comment[be]=Кіраўнік заставак загрузкі -Comment[be@latin]=Kiraŭnik zastavak -Comment[bg]=Управление изгледа на началния екран -Comment[bn]=স্প্ল্যাশ স্ক্রীণ থীম ম্যানেজার -Comment[br]=Merour evit gwiskadoù ar skramm degemer -Comment[bs]=Menadžer tema za uvodne ekrane -Comment[ca]=Gestor per als temes de la pantalla de presentació -Comment[ca@valencia]=Gestor per als temes de la pantalla d'inici -Comment[cs]=Správce motivů úvodních obrazovek -Comment[csb]=Menadżera témów ekranu na przëwitanié -Comment[cy]=Rheolydd Themau Sgriniau Croeso -Comment[da]=Håndtering for opstartskærme-temaer -Comment[de]=Verwaltung für Startbildschirmdesigns -Comment[el]=Διαχειριστής για θέματα αρχικής οθόνης -Comment[en_GB]=Manager for Splash Screen Themes -Comment[eo]=Administrilo por la salutŝildaj etosoj -Comment[es]=Gestor para los temas de la pantalla anunciadora -Comment[et]=Käivitusekraani teemade haldur -Comment[eu]=Harrerako pantailako gaien kudeatzailea -Comment[fa]=مدیر چهره‌های رنگ‌پاشی پرده -Comment[fi]=Tervetuloruudun asetukset -Comment[fy]=Temabehear foar begjinskerm -Comment[ga]=Bainisteoir Téamaí Splancscáileáin -Comment[gl]=Xestor dos temas da pantalla de benvida -Comment[gu]=સ્પ્લેશ સ્ક્રિન થીમો માટે વ્યવસ્થાપક -Comment[he]=מנהל ערכות־נושא למצג הפתיחה -Comment[hi]=स्प्लैश स्क्रीन प्रसंगों के लिए प्रबंधक -Comment[hne]=स्प्लैस स्क्रीन प्रसंग मन बर प्रबंधक -Comment[hr]=Upravitelj tema pozdravnih zaslona -Comment[hsb]=Rjadowar za powitanske temy -Comment[hu]=A nyitókép témájának beállítása -Comment[ia]=Gerente pro themas de schermo Splash -Comment[id]=Manajer untuk Tema Layar Splash -Comment[is]=Stjórna þemum upphafsskjáa -Comment[kk]=Бастау бейнеперде нақыштарының менеджері -Comment[km]=កម្មវិធី​គ្រប់គ្រង​ស្បែក​អេក្រង់​ស្វាគមន៍ -Comment[kn]=ಸ್ಪ್ಲಾಷ್ ತೆರೆ ಪರಿಸರವಿನ್ಯಾಸಗಳಿಗೆ (ಥೀಮ್) ವ್ಯವಸ್ಥಾಪಕ -Comment[ko]=시작 화면 테마 관리자 -Comment[ku]=Gerînendetiya Dirbên Splash Screenê -Comment[lt]=Pasveikinimo ekrano temų tvarkytuvė -Comment[lv]=Šļakstekrāna tēmu pārvaldnieks -Comment[mai]=स्प्लैश स्क्रीन प्रसंगसभ क' लेल प्रबंधक -Comment[mk]=Менаџер на теми за поздравни екрани -Comment[ml]=മുഖചിത്രത്തിനുള്ള ആശയങ്ങളുടെ കാര്യസ്ഥന്‍ -Comment[mr]=स्प्लॅश स्क्रीन शैली करिता व्यवस्थापक -Comment[ms]=Pengurus untuk Tema Splash Screen -Comment[nb]=Behandler for velkomstbildetemaer -Comment[nds]=Startschirmmuster instellen -Comment[ne]=स्प्लयास पर्दा विषयवस्तुका लागि प्रबन्धक -Comment[nl]=Themabeheer voor opstartschermen -Comment[nn]=Handsamar for velkomstbilete -Comment[pa]=ਸਵਾਗਤੀ ਸਕਰੀਨ ਥੀਮਾਂ ਲਈ ਮੈਨੇਜਰ -Comment[pl]=Zarządca wystrojów ekranu powitalnego -Comment[pt]=Gestor de Temas do Ecrã Inicial -Comment[pt_BR]=Gerencia os temas da tela de apresentação -Comment[ro]=Administrator pentru tematicile imaginii de pornire a KDE -Comment[ru]=Управление темами экрана-заставки -Comment[se]=Álgošearbmafáttáid gieđahalli -Comment[si]=ස්ප්ලෑෂ් තිර තේමා සඳහා කළමණාකරු -Comment[sk]=Správca tém pre úvodnú obrazovku -Comment[sl]=Upravljalnik tem pozdravnih oken -Comment[sr]=Менаџер тема за уводне екране -Comment[sr@ijekavian]=Менаџер тема за уводне екране -Comment[sr@ijekavianlatin]=Menadžer tema za uvodne ekrane -Comment[sr@latin]=Menadžer tema za uvodne ekrane -Comment[sv]=Hanterare för startskärmsteman -Comment[ta]=தோன்றும் திரை தலைப்புகளுக்கு மேலாளர் -Comment[te]=స్ప్లాష్ స్క్రీన్ థీమ్‍స్ కొరకు నిర్వాహకి -Comment[tg]=Мудири мавзӯъҳои пардаи экран -Comment[th]=เครื่องมือจัดการชุดตกแต่งของหน้าจอเริ่มการทำงาน -Comment[tr]=Açılış Ekran Teması Yöneticisi -Comment[ug]=مەرھابا ئېكران ئۆرنەك باشقۇرغۇچ -Comment[uk]=Керування темами вікон вітання -Comment[uz]=Splesh oynasi uchun mavzularni moslash -Comment[uz@cyrillic]=Сплэш ойнаси учун мавзуларни мослаш -Comment[vi]=Trình quản lý sắc thái cho màn hình chào mừng -Comment[wa]=Manaedjeu po les tinmes del waitroûle d' enondaedje -Comment[x-test]=xxManager for Splash Screen Themesxx -Comment[zh_CN]=欢迎屏幕主题管理器 -Comment[zh_TW]=啟動畫面佈景管理程式 -X-KDE-Keywords=splash screen,splash theme,startup -X-KDE-Keywords[bs]=čuvar zaslona,blijesak teme,pokretanje -X-KDE-Keywords[ca]=pantalla de presentació,tema de presentació,engegar -X-KDE-Keywords[ca@valencia]=pantalla de benvinguda,tema de benvinguda,engegar -X-KDE-Keywords[da]=opstartsbillede,opstartsskærm,splash,opstartstema,opstart -X-KDE-Keywords[de]=Startbildschirm,Design -X-KDE-Keywords[el]=οθόνης εκκίνησης,θέμα εκκίνησης,έναρξη -X-KDE-Keywords[en_GB]=splash screen,splash theme,startup -X-KDE-Keywords[es]=pantalla de bienvenida,tema de bienvenida,inicio -X-KDE-Keywords[et]=tiitelkuva,tiitelkuva teema,käivitamine -X-KDE-Keywords[eu]=harrerako pantaila,harrerako gaia,abioa -X-KDE-Keywords[fi]=aloitusruutu,aloitusteema,käynnistys,käynnistysruutu,käynnistysteema,tervetuloruutu,tervetuloikkuna,tervetuloteema -X-KDE-Keywords[fr]=écran de démarrage, thème de l'écran de démarrage, démarrage -X-KDE-Keywords[ga]=splancscáileán,splancthéama,tosú,tosach -X-KDE-Keywords[gl]=pantalla de benvida, tema de benvida, inicio -X-KDE-Keywords[hu]=indítóképernyő,indítótéma,indulás -X-KDE-Keywords[ia]=schermo splash,thema de splash,initio -X-KDE-Keywords[kk]=splash screen,splash theme,startup -X-KDE-Keywords[km]=អេក្រង់​ស្វាគមន៍ រូបរាង​ស្វាគមន៍ ចាប់ផ្ដើម -X-KDE-Keywords[ko]=splash screen,splash theme,startup,시작 화면,시작 테마,시작 -X-KDE-Keywords[mr]=स्प्लॅश स्क्रीन, स्प्लॅश शैली, सुरुवात -X-KDE-Keywords[nb]=velkomstbilde,velkomstbildetema,oppstart -X-KDE-Keywords[nds]=Startschirm,Startschirm-Muster,Hoochfohren -X-KDE-Keywords[nl]=splash-scherm,splash-thema,opstarten -X-KDE-Keywords[pa]=ਸਵਾਗਤੀ ਸਕਰੀਨ,ਸਪਲੈਸ਼ ਥੀਮ,ਸ਼ੁਰੂ,ਸ਼ੁਰੂਆਤ -X-KDE-Keywords[pl]=ekran powitalny,motyw ekranu powitalnego,uruchomienie -X-KDE-Keywords[pt]=ecrã inicial,tema inicial,arranque -X-KDE-Keywords[pt_BR]=tela inicial,tema inicial,inicialização -X-KDE-Keywords[ro]=ecran de întîmpinare,ecran de pornire,temă de întîmpinare,pornire -X-KDE-Keywords[ru]=splash screen,splash theme,startup,экранная заставка,тема заставки,запуск -X-KDE-Keywords[sk]=splash screen,splash theme,spustenie -X-KDE-Keywords[sl]=pozdravno okno,pozdravni zaslon,tema pozdravnega zaslona,zagon -X-KDE-Keywords[sr]=splash screen;splash theme;startup;уводни екран;уводна тема;покретање; -X-KDE-Keywords[sr@ijekavian]=splash screen;splash theme;startup;уводни екран;уводна тема;покретање; -X-KDE-Keywords[sr@ijekavianlatin]=splash screen;splash theme;startup;uvodni ekran;uvodna tema;pokretanje; -X-KDE-Keywords[sr@latin]=splash screen;splash theme;startup;uvodni ekran;uvodna tema;pokretanje; -X-KDE-Keywords[sv]=startskärm,starttema,start -X-KDE-Keywords[tr]=açılış ekranı,açılış ekranı teması,başlangıç,açılış,giriş -X-KDE-Keywords[uk]=splash screen,splash theme,startup,вікно,вітання,тема,запуск -X-KDE-Keywords[x-test]=xxsplash screen,splash theme,startupxx -X-KDE-Keywords[zh_CN]=splash screen,splash theme,startup,飞溅屏幕,启动画面,启动画面主题,飞溅屏幕主题,启动 -X-KDE-Keywords[zh_TW]=splash screen,splash theme,startup -Categories=Qt;KDE;X-KDE-settings-looknfeel; diff --git a/kcontrol/splash/main.cpp b/kcontrol/splash/main.cpp deleted file mode 100644 index 17db6e6c..00000000 --- a/kcontrol/splash/main.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/*************************************************************************** - * Copyright Ravikiran Rajagopal 2003 * - * ravi@ee.eng.ohio-state.edu * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License (version 2) as * - * published by the Free Software Foundation. * - * * - ***************************************************************************/ - -#include - -#include -#include -//Added by qt3to4: -#include - -#include -#include -#include -#include - -#include "installer.h" -#include -#include - -class KSplashThemeMgr : public KCModule -{ - Q_OBJECT -public: - KSplashThemeMgr( QWidget *parent, const QVariantList &/*unused*/); - ~KSplashThemeMgr(); - - QString quickHelp() const; - - virtual void init(); - virtual void save(); - virtual void load(); - virtual void defaults(); - -private: - SplashInstaller *mInstaller; -}; - -K_PLUGIN_FACTORY(KSplashThemeMgrFactory, - registerPlugin< KSplashThemeMgr>(); - ) -K_EXPORT_PLUGIN(KSplashThemeMgrFactory("ksplashthemes")) - -// ----------------------------------------------------------------------------------------- - -KSplashThemeMgr::KSplashThemeMgr( QWidget *parent, const QVariantList &args) - : KCModule( KSplashThemeMgrFactory::componentData(), parent, args ), mInstaller(new SplashInstaller(this)) -{ - init(); - -#if 0 - QHBoxLayout *box = new QHBoxLayout(this); - QTabWidget *tab = new QTabWidget(this); // There will be more tabs in the future. - box->addWidget(tab); - tab->addTab( mInstaller, i18n("&Theme Installer") ); -#else - QHBoxLayout *box = new QHBoxLayout(this); - box->setMargin(0); - box->addWidget(mInstaller); -#endif - connect( mInstaller, SIGNAL(changed(bool)), SIGNAL(changed(bool)) ); - KAboutData *about = new KAboutData( "kcmksplash" - , 0,ki18n("KDE splash screen theme manager") - ,"0.1" - ,KLocalizedString() - ,KAboutData::License_GPL - ,ki18n("(c) 2003 KDE developers") ); - about->addAuthor(ki18n("Ravikiran Rajagopal"), KLocalizedString(), "ravi@ee.eng.ohio-state.edu"); - about->addCredit(ki18n("Brian Ledbetter"), ki18n("Original KSplash/ML author"), "brian@shadowcom.net"); - about->addCredit(ki18n("KDE Theme Manager authors" ), ki18n("Original installer code") ); - // Once string freeze is over, replace second argument with "Icon" - about->addCredit(ki18n("Hans Karlsson"), KLocalizedString(), "karlsson.h@home.se" ); - setAboutData(about); - //setButtons( KCModule::Default|KCModule::Apply ); -} - -KSplashThemeMgr::~KSplashThemeMgr() -{ - // Do not delete the installer as it is now owned by the tab widget. -} - -QString KSplashThemeMgr::quickHelp() const -{ - return i18n("

Splash Screen Theme Manager

Install and view splash screen themes."); -} - -void KSplashThemeMgr::init() -{ - KGlobal::dirs()->addResourceType("ksplashthemes", "data", "ksplash/Themes"); -} - -void KSplashThemeMgr::save() -{ - mInstaller->save(); -} - -void KSplashThemeMgr::load() -{ - mInstaller->load(); -} - -void KSplashThemeMgr::defaults() -{ - mInstaller->defaults(); -} - -#include "main.moc" diff --git a/kcontrol/splash/pics/CMakeLists.txt b/kcontrol/splash/pics/CMakeLists.txt deleted file mode 100644 index bd4b9119..00000000 --- a/kcontrol/splash/pics/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -kde4_install_icons( ${KDE4_ICON_INSTALL_DIR} ) diff --git a/kcontrol/splash/pics/hi128-app-ksplash.png b/kcontrol/splash/pics/hi128-app-ksplash.png deleted file mode 100644 index e6b72a81..00000000 Binary files a/kcontrol/splash/pics/hi128-app-ksplash.png and /dev/null differ diff --git a/kcontrol/splash/pics/hi16-app-ksplash.png b/kcontrol/splash/pics/hi16-app-ksplash.png deleted file mode 100644 index 1d563edb..00000000 Binary files a/kcontrol/splash/pics/hi16-app-ksplash.png and /dev/null differ diff --git a/kcontrol/splash/pics/hi22-app-ksplash.png b/kcontrol/splash/pics/hi22-app-ksplash.png deleted file mode 100644 index 2744d833..00000000 Binary files a/kcontrol/splash/pics/hi22-app-ksplash.png and /dev/null differ diff --git a/kcontrol/splash/pics/hi32-app-ksplash.png b/kcontrol/splash/pics/hi32-app-ksplash.png deleted file mode 100644 index f1873279..00000000 Binary files a/kcontrol/splash/pics/hi32-app-ksplash.png and /dev/null differ diff --git a/kcontrol/splash/pics/hi48-app-ksplash.png b/kcontrol/splash/pics/hi48-app-ksplash.png deleted file mode 100644 index a56bcbb3..00000000 Binary files a/kcontrol/splash/pics/hi48-app-ksplash.png and /dev/null differ diff --git a/kcontrol/splash/pics/hi64-app-ksplash.png b/kcontrol/splash/pics/hi64-app-ksplash.png deleted file mode 100644 index 3496e056..00000000 Binary files a/kcontrol/splash/pics/hi64-app-ksplash.png and /dev/null differ diff --git a/ksmserver/README b/ksmserver/README index 647e9af5..e744786b 100644 --- a/ksmserver/README +++ b/ksmserver/README @@ -68,9 +68,7 @@ Startkde also launches kcminit, which performs initialization done by kcontrol modules. There are three kcminit phases, 0, 1 and 2, controlled by X-KDE-Init-Phase= in the .desktop file, which defaults to 1. Phase 0 kcminit modules should be only those that really need to be run early in the startup -process (and those should probably actually use kstartupconfig in startkde -to be done even before kdeinit and daemons). After executing phase 0 -modules kcminit returns and waits. +process. After executing phase 0 modules kcminit returns and waits. When ksmserver is launched, the first thing it does is launching the window manager, as the WM is necessary before any windows are possibly diff --git a/ksmserver/server.h b/ksmserver/server.h index 91d0acf7..808fbe16 100644 --- a/ksmserver/server.h +++ b/ksmserver/server.h @@ -252,9 +252,6 @@ private: KWorkSpace::ShutdownType pendingShutdown_sdtype; KWorkSpace::ShutdownMode pendingShutdown_sdmode; - // ksplash interface - void upAndRunning( const QString& msg ); - // sequential startup int appsToStart; int lastAppStarted; diff --git a/ksmserver/startup.cpp b/ksmserver/startup.cpp index 30fd234f..13a4bf0d 100644 --- a/ksmserver/startup.cpp +++ b/ksmserver/startup.cpp @@ -98,7 +98,6 @@ void KSMServer::restoreSession( const QString &sessionName ) int count = configSessionGroup.readEntry( "count", 0 ); appsToStart = count; - upAndRunning( "ksmserver" ); connect( klauncherSignals, SIGNAL(autoStart0Done()), SLOT(autoStart0Done())); connect( klauncherSignals, SIGNAL(autoStart1Done()), SLOT(autoStart1Done())); connect( klauncherSignals, SIGNAL(autoStart2Done()), SLOT(autoStart2Done())); @@ -133,7 +132,6 @@ void KSMServer::startDefaultSession() t.start(); #endif sessionGroup = ""; - upAndRunning( "ksmserver" ); connect( klauncherSignals, SIGNAL(autoStart0Done()), SLOT(autoStart0Done())); connect( klauncherSignals, SIGNAL(autoStart1Done()), SLOT(autoStart1Done())); connect( klauncherSignals, SIGNAL(autoStart2Done()), SLOT(autoStart2Done())); @@ -231,7 +229,6 @@ void KSMServer::autoStart0Done() #ifdef KSMSERVER_STARTUP_DEBUG1 kDebug() << t.elapsed(); #endif - upAndRunning( "desktop" ); state = KcmInitPhase1; kcminitSignals = new QDBusInterface("org.kde.kcminit", "/kcminit", "org.kde.KCMInit", QDBusConnection::sessionBus(), this ); if( !kcminitSignals->isValid()) { @@ -465,7 +462,6 @@ void KSMServer::finishStartup() if( waitAutoStart2 || waitKcmInit2 ) return; - upAndRunning( "ready" ); #ifdef KSMSERVER_STARTUP_DEBUG1 kDebug() << t.elapsed(); #endif @@ -535,19 +531,6 @@ void KSMServer::resumeStartupInternal() } } -void KSMServer::upAndRunning( const QString& msg ) -{ - XEvent e; - e.xclient.type = ClientMessage; - e.xclient.message_type = XInternAtom( QX11Info::display(), "_KDE_SPLASH_PROGRESS", False ); - e.xclient.display = QX11Info::display(); - e.xclient.window = QX11Info::appRootWindow(); - e.xclient.format = 8; - assert( strlen( msg.toLatin1()) < 20 ); - strcpy( e.xclient.data.b, msg.toLatin1()); - XSendEvent( QX11Info::display(), QX11Info::appRootWindow(), False, SubstructureNotifyMask, &e ); -} - void KSMServer::restoreSubSession( const QString& name ) { sessionGroup = "SubSession: " + name; diff --git a/ksplash/CMakeLists.txt b/ksplash/CMakeLists.txt deleted file mode 100644 index 0cfd57a6..00000000 --- a/ksplash/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -add_subdirectory( ksplashx ) -add_subdirectory( elarun ) -add_subdirectory( none ) -add_subdirectory( ksplashqml ) -add_subdirectory( default ) diff --git a/ksplash/README b/ksplash/README deleted file mode 100644 index 540827a6..00000000 --- a/ksplash/README +++ /dev/null @@ -1,61 +0,0 @@ -KDE Splash: -=========== - -The 'kcm' directory contains the control module for configuring the splashscreen. -Other directories contain various splash implementations: - -- 'none' is no splashscreen -- 'simple' is a very simple and fast splashscreen showing a plain progressbar -- 'ksplashx' is a more capable implementation. See its README. - -(the KDE3 implementation 'ksplashml' has been removed to /tags/unmaintained) - - -Theme format: -============= - -This is a description of what is shared between the implementations (as needed -by the configuration module and startkde code deciding which implementation to use). -Implementations may have their own additions. - -Themes are stored in $KDEDIRS/share/apps/ksplash/Themes/ in a directory specifying -the name of the theme. The directory must contain file 'Theme.rc' describing -the theme and should contain file 'Preview.png' with a preview image. Other contents -are implementation-dependent. - - -Theme.rc format: -================ - -The format is the usual ini-style format, e.g.: - -[KSplash Theme: Simple] -Name = Simple Splash Screen -Description = Very Simple Optimized Splash Screen -Version = 1.0 -Author = Lubos Lunak -Engine = Simple - -The group name is [KSplash Theme: ]. Name, Description, Version and Author -are shown in the configuration module. Engine selects which splash implementation -the theme is for (currently 'None', 'Simple' and 'KSplashX' ). There may be futher -implementation-dependent data in Theme.rc . - - -Startup states: -=============== - -These are ksplash states: -- initial - at the beginning -- kded - after kded is running (dbus is ready, etc.) -- kcminit - after configuration setup -- ksmserver - session manager is started -- wm - window manager is running -- desktop - desktop (plasma) is running -- ready - session is ready (not fully actually, still e.g. restoring applications, but splash goes away) - -Note however that these states should not be relied on too much: -- they do not represent very accurately what is actually going on -- states may be removed (they'll take 0 time and directly go to another state) -- states may be added -- states may be reordered (waiting for a later state and then a sooner state means the sooner state will take 0 time) diff --git a/ksplash/default/1024x768/background.png b/ksplash/default/1024x768/background.png deleted file mode 100644 index af603641..00000000 Binary files a/ksplash/default/1024x768/background.png and /dev/null differ diff --git a/ksplash/default/1280x1024/background.png b/ksplash/default/1280x1024/background.png deleted file mode 100644 index 24b2184c..00000000 Binary files a/ksplash/default/1280x1024/background.png and /dev/null differ diff --git a/ksplash/default/1600x1200/background.png b/ksplash/default/1600x1200/background.png deleted file mode 100644 index 08482024..00000000 Binary files a/ksplash/default/1600x1200/background.png and /dev/null differ diff --git a/ksplash/default/1600x1200/description.txt b/ksplash/default/1600x1200/description.txt deleted file mode 100644 index 7904dbca..00000000 --- a/ksplash/default/1600x1200/description.txt +++ /dev/null @@ -1,42 +0,0 @@ -SCALE ON -BACKGROUND_IMAGE 0 0 background.png -SCALE OFF - -# the image is 390x234, make it centered, all icons need the same adjustment too -IMAGE_REL CC 0 0 CC rectangle.png - -# these have their relative positions to the rectangle adjusted by -195,-117 -# (i.e. half of the rectangle size) -# 3,32 -ANIM_REL 1 CC -192 -50 LT 30 icon1_anim.png 85 1 -WAIT_STATE kded - -# 69,32 -ANIM_REL 2 CC -126 -50 LT 30 icon2_anim.png 85 1 -WAIT_STATE kcminit - -# 135,32 -ANIM_REL 3 CC -60 -50 LT 29 icon3_anim.png 85 1 -WAIT_STATE ksmserver - -# 201,32 -ANIM_REL 4 CC 6 -50 LT 30 icon4_anim.png 85 1 -WAIT_STATE wm - -# 263,15 -ANIM_REL 5 CC 68 -88 LT 30 icon5_anim.png 85 1 -WAIT_STATE desktop - -WAIT_STATE ready - -# show the icons fully right before the splash goes away -STOP_ANIM 1 -IMAGE_REL CC -192 -50 LT icon1.png -STOP_ANIM 2 -IMAGE_REL CC -126 -50 LT icon2.png -STOP_ANIM 3 -IMAGE_REL CC -60 -50 LT icon3.png -STOP_ANIM 4 -IMAGE_REL CC 6 -50 LT icon4.png -STOP_ANIM 5 -IMAGE_REL CC 68 -88 LT icon5.png diff --git a/ksplash/default/1600x1200/icon1.png b/ksplash/default/1600x1200/icon1.png deleted file mode 100644 index d75322f0..00000000 Binary files a/ksplash/default/1600x1200/icon1.png and /dev/null differ diff --git a/ksplash/default/1600x1200/icon1_anim.png b/ksplash/default/1600x1200/icon1_anim.png deleted file mode 100644 index 6613ede2..00000000 Binary files a/ksplash/default/1600x1200/icon1_anim.png and /dev/null differ diff --git a/ksplash/default/1600x1200/icon2.png b/ksplash/default/1600x1200/icon2.png deleted file mode 100644 index 99491f35..00000000 Binary files a/ksplash/default/1600x1200/icon2.png and /dev/null differ diff --git a/ksplash/default/1600x1200/icon2_anim.png b/ksplash/default/1600x1200/icon2_anim.png deleted file mode 100644 index 904e9ffc..00000000 Binary files a/ksplash/default/1600x1200/icon2_anim.png and /dev/null differ diff --git a/ksplash/default/1600x1200/icon3.png b/ksplash/default/1600x1200/icon3.png deleted file mode 100644 index 3e5e2c0d..00000000 Binary files a/ksplash/default/1600x1200/icon3.png and /dev/null differ diff --git a/ksplash/default/1600x1200/icon3_anim.png b/ksplash/default/1600x1200/icon3_anim.png deleted file mode 100644 index 20e76476..00000000 Binary files a/ksplash/default/1600x1200/icon3_anim.png and /dev/null differ diff --git a/ksplash/default/1600x1200/icon4.png b/ksplash/default/1600x1200/icon4.png deleted file mode 100644 index 1c298a54..00000000 Binary files a/ksplash/default/1600x1200/icon4.png and /dev/null differ diff --git a/ksplash/default/1600x1200/icon4_anim.png b/ksplash/default/1600x1200/icon4_anim.png deleted file mode 100644 index d263f8d0..00000000 Binary files a/ksplash/default/1600x1200/icon4_anim.png and /dev/null differ diff --git a/ksplash/default/1600x1200/icon5.png b/ksplash/default/1600x1200/icon5.png deleted file mode 100644 index e839e949..00000000 Binary files a/ksplash/default/1600x1200/icon5.png and /dev/null differ diff --git a/ksplash/default/1600x1200/icon5_anim.png b/ksplash/default/1600x1200/icon5_anim.png deleted file mode 100644 index 3ca35faa..00000000 Binary files a/ksplash/default/1600x1200/icon5_anim.png and /dev/null differ diff --git a/ksplash/default/1600x1200/rectangle.png b/ksplash/default/1600x1200/rectangle.png deleted file mode 100644 index 626045d4..00000000 Binary files a/ksplash/default/1600x1200/rectangle.png and /dev/null differ diff --git a/ksplash/default/1920x1080/background.png b/ksplash/default/1920x1080/background.png deleted file mode 100644 index 1e538386..00000000 Binary files a/ksplash/default/1920x1080/background.png and /dev/null differ diff --git a/ksplash/default/1920x1200/background.png b/ksplash/default/1920x1200/background.png deleted file mode 100644 index af59f28b..00000000 Binary files a/ksplash/default/1920x1200/background.png and /dev/null differ diff --git a/ksplash/default/800x600/background.png b/ksplash/default/800x600/background.png deleted file mode 100644 index 30442037..00000000 Binary files a/ksplash/default/800x600/background.png and /dev/null differ diff --git a/ksplash/default/CMakeLists.txt b/ksplash/default/CMakeLists.txt deleted file mode 100644 index 6f00e3ec..00000000 --- a/ksplash/default/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -install( FILES Preview.png Theme.rc DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Default ) -install( FILES 1600x1200/description.txt 1600x1200/background.png 1600x1200/rectangle.png - 1600x1200/icon1.png 1600x1200/icon2.png 1600x1200/icon3.png - 1600x1200/icon4.png 1600x1200/icon5.png - 1600x1200/icon1_anim.png 1600x1200/icon2_anim.png 1600x1200/icon3_anim.png - 1600x1200/icon4_anim.png 1600x1200/icon5_anim.png - DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Default/1600x1200 ) -install( FILES 1024x768/background.png DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Default/1024x768 ) -install( FILES 1280x1024/background.png DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Default/1280x1024 ) -install( FILES 1920x1080/background.png DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Default/1920x1080 ) -install( FILES 1920x1200/background.png DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Default/1920x1200 ) -install( FILES 800x600/background.png DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Default/800x600 ) diff --git a/ksplash/default/Preview.png b/ksplash/default/Preview.png deleted file mode 100644 index 76da7ffb..00000000 Binary files a/ksplash/default/Preview.png and /dev/null differ diff --git a/ksplash/default/Theme.rc b/ksplash/default/Theme.rc deleted file mode 100644 index 71738547..00000000 --- a/ksplash/default/Theme.rc +++ /dev/null @@ -1,9 +0,0 @@ -[KSplash Theme: Default] -Name = Default Splash Screen -Description = Ariya Splash Screen -Version = 1.0 -Author = Ivailo Monev -Homepage = http://www.kde.org - -# Theme behaviour settings. -Engine = KSplashX diff --git a/ksplash/elarun/1024x768/background.png b/ksplash/elarun/1024x768/background.png deleted file mode 100644 index 9e4df901..00000000 Binary files a/ksplash/elarun/1024x768/background.png and /dev/null differ diff --git a/ksplash/elarun/1280x1024/background.png b/ksplash/elarun/1280x1024/background.png deleted file mode 100644 index eaf5cc5b..00000000 Binary files a/ksplash/elarun/1280x1024/background.png and /dev/null differ diff --git a/ksplash/elarun/1600x1200/background.png b/ksplash/elarun/1600x1200/background.png deleted file mode 100644 index 4ff3ebac..00000000 Binary files a/ksplash/elarun/1600x1200/background.png and /dev/null differ diff --git a/ksplash/elarun/1600x1200/description.txt b/ksplash/elarun/1600x1200/description.txt deleted file mode 100644 index 7904dbca..00000000 --- a/ksplash/elarun/1600x1200/description.txt +++ /dev/null @@ -1,42 +0,0 @@ -SCALE ON -BACKGROUND_IMAGE 0 0 background.png -SCALE OFF - -# the image is 390x234, make it centered, all icons need the same adjustment too -IMAGE_REL CC 0 0 CC rectangle.png - -# these have their relative positions to the rectangle adjusted by -195,-117 -# (i.e. half of the rectangle size) -# 3,32 -ANIM_REL 1 CC -192 -50 LT 30 icon1_anim.png 85 1 -WAIT_STATE kded - -# 69,32 -ANIM_REL 2 CC -126 -50 LT 30 icon2_anim.png 85 1 -WAIT_STATE kcminit - -# 135,32 -ANIM_REL 3 CC -60 -50 LT 29 icon3_anim.png 85 1 -WAIT_STATE ksmserver - -# 201,32 -ANIM_REL 4 CC 6 -50 LT 30 icon4_anim.png 85 1 -WAIT_STATE wm - -# 263,15 -ANIM_REL 5 CC 68 -88 LT 30 icon5_anim.png 85 1 -WAIT_STATE desktop - -WAIT_STATE ready - -# show the icons fully right before the splash goes away -STOP_ANIM 1 -IMAGE_REL CC -192 -50 LT icon1.png -STOP_ANIM 2 -IMAGE_REL CC -126 -50 LT icon2.png -STOP_ANIM 3 -IMAGE_REL CC -60 -50 LT icon3.png -STOP_ANIM 4 -IMAGE_REL CC 6 -50 LT icon4.png -STOP_ANIM 5 -IMAGE_REL CC 68 -88 LT icon5.png diff --git a/ksplash/elarun/1600x1200/icon1.png b/ksplash/elarun/1600x1200/icon1.png deleted file mode 100644 index d75322f0..00000000 Binary files a/ksplash/elarun/1600x1200/icon1.png and /dev/null differ diff --git a/ksplash/elarun/1600x1200/icon1_anim.png b/ksplash/elarun/1600x1200/icon1_anim.png deleted file mode 100644 index 6613ede2..00000000 Binary files a/ksplash/elarun/1600x1200/icon1_anim.png and /dev/null differ diff --git a/ksplash/elarun/1600x1200/icon2.png b/ksplash/elarun/1600x1200/icon2.png deleted file mode 100644 index 99491f35..00000000 Binary files a/ksplash/elarun/1600x1200/icon2.png and /dev/null differ diff --git a/ksplash/elarun/1600x1200/icon2_anim.png b/ksplash/elarun/1600x1200/icon2_anim.png deleted file mode 100644 index 904e9ffc..00000000 Binary files a/ksplash/elarun/1600x1200/icon2_anim.png and /dev/null differ diff --git a/ksplash/elarun/1600x1200/icon3.png b/ksplash/elarun/1600x1200/icon3.png deleted file mode 100644 index 3e5e2c0d..00000000 Binary files a/ksplash/elarun/1600x1200/icon3.png and /dev/null differ diff --git a/ksplash/elarun/1600x1200/icon3_anim.png b/ksplash/elarun/1600x1200/icon3_anim.png deleted file mode 100644 index 20e76476..00000000 Binary files a/ksplash/elarun/1600x1200/icon3_anim.png and /dev/null differ diff --git a/ksplash/elarun/1600x1200/icon4.png b/ksplash/elarun/1600x1200/icon4.png deleted file mode 100644 index 1c298a54..00000000 Binary files a/ksplash/elarun/1600x1200/icon4.png and /dev/null differ diff --git a/ksplash/elarun/1600x1200/icon4_anim.png b/ksplash/elarun/1600x1200/icon4_anim.png deleted file mode 100644 index d263f8d0..00000000 Binary files a/ksplash/elarun/1600x1200/icon4_anim.png and /dev/null differ diff --git a/ksplash/elarun/1600x1200/icon5.png b/ksplash/elarun/1600x1200/icon5.png deleted file mode 100644 index e839e949..00000000 Binary files a/ksplash/elarun/1600x1200/icon5.png and /dev/null differ diff --git a/ksplash/elarun/1600x1200/icon5_anim.png b/ksplash/elarun/1600x1200/icon5_anim.png deleted file mode 100644 index 3ca35faa..00000000 Binary files a/ksplash/elarun/1600x1200/icon5_anim.png and /dev/null differ diff --git a/ksplash/elarun/1600x1200/rectangle.png b/ksplash/elarun/1600x1200/rectangle.png deleted file mode 100644 index 626045d4..00000000 Binary files a/ksplash/elarun/1600x1200/rectangle.png and /dev/null differ diff --git a/ksplash/elarun/1920x1080/background.png b/ksplash/elarun/1920x1080/background.png deleted file mode 100644 index 47618b02..00000000 Binary files a/ksplash/elarun/1920x1080/background.png and /dev/null differ diff --git a/ksplash/elarun/1920x1200/background.png b/ksplash/elarun/1920x1200/background.png deleted file mode 100644 index 757c78a5..00000000 Binary files a/ksplash/elarun/1920x1200/background.png and /dev/null differ diff --git a/ksplash/elarun/600x400/background.png b/ksplash/elarun/600x400/background.png deleted file mode 100644 index 771da663..00000000 Binary files a/ksplash/elarun/600x400/background.png and /dev/null differ diff --git a/ksplash/elarun/800x600/background.png b/ksplash/elarun/800x600/background.png deleted file mode 100644 index c1388213..00000000 Binary files a/ksplash/elarun/800x600/background.png and /dev/null differ diff --git a/ksplash/elarun/CMakeLists.txt b/ksplash/elarun/CMakeLists.txt deleted file mode 100644 index 34770ff4..00000000 --- a/ksplash/elarun/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -install( FILES Preview.png Theme.rc DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Elarun ) -install( FILES 1600x1200/description.txt 1600x1200/background.png 1600x1200/rectangle.png - 1600x1200/icon1.png 1600x1200/icon2.png 1600x1200/icon3.png - 1600x1200/icon4.png 1600x1200/icon5.png - 1600x1200/icon1_anim.png 1600x1200/icon2_anim.png 1600x1200/icon3_anim.png - 1600x1200/icon4_anim.png 1600x1200/icon5_anim.png - DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Elarun/1600x1200 ) -install( FILES 1024x768/background.png DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Elarun/1024x768 ) -install( FILES 1280x1024/background.png DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Elarun/1280x1024 ) -install( FILES 1920x1080/background.png DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Elarun/1920x1080 ) -install( FILES 1920x1200/background.png DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Elarun/1920x1200 ) -install( FILES 600x400/background.png DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Elarun/600x400 ) -install( FILES 800x600/background.png DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Elarun/800x600 ) diff --git a/ksplash/elarun/Preview.png b/ksplash/elarun/Preview.png deleted file mode 100644 index 1bdce956..00000000 Binary files a/ksplash/elarun/Preview.png and /dev/null differ diff --git a/ksplash/elarun/Theme.rc b/ksplash/elarun/Theme.rc deleted file mode 100644 index 403ae487..00000000 --- a/ksplash/elarun/Theme.rc +++ /dev/null @@ -1,9 +0,0 @@ -[KSplash Theme: Elarun] -Name = Elarun Splash Screen -Description = Air and Elarun Splash Screen -Version = 1.0 -Author = Nuno Pinheiro , Riccardo Iaconelli and Marco Martin -Homepage = http://www.kde.org - -# Theme behaviour settings. -Engine = KSplashX diff --git a/ksplash/ksplashqml/CMakeLists.txt b/ksplash/ksplashqml/CMakeLists.txt deleted file mode 100644 index c2065d9d..00000000 --- a/ksplash/ksplashqml/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -project(ksplashqml) - -add_subdirectory(themes) - -set(ksplashqml_SRCS - main.cpp - SplashApp.cpp - SplashWindow.cpp - ) - -add_executable(ksplashqml ${ksplashqml_SRCS}) - -target_link_libraries(ksplashqml - ${X11_LIBRARIES} - ${QT_QTCORE_LIBRARY} - ${QT_QTDECLARATIVE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ) - -install(TARGETS ksplashqml ${INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/ksplash/ksplashqml/SplashApp.cpp b/ksplash/ksplashqml/SplashApp.cpp deleted file mode 100644 index fc6f9eca..00000000 --- a/ksplash/ksplashqml/SplashApp.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (C) 2010 Ivan Cukic - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * or (at your option) any later version, as published by the Free - * Software Foundation - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "SplashWindow.h" -#include "SplashApp.h" - -#include -#include -#include - -#define TEST_STEP_INTERVAL 2000 - -SplashApp::SplashApp(Display * display, int &argc, char ** argv) - : QApplication(display, argc, argv), - m_display(display), m_stage(0), - m_testing(false) -{ - m_kde_splash_progress = XInternAtom(m_display, "_KDE_SPLASH_PROGRESS", False); - m_testing = arguments().contains("--test"); - - m_desktop = QApplication::desktop(); - screenGeometryChanged(m_desktop->screenCount()); - - setStage(1); - - - QPixmap cursor(32, 32); - cursor.fill(QColor(0, 0, 0, 0)); - setOverrideCursor(QCursor(cursor)); - - - XSelectInput(display, DefaultRootWindow(display), SubstructureNotifyMask); - - if (m_testing) { - m_timer.start(TEST_STEP_INTERVAL, this); - } - - connect(m_desktop, SIGNAL(screenCountChanged(int)), this, SLOT(screenGeometryChanged(int))); - connect(m_desktop, SIGNAL(workAreaResized(int)), this, SLOT(screenGeometryChanged(int))); -} - -SplashApp::~SplashApp() -{ - qDeleteAll(m_windows); -} - -Display * SplashApp::display() const -{ - return m_display; -} - -void SplashApp::timerEvent(QTimerEvent * event) -{ - if (event->timerId() == m_timer.timerId()) { - m_timer.stop(); - - setStage(m_stage + 1); - - m_timer.start(TEST_STEP_INTERVAL, this); - } -} - -bool SplashApp::x11EventFilter(XEvent * xe) -{ - switch (xe->type) { - case ClientMessage: - if (xe->xclient.message_type == m_kde_splash_progress) { - char * message = xe->xclient.data.b; - - int stage = -1; - - if (strcmp(message, "initial") == 0 && m_stage < 0) - stage = 0; // not actually used - else if (strcmp(message, "kded") == 0 && m_stage < 1) - stage = 1; - else if (strcmp(message, "kcminit") == 0 && m_stage < 2) - stage = 2; - else if (strcmp(message, "ksmserver") == 0 && m_stage < 3) - stage = 3; - else if (strcmp(message, "wm") == 0 && m_stage < 4) - stage = 4; - else if (strcmp(message, "desktop") == 0 && m_stage < 5) - stage = 5; - - setStage(stage); - } - } - return false; - -} - -int SplashApp::x11ProcessEvent(XEvent * xe) -{ - Q_UNUSED(xe) - return 0; -} - -void SplashApp::setStage(int stage) -{ - if (m_stage == 6) { - QApplication::exit(EXIT_SUCCESS); - } - - m_stage = stage; - foreach (SplashWindow *w, m_windows) { - w->setStage(stage); - } -} - -void SplashApp::screenGeometryChanged(int) -{ - int i; - // first iterate over all the new and old ones to set sizes appropriately - for (i = 0; i < m_desktop->screenCount(); i++) { - if (i < m_windows.count()) { - m_windows[i]->setGeometry(m_desktop->availableGeometry(i)); - } - else { - SplashWindow *w = new SplashWindow(m_testing); - // When running into a view error at this point it means that the - // theme file could not be loaded. We want to exit as otherwise we - // are exposed to nullptr crashes. - if (w->status() == QDeclarativeView::Error) { - ::exit(2); - } - w->setGeometry(m_desktop->availableGeometry(i)); - w->setStage(m_stage); - w->show(); - m_windows << w; - } - } - // then delete the rest, if there is any - m_windows.erase(m_windows.begin() + i, m_windows.end()); -} - -#include "moc_SplashApp.cpp" diff --git a/ksplash/ksplashqml/SplashApp.h b/ksplash/ksplashqml/SplashApp.h deleted file mode 100644 index 3c55be9c..00000000 --- a/ksplash/ksplashqml/SplashApp.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2010 Ivan Cukic - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * or (at your option) any later version, as published by the Free - * Software Foundation - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef SPLASH_APP_H_ -#define SPLASH_APP_H_ - -#include -#include -#include - -#include - -class SplashWindow; - -class SplashApp: public QApplication { - Q_OBJECT - -public: - explicit SplashApp(Display * display, int &argc, char ** argv); - virtual ~SplashApp(); - - Display * display() const; - - bool x11EventFilter(XEvent * xe); - int x11ProcessEvent(XEvent * xe); - -protected: - void timerEvent(QTimerEvent * event); - void setStage(int stage); - -private: - Display * m_display; - int m_stage; - Atom m_kde_splash_progress; - QList m_windows; - bool m_testing; - QBasicTimer m_timer; - QDesktopWidget *m_desktop; - -private slots: - void screenGeometryChanged(int newCount); -}; - -#endif // SPLASH_APP_H_ diff --git a/ksplash/ksplashqml/SplashWindow.cpp b/ksplash/ksplashqml/SplashWindow.cpp deleted file mode 100644 index be833af3..00000000 --- a/ksplash/ksplashqml/SplashWindow.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2010 Ivan Cukic - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * or (at your option) any later version, as published by the Free - * Software Foundation - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "SplashWindow.h" - -#include -#include -#include -#include -#include -#include - -#include "SystemInfo.h" - -SplashWindow::SplashWindow(bool testing) - : QDeclarativeView(), - m_stage(0), - m_testing(testing) -{ - setWindowFlags( - Qt::FramelessWindowHint | - Qt::WindowStaysOnTopHint - ); - - if (m_testing) { - setWindowState(Qt::WindowFullScreen); - } else { - setWindowFlags(Qt::X11BypassWindowManagerHint); - } - - rootContext()->setContextProperty("screenSize", size()); - setSource(QUrl(themeDir(QApplication::arguments().at(1)) + "/main.qml")); - setStyleSheet("background: #000000; border: none"); - setAttribute(Qt::WA_OpaquePaintEvent); - setAttribute(Qt::WA_NoSystemBackground); - //be sure it will be eventually closed - //FIXME: should never be stuck - QTimer::singleShot(30000, this, SLOT(close())); -} - -void SplashWindow::setStage(int stage) -{ - m_stage = stage; - - rootObject()->setProperty("stage", stage); -} - -void SplashWindow::resizeEvent(QResizeEvent *event) -{ - Q_UNUSED(event) - rootContext()->setContextProperty("screenSize", size()); - centerOn(rootObject()); -} - -void SplashWindow::keyPressEvent(QKeyEvent *event) -{ - QDeclarativeView::keyPressEvent(event); - if (m_testing && !event->isAccepted() && event->key() == Qt::Key_Escape) { - close(); - } -} - -void SplashWindow::mousePressEvent(QMouseEvent *event) -{ - QDeclarativeView::mousePressEvent(event); - if (m_testing && !event->isAccepted()) { - close(); - } -} diff --git a/ksplash/ksplashqml/SplashWindow.h b/ksplash/ksplashqml/SplashWindow.h deleted file mode 100644 index e786f067..00000000 --- a/ksplash/ksplashqml/SplashWindow.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2010 Ivan Cukic - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * or (at your option) any later version, as published by the Free - * Software Foundation - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef SPLASH_WINDOW_H_ -#define SPLASH_WINDOW_H_ - -#include - -#include -#include -#include - -class SplashWindow: public QDeclarativeView -{ -public: - SplashWindow(bool testing); - - void setStage(int stage); - -protected: - virtual void resizeEvent (QResizeEvent *event); - virtual void keyPressEvent(QKeyEvent *event); - virtual void mousePressEvent(QMouseEvent *event); - -private: - int m_stage; - bool m_testing; -}; - -#endif // SPLASH_WINDOW_H_ diff --git a/ksplash/ksplashqml/SystemInfo.h b/ksplash/ksplashqml/SystemInfo.h deleted file mode 100644 index 7a74554d..00000000 --- a/ksplash/ksplashqml/SystemInfo.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2010 Ivan Cukic - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * or (at your option) any later version, as published by the Free - * Software Foundation - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef SYSTEM_INFO_H_ -#define SYSTEM_INFO_H_ - -#include -#include - -#include -#include - -QString homeDir() -{ - const char * kdehome = getenv("KDEHOME"); - const char * home = getenv("HOME"); - if (!kdehome || !kdehome[0]) { - return QString() + home + "/" + KDE_DEFAULT_HOME; - } - - return kdehome; -} - -QString systemDir() -{ - return KDE_DATADIR; -} - -QString themeDir(QString theme) -{ - QString path; - - path = homeDir() + "/share/apps/ksplash/Themes/" + theme; - - if (!QDir(path).exists()) { - path = systemDir() + "/ksplash/Themes/" + theme; - } - - return path; -} - -#endif // SYSTEM_INFO_H_ - - diff --git a/ksplash/ksplashqml/main.cpp b/ksplash/ksplashqml/main.cpp deleted file mode 100644 index c2722ab9..00000000 --- a/ksplash/ksplashqml/main.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2011 Ivan Cukic - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * or (at your option) any later version, as published by the Free - * Software Foundation - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "SplashApp.h" - -#include -#include -#include -#include - -int main(int argc, char **argv) -{ - bool test = false; - bool printPid = false; - - for (int i = 1; i < argc; i++) { - if (strcmp("--test", argv[i]) == 0) - test = true; - else if (strcmp("--pid", argv[i]) == 0) - printPid = true; - } - - // lets fork and all that... - - if (!test) { - pid_t pid = fork(); - if (pid < -1) { - return -1; - } - - if (pid != 0) { - // this is the parent process, returning pid of the fork - if (printPid) { - std::cout << pid << std::endl; - } - - return 0; - } - - // close stdin,stdout,stderr, otherwise startkde will block - close(0); - close(1); - close(2); - } - - Display * display = XOpenDisplay(NULL); - - SplashApp app(display, argc, argv); - - return app.exec(); -} - diff --git a/ksplash/ksplashqml/themes/CMakeLists.txt b/ksplash/ksplashqml/themes/CMakeLists.txt deleted file mode 100644 index c5ab367d..00000000 --- a/ksplash/ksplashqml/themes/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(Minimalistic) diff --git a/ksplash/ksplashqml/themes/Minimalistic/CMakeLists.txt b/ksplash/ksplashqml/themes/Minimalistic/CMakeLists.txt deleted file mode 100644 index b91931c8..00000000 --- a/ksplash/ksplashqml/themes/Minimalistic/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -install(FILES Preview.png Theme.rc main.qml DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Minimalistic) - -install(FILES images/kdegear.png DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Minimalistic/images) -install(FILES images/kdeletter.png DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Minimalistic/images) -install(FILES images/kdemask.png DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Minimalistic/images) -install(FILES images/kdelogo.png DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Minimalistic/images) -install(FILES images/kdelogo-contrast.png DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/Minimalistic/images) diff --git a/ksplash/ksplashqml/themes/Minimalistic/Preview.png b/ksplash/ksplashqml/themes/Minimalistic/Preview.png deleted file mode 100644 index 3836adfe..00000000 Binary files a/ksplash/ksplashqml/themes/Minimalistic/Preview.png and /dev/null differ diff --git a/ksplash/ksplashqml/themes/Minimalistic/Theme.rc b/ksplash/ksplashqml/themes/Minimalistic/Theme.rc deleted file mode 100644 index d9a48516..00000000 --- a/ksplash/ksplashqml/themes/Minimalistic/Theme.rc +++ /dev/null @@ -1,9 +0,0 @@ -[KSplash Theme: Minimalistic] -Name = Minimalistic splash screen -Description = Animated KDE logo on a black background -Version = 1.0 -Author = Ivan Cukic -Homepage = http://www.kde.org - -# Theme behaviour settings. -Engine = KSplashQML diff --git a/ksplash/ksplashqml/themes/Minimalistic/images/kdegear.png b/ksplash/ksplashqml/themes/Minimalistic/images/kdegear.png deleted file mode 100644 index 983fa42d..00000000 Binary files a/ksplash/ksplashqml/themes/Minimalistic/images/kdegear.png and /dev/null differ diff --git a/ksplash/ksplashqml/themes/Minimalistic/images/kdeletter.png b/ksplash/ksplashqml/themes/Minimalistic/images/kdeletter.png deleted file mode 100644 index 271a36c4..00000000 Binary files a/ksplash/ksplashqml/themes/Minimalistic/images/kdeletter.png and /dev/null differ diff --git a/ksplash/ksplashqml/themes/Minimalistic/images/kdelogo-contrast.png b/ksplash/ksplashqml/themes/Minimalistic/images/kdelogo-contrast.png deleted file mode 100644 index b5b57344..00000000 Binary files a/ksplash/ksplashqml/themes/Minimalistic/images/kdelogo-contrast.png and /dev/null differ diff --git a/ksplash/ksplashqml/themes/Minimalistic/images/kdelogo.png b/ksplash/ksplashqml/themes/Minimalistic/images/kdelogo.png deleted file mode 100644 index e15b325a..00000000 Binary files a/ksplash/ksplashqml/themes/Minimalistic/images/kdelogo.png and /dev/null differ diff --git a/ksplash/ksplashqml/themes/Minimalistic/images/kdemask.png b/ksplash/ksplashqml/themes/Minimalistic/images/kdemask.png deleted file mode 100644 index fc4978d8..00000000 Binary files a/ksplash/ksplashqml/themes/Minimalistic/images/kdemask.png and /dev/null differ diff --git a/ksplash/ksplashqml/themes/Minimalistic/main.qml b/ksplash/ksplashqml/themes/Minimalistic/main.qml deleted file mode 100644 index 383aba47..00000000 --- a/ksplash/ksplashqml/themes/Minimalistic/main.qml +++ /dev/null @@ -1,181 +0,0 @@ -/* vim:set foldenable foldmethod=marker: - * - * Copyright (C) 2011 Ivan Cukic - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * or (at your option) any later version, as published by the Free - * Software Foundation - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -import QtQuick 1.0 - -Item { - id: main - - width: screenSize.width - height: screenSize.height - // width: 300 - // height: 300 - - /* property declarations --------------------------{{{ */ - property int stage - property int iconSize: (screenSize.width <= 1024) ? 64 : 128 - /* }}} */ - - /* signal declarations ----------------------------{{{ */ - - /* }}} */ - - /* JavaScript functions ---------------------------{{{ */ - onStageChanged: { - if (stage == 1) { - background.opacity = 1 - gear.opacity = 0.5 - } - if (stage == 2) { - gear.opacity = 1 - mask.opacity = 1 - letter.opacity = 1 - } - if (stage == 3) { - } - if (stage == 4) { - } - if (stage == 5) { - logo.opacity = 1 - } - if (stage == 6) { - } - } - /* }}} */ - - /* object properties ------------------------------{{{ */ - - /* }}} */ - - /* child objects ----------------------------------{{{ */ - - Rectangle { - color: "black" - anchors.fill: parent - } - - Rectangle { - id: background - - gradient: Gradient { - GradientStop { position: 0.0; color: "#55555f" } - GradientStop { position: 1.0; color: "#000000" } - } - - anchors { - top: parent.top - left: parent.left - right: parent.right - } - - height: gear.y - 32 - - opacity: 0 - Behavior on opacity { NumberAnimation { duration: 1000; easing { type: Easing.InOutQuad } } } - } - - Image { - id: gear - - height: iconSize - width: iconSize - smooth: true - - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 - - source: "images/kdegear.png" - - opacity: 0 - Behavior on opacity { NumberAnimation { duration: 1000; easing { type: Easing.InOutQuad } } } - - NumberAnimation { - id: animateRotation - target: gear - properties: "rotation" - from: 0 - to: 360 - duration: 5000 - - loops: Animation.Infinite - running: true - } - - } - - Image { - id: mask - - height: iconSize - width: iconSize - smooth: true - - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 - - source: "images/kdemask.png" - - opacity: 0 - Behavior on opacity { NumberAnimation { duration: 1000; easing { type: Easing.InOutQuad } } } - } - - Image { - id: letter - - height: iconSize - width: iconSize - smooth: true - - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 - - source: "images/kdeletter.png" - - opacity: 0 - Behavior on opacity { NumberAnimation { duration: 1000; easing { type: Easing.InOutQuad } } } - } - - Image { - id: logo - - height: iconSize - width: iconSize - smooth: true - - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 - 1 - - source: "images/kdelogo-contrast.png" - - opacity: 0 - Behavior on opacity { NumberAnimation { duration: 1000; easing { type: Easing.InOutQuad } } } - } - - /* }}} */ - - /* stages -----------------------------------------{{{ */ - - /* }}} */ - - /* transitions ------------------------------------{{{ */ - - /* }}} */ -} - diff --git a/ksplash/ksplashx/CMakeLists.txt b/ksplash/ksplashx/CMakeLists.txt deleted file mode 100644 index a3e90731..00000000 --- a/ksplash/ksplashx/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -project(ksplashx) - -add_subdirectory(scale) -add_subdirectory(utils) - -include_directories( - ${PNG_INCLUDE_DIRS} -) - -include(CheckCXXSourceCompiles) -CHECK_CXX_SOURCE_COMPILES(" -int main() { __asm__(\"pxor %mm0, %mm0\") ; }" - X86_MMX_FOUND -) - -########### next target ############### - -set(ksplashx_SRCS - main.cpp - qglobal.cpp - qpngio.cpp - qimage.cpp - qsize.cpp - pixmap.cpp - qcolor.cpp - qcolor_x11.cpp - qcolor_p.cpp - x11_defs.cpp - defs.cpp - splash.cpp - qrect.cpp - kcpuinfo.cpp - scale.cpp -) - -# this doesn't work on x86_64 so it needs somebody who knows assembly enough to fix it -if(X86_MMX_FOUND AND "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "i[3-6]86") - enable_language(ASM) - set(ksplashx_SRCS - ${ksplashx_SRCS} - asm_scale.S - ) - add_definitions(-DHAVE_X86_MMX) -endif() - -add_executable(ksplashx ${ksplashx_SRCS}) -target_link_libraries(ksplashx ${X11_LIBRARIES} ${PNG_LIBRARIES}) -if(X11_Xinerama_FOUND) - target_link_libraries(ksplashx ${X11_Xinerama_LIB}) -endif() - -install(TARGETS ksplashx ${INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/ksplash/ksplashx/LICENSE b/ksplash/ksplashx/LICENSE deleted file mode 100644 index fee7477f..00000000 --- a/ksplash/ksplashx/LICENSE +++ /dev/null @@ -1,12 +0,0 @@ -This work, as a whole, is licensed under the terms of the -GNU General Public License version 2 as published by the Free Software -Foundation. - -Many files are based on sources of the Qt GUI Toolkit. Please see their -headers for futher information. - -All contributions, either in files based on Qt or in original files, -are, and are required to be, compatible with the terms of the GNU General -Public License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. Please -see headers of the individual files for further information. diff --git a/ksplash/ksplashx/README b/ksplash/ksplashx/README deleted file mode 100644 index 3fb70da9..00000000 --- a/ksplash/ksplashx/README +++ /dev/null @@ -1,117 +0,0 @@ -This is a splashscreen which basically depends only on libX11 and libpng. -It includes few sources from Qt which have been modified to work without -QApplication. Due to almost no link dependencies and no QApplication -initialization this splashscreen has a very fast startup. - -Please see file LICENSE for the licensing terms. - - -LIMITATIONS: -This implementation can only draw images and animations. This means that -e.g. texts need to be pre-rendered into images. i18n support is however -provided by mimicking KLocale's mechanism for localizing non-text resources. - - -USAGE: -ksplashx [--test] - - -NOTES: -Add a comment in description.txt and update it everytime you change anything. -Caching of the splash is done and the timestamp of description.txt is used. -Alternatively, update at least Theme.rc. - -New images are alphablended (if needed) with what's in the splash window -and then they replace what's at their position. Animations have all frames -alphablended (if needed) with what's in the splash window but they do not -replace window contents permanently. - -In a theme directory there can be a subdirectory for each screen resolution -named the same like the resolution (e.g. "1600x1200"). A best match is searched -for the active screen resolution. It should be usually enough to have just -one set, e.g. 1600x1200; especially with SCALE OFF. - -Low color screen depths are supported, with bpp <= 8 a directory called with -"-locolor" (e.g. "1600x1200-locolor") appended is always searched first. - - -FORMAT: - -# comments start with # -# commands are case-sensitive - -# whether to enable scaling (SCALE ON) or not (SCALE OFF) to fit current screen resolution -# if enabled, all positions and sizes are scaled by ratio between their primary resolution size -# and current resolution size (e.g. a 80x80 image at 100,0 in 1600x1200 -# is scaled to 40x40 at 50,0 for 800x600) -# defaults to ON, it's suggested to always explicitly specify -# it is possible to toggle scaling also several times (e.g. scale background image, not scale the rest) -SCALE ON/OFF - -# like SCALE, for only one dimension -SCALEX ON/OFF -SCALEY ON/OFF - -# x y w h - geometry of the splash window (screen size by default) -# if x or y are negative, they're relative to the right/bottom side -GEOMETRY x y w h - -# geometry of the splash window relatively to the screen -# relative position is specified as x_rel,y_rel offset of reference point of the window -# to reference point of the screen -# reference point is specified as two letters, first being X, second being Y: -# L - left, R - right, C - center, T - top, B - bottom -# e.g. GEOMETRY_REL LC 100 0 CC places window's center 100 pixels to the right of middle of left screen edge -GEOMETRY_REL screen_ref x_rel y_rel window_ref w h - -# color to fill the window with (this command also clears the whole window) -# not necessary if image(s) will fill the area entirely -BACKGROUND color - -# place an image called name (no path, include extension) at position x,y -IMAGE x y name - -# Same as image but this image is painted on every screen in xinerama setups -BACKGROUND_IMAGE x y name - -# place an image called name (no path, include extension) at relative position -# see description of GEOMETRY_REL for screen_ref, x_rel, y_rel and image_ref (=window_ref) -IMAGE_REL screen_ref x_rel y_xrel image_ref name - -# place animation from file 'name' at position x,y, id is 'number' -# animation is specified in a non-animated file as a sequence of images in rows, -# images wrap at 10 columns -# image contains 'frames' frames and there's 'delay' pause between each frame -# the animation repeats 'repeat' times, with 0 for infinite (optional field defaulting to 0) -ANIM number x y frames name delay [repeat] - -# place animation -# see description of ANIM for number, frames, name, delay and repeat -# see description of GEOMETRY_REL for screen_ref, x_rel, y_rel and image_ref (=window_ref) -ANIM_REL number screen_ref x_rel y_rel image_ref frames name delay [repeat] - -# stop animation with the given id -# this also clears the animation from the window -STOP_ANIM number - -# wait until the specified ksplash state -# see the splash toplevel README file (one directory up) -# specifying "ready" means waiting until whole startup is complete (should be used at the very end) -WAIT_STATE state - - -HOW TO CREATE ANIM PNG FILE: - -Since there's only PNG support, animation have to be prepared as separate frames. -In order to improve performance, all frames are put together in one big PNG file. - -Steps: -1. Animation must be prepared as a list of images. -2. In the utils/ directory there's prepareanim utility. Run it as - ./prepareanim - where - frame images - list of images for animation in their order -3. File result.png will be created. - -It is also possible to create the resulting PNG manually - frames are added -in rows, rows wrap at 10th frame. diff --git a/ksplash/ksplashx/asm_scale.S b/ksplash/ksplashx/asm_scale.S deleted file mode 100644 index 911fa633..00000000 --- a/ksplash/ksplashx/asm_scale.S +++ /dev/null @@ -1,795 +0,0 @@ -#define PR_(foo) __##foo -#define PT_(foo,func) __##foo,func -#define SIZE(sym) \ - .__end_##sym:; \ - .size __##sym,.__end_##sym-__##sym; \ - .align 8; - -/*\ -|*| MMX assembly scaling routine for Imlib2 -|*| Written by Willem Monsuwe -\*/ - -.text - .align 8 -.globl PR_(mimageScale_mmx_AARGBA) -/* .type PT_(mimageScale_mmx_AARGBA,@function) */ - - -/*\ Prototype: __mimageScale_mmx_AARGBA(ImlibScaleInfo *isi, DATA32 *dest, -|*| int dxx, int dyy, int dx, int dy, int dw, int dh, int dow, int sow) -\*/ - -#define isi 8(%ebp) -#define dest 12(%ebp) -#define dxx 16(%ebp) -#define dyy 20(%ebp) -#define dx 24(%ebp) -#define dy 28(%ebp) -#define dw 32(%ebp) -#define dh 36(%ebp) -#define dow 40(%ebp) -#define sow 44(%ebp) - -/*\ Local variables that didn't fit in registers \*/ -#define y -4(%ebp) -#define yp -8(%ebp) -#define yap -12(%ebp) -#define xp -16(%ebp) -#define xap -20(%ebp) -#define Cx -24(%ebp) -#define Mx -28(%ebp) -#define Cy -32(%ebp) -#define My -36(%ebp) -#define sow_4 -40(%ebp) - -/*\ When %edx points to ImlibScaleInfo, these are the members \*/ -#define xpoints (%edx) -#define ypoints 4(%edx) -#define xapoints 8(%edx) -#define yapoints 12(%edx) -#define xup_yup 16(%edx) - -PR_(mimageScale_mmx_AARGBA): - pushl %ebp - movl %esp, %ebp - subl $40, %esp - pushl %ebx - pushl %ecx - pushl %edx - pushl %edi - pushl %esi - movl isi, %edx - - /*\ Check (dw > 0) && (dh > 0) \*/ - cmpl $0, dw - jle .scale_leave - cmpl $0, dh - jle .scale_leave - - /*\ X-based array pointers point to the end; we're looping up to 0 \*/ - /*\ %edi = dest + dow * dy + dx + dw \*/ - movl dow, %eax - imull dy, %eax - addl dx, %eax - addl dw, %eax - movl dest, %edi - leal (%edi, %eax, 4), %edi - /*\ xp = xpoints + dxx + dw \*/ - movl dxx, %ebx - addl dw, %ebx - movl xpoints, %eax - leal (%eax, %ebx, 4), %eax - movl %eax, xp - /*\ xap = xapoints + dxx + dw \*/ - movl xapoints, %eax - leal (%eax, %ebx, 4), %eax - movl %eax, xap - /*\ y = dh \*/ - movl dh, %eax - movl %eax, y - /*\ yp = ypoints + dyy \*/ - movl dyy, %ebx - movl ypoints, %eax - leal (%eax, %ebx, 4), %eax - movl %eax, yp - /*\ yap = yapoints + dyy \*/ - movl yapoints, %eax - leal (%eax, %ebx, 4), %eax - movl %eax, yap - - pxor %mm7, %mm7 - - /*\ Test xup bit \*/ - movl xup_yup, %eax - sarl $1, %eax - jnc .scale_x_down - -.scale_x_up: - /*\ Test yup bit \*/ - sarl $1, %eax - jnc .scale_x_up_y_down - - -/*\ Scaling up both ways \*/ - -.scale_x_up_y_up: - movl sow, %ebx - -.up_up_loop_y: - - /*\ x = -dw \*/ - movl dw, %ecx - negl %ecx - - /*\ %eax = *yap << 4 \*/ - movl yap, %eax - movl (%eax), %eax - sall $4, %eax - jz .up_up_yap_0 - movd %eax, %mm1 - punpcklwd %mm1, %mm1 - punpckldq %mm1, %mm1 - -.up_up_loop1_x: - /*\ %esi = *yp + xp[x] \*/ - movl yp, %eax - movl (%eax), %esi - movl xp, %eax - movl (%eax, %ecx, 4), %eax - leal (%esi, %eax, 4), %esi - - /*\ %eax = xap[x] << 4 \*/ - movl xap, %eax - movl (%eax, %ecx, 4), %eax - sall $4, %eax - jz .up_up_xap_0 - - /*\ %mm0 = xap[x] << 4 \*/ - movd %eax, %mm0 - punpcklwd %mm0, %mm0 - punpckldq %mm0, %mm0 - - /*\ Load and unpack four pixels in parralel - |*| %mm2 = ptr[0], %mm3 = ptr[1] - |*| %mm4 = ptr[sow], %mm5 = ptr[sow + 1] - \*/ - movq (%esi), %mm2 - movq (%esi, %ebx, 4), %mm4 - movq %mm2, %mm3 - movq %mm4, %mm5 - punpcklbw %mm7, %mm2 - punpcklbw %mm7, %mm4 - punpckhbw %mm7, %mm3 - punpckhbw %mm7, %mm5 - - /*\ X interpolation: r = l + (r - l) * xap \*/ - psubw %mm2, %mm3 - psubw %mm4, %mm5 - psllw $4, %mm3 - psllw $4, %mm5 - pmulhw %mm0, %mm3 - pmulhw %mm0, %mm5 - paddw %mm2, %mm3 - paddw %mm4, %mm5 - /*\ Now %mm3 = I(ptr[0], ptr[1]), %mm5 = I(ptr[sow], ptr[sow + 1]) \*/ - jmp .up_up_common -.up_up_xap_0: - /*\ Load and unpack two pixels - |*| %mm3 = ptr[0], %mm5 = ptr[sow] - \*/ - movd (%esi), %mm3 - movd (%esi, %ebx, 4), %mm5 - punpcklbw %mm7, %mm3 - punpcklbw %mm7, %mm5 -.up_up_common: - /*\ Y interpolation: d = u + (d - u) * yap \*/ - psubw %mm3, %mm5 - psllw $4, %mm5 - pmulhw %mm1, %mm5 - paddw %mm3, %mm5 - packuswb %mm5, %mm5 - movd %mm5, (%edi, %ecx, 4) - - /*\ while (++x) \*/ - incl %ecx - jnz .up_up_loop1_x - jmp .up_up_yap_end -.up_up_yap_0: - -.up_up_loop2_x: - /*\ %esi = *yp + xp[x] \*/ - movl yp, %eax - movl (%eax), %esi - movl xp, %eax - movl (%eax, %ecx, 4), %eax - leal (%esi, %eax, 4), %esi - - /*\ %eax = xap[x] << 4 \*/ - movl xap, %eax - movl (%eax, %ecx, 4), %eax - sall $4, %eax - jz .up_up_0 - - /*\ %mm0 = xap[x] << 4 \*/ - movd %eax, %mm0 - punpcklwd %mm0, %mm0 - punpckldq %mm0, %mm0 - - /*\ Load and unpack two pixels in parralel - |*| %mm2 = ptr[0], %mm3 = ptr[1] - \*/ - movq (%esi), %mm2 - movq %mm2, %mm3 - punpcklbw %mm7, %mm2 - punpckhbw %mm7, %mm3 - - /*\ X interpolation: r = l + (r - l) * xap \*/ - psubw %mm2, %mm3 - psllw $4, %mm3 - pmulhw %mm0, %mm3 - paddw %mm2, %mm3 - packuswb %mm3, %mm3 - movd %mm3, (%edi, %ecx, 4) - jmp .up_up_1 -.up_up_0: - /*\ dptr[x] = *sptr \*/ - movl (%esi), %eax - movl %eax, (%edi, %ecx, 4) -.up_up_1: - incl %ecx - jnz .up_up_loop2_x - -.up_up_yap_end: - /*\ dptr += dow \*/ - movl dow, %eax - leal (%edi, %eax, 4), %edi - /*\ yap++; yp++ \*/ - addl $4, yap - addl $4, yp - /*\ while (y--) \*/ - decl y - jnz .up_up_loop_y - - jmp .scale_leave - - -/*\ Scaling down vertically \*/ - -.scale_x_up_y_down: - /*\ sow_4 = sow * 4 \*/ - movl sow, %eax - sall $2, %eax - movl %eax, sow_4 - -.up_down_loop_y: - - /*\ Setup My and Cy \*/ - movl yap, %eax - movzwl (%eax), %ebx - movl %ebx, My - movzwl 2(%eax), %eax - movl %eax, Cy - - /*\ mm4 = Cy \*/ - movd %eax, %mm4 - punpcklwd %mm4, %mm4 - punpckldq %mm4, %mm4 - /*\ mm5 = My \*/ - movd %ebx, %mm5 - punpcklwd %mm5, %mm5 - punpckldq %mm5, %mm5 - - /*\ x = -dw \*/ - movl dw, %ecx - negl %ecx -.up_down_loop_x: - /*\ %esi = *yp + xp[x] \*/ - movl yp, %eax - movl (%eax), %esi - movl xp, %eax - movl (%eax, %ecx, 4), %eax - leal (%esi, %eax, 4), %esi - - movl %esi, %eax - /*\ v = (*p * My) >> 10 \*/ - movd (%eax), %mm0 - punpcklbw %mm7, %mm0 - psllw $6, %mm0 - pmulhw %mm5, %mm0 - - /*\ i = 0x4000 - My \*/ - movl $0x4000, %ebx - subl My, %ebx - jbe 5f - jmp 2f -1: - /*\ p += sow; v += (*p * Cy) >> 10 \*/ - addl sow_4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $6, %mm1 - pmulhw %mm4, %mm1 - paddw %mm1, %mm0 - - /*\ i -= Cy; while (i > Cy) \*/ - subl Cy, %ebx -2: - cmpl Cy, %ebx - jg 1b - - /*\ mm6 = i \*/ - movd %ebx, %mm6 - punpcklwd %mm6, %mm6 - punpckldq %mm6, %mm6 - - /*\ p += sow; v += (*p * i) >> 10 \*/ - addl sow_4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $6, %mm1 - pmulhw %mm6, %mm1 - paddw %mm1, %mm0 -5: - /*\ %eax = xap[x] << 5 \*/ - movl xap, %eax - movl (%eax, %ecx, 4), %eax - sall $5, %eax - jz 6f - /*\ mm3 = xap[x] << 5 \*/ - movd %eax, %mm3 - punpcklwd %mm3, %mm3 - punpckldq %mm3, %mm3 - - /*\ p + 1 \*/ - movl %esi, %eax - addl $4, %eax - /*\ vv = (*p * My) >> 10 \*/ - movd (%eax), %mm2 - punpcklbw %mm7, %mm2 - psllw $6, %mm2 - pmulhw %mm5, %mm2 - - /*\ i = 0x4000 - My \*/ - movl $0x4000, %ebx - subl My, %ebx - jbe 5f - jmp 2f -1: - /*\ p += sow; vv += (*p * Cy) >> 10 \*/ - addl sow_4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $6, %mm1 - pmulhw %mm4, %mm1 - paddw %mm1, %mm2 - - /*\ i -= Cy; while (i > Cy) \*/ - subl Cy, %ebx -2: - cmpl Cy, %ebx - jg 1b - - /*\ p += sow; v += (*p * i) >> 10 \*/ - addl sow_4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $6, %mm1 - pmulhw %mm6, %mm1 - paddw %mm1, %mm2 -5: - /*\ v = v + (vv - v) * xap \*/ - psubw %mm0, %mm2 - psllw $3, %mm2 - pmulhw %mm3, %mm2 - paddw %mm2, %mm0 -6: - /*\ dest[x] = v >> 4 \*/ - psrlw $4, %mm0 - packuswb %mm0, %mm0 - movd %mm0, (%edi, %ecx, 4) - - /*\ while (++x) \*/ - incl %ecx - jnz .up_down_loop_x - - /*\ dptr += dow \*/ - movl dow, %eax - leal (%edi, %eax, 4), %edi - /*\ yap++; yp++ \*/ - addl $4, yap - addl $4, yp - /*\ while (y--) \*/ - decl y - jnz .up_down_loop_y - - jmp .scale_leave - -.scale_x_down: - /*\ Test yup bit \*/ - sarl $1, %eax - jnc .scale_x_down_y_down - - -/*\ Scaling down horizontally \*/ - -.scale_x_down_y_up: - /*\ sow_4 = sow * 4 \*/ - movl sow, %eax - sall $2, %eax - movl %eax, sow_4 - -.down_up_loop_y: - - /*\ %eax = *yap << 5 \*/ - movl yap, %eax - movl (%eax), %eax - sall $5, %eax - /*\ mm3 = *yap << 5 \*/ - movd %eax, %mm3 - punpcklwd %mm3, %mm3 - punpckldq %mm3, %mm3 - - /*\ x = -dw \*/ - movl dw, %ecx - negl %ecx -.down_up_loop_x: - /*\ %esi = *yp + xp[x] \*/ - movl yp, %eax - movl (%eax), %esi - movl xp, %eax - movl (%eax, %ecx, 4), %eax - leal (%esi, %eax, 4), %esi - - /*\ Setup Mx and Cx \*/ - movl xap, %eax - movzwl (%eax, %ecx, 4), %ebx - movl %ebx, Mx - movzwl 2(%eax, %ecx, 4), %eax - movl %eax, Cx - - /*\ mm4 = Cx \*/ - movd %eax, %mm4 - punpcklwd %mm4, %mm4 - punpckldq %mm4, %mm4 - /*\ mm5 = Mx \*/ - movd %ebx, %mm5 - punpcklwd %mm5, %mm5 - punpckldq %mm5, %mm5 - - movl %esi, %eax - /*\ v = (*p * Mx) >> 10 \*/ - movd (%eax), %mm0 - punpcklbw %mm7, %mm0 - psllw $6, %mm0 - pmulhw %mm5, %mm0 - - /*\ i = 0x4000 - Mx \*/ - movl $0x4000, %ebx - subl Mx, %ebx - jbe 5f - jmp 2f -1: - /*\ p += sow; v += (*p * Cx) >> 10 \*/ - addl $4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $6, %mm1 - pmulhw %mm4, %mm1 - paddw %mm1, %mm0 - - /*\ i -= Cx; while (i > Cx) \*/ - subl Cx, %ebx -2: - cmpl Cx, %ebx - jg 1b - - /*\ mm6 = i \*/ - movd %ebx, %mm6 - punpcklwd %mm6, %mm6 - punpckldq %mm6, %mm6 - - /*\ p += sow; v += (*p * i) >> 10 \*/ - addl $4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $6, %mm1 - pmulhw %mm6, %mm1 - paddw %mm1, %mm0 -5: - movd %mm3, %eax - testl %eax, %eax - jz 6f - /*\ p + sow \*/ - movl %esi, %eax - addl sow_4, %eax - /*\ vv = (*p * Mx) >> 10 \*/ - movd (%eax), %mm2 - punpcklbw %mm7, %mm2 - psllw $6, %mm2 - pmulhw %mm5, %mm2 - - /*\ i = 0x4000 - Mx \*/ - movl $0x4000, %ebx - subl Mx, %ebx - jbe 5f - jmp 2f -1: - /*\ p += sow; vv += (*p * Cx) >> 10 \*/ - addl $4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $6, %mm1 - pmulhw %mm4, %mm1 - paddw %mm1, %mm2 - - /*\ i -= Cx; while (i > Cx) \*/ - subl Cx, %ebx -2: - cmpl Cx, %ebx - jg 1b - - /*\ p += sow; v += (*p * i) >> 10 \*/ - addl $4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $6, %mm1 - pmulhw %mm6, %mm1 - paddw %mm1, %mm2 -5: - /*\ v = v + (vv - v) * yap \*/ - psubw %mm0, %mm2 - psllw $3, %mm2 - pmulhw %mm3, %mm2 - paddw %mm2, %mm0 -6: - /*\ dest[x] = v >> 4 \*/ - psrlw $4, %mm0 - packuswb %mm0, %mm0 - movd %mm0, (%edi, %ecx, 4) - - /*\ while (++x) \*/ - incl %ecx - jnz .down_up_loop_x - - /*\ dptr += dow \*/ - movl dow, %eax - leal (%edi, %eax, 4), %edi - /*\ yap++; yp++ \*/ - addl $4, yap - addl $4, yp - /*\ while (y--) \*/ - decl y - jnz .down_up_loop_y - - jmp .scale_leave - - -/*\ Scaling down both ways \*/ - -.scale_x_down_y_down: - /*\ sow_4 = sow * 4 \*/ - movl sow, %eax - sall $2, %eax - movl %eax, sow_4 - -.down_down_loop_y: - - /*\ Setup My and Cy \*/ - movl yap, %eax - movzwl (%eax), %ebx - movl %ebx, My - movzwl 2(%eax), %eax - movl %eax, Cy - - /*\ x = -dw \*/ - movl dw, %ecx - negl %ecx -.down_down_loop_x: - /*\ %esi = *yp + xp[x] \*/ - movl yp, %eax - movl (%eax), %esi - movl xp, %eax - movl (%eax, %ecx, 4), %eax - leal (%esi, %eax, 4), %esi - - /*\ Setup Mx and Cx \*/ - movl xap, %eax - movzwl (%eax, %ecx, 4), %ebx - movl %ebx, Mx - movzwl 2(%eax, %ecx, 4), %eax - movl %eax, Cx - - /*\ mm3 = Cx \*/ - movd %eax, %mm3 - punpcklwd %mm3, %mm3 - punpckldq %mm3, %mm3 - /*\ mm5 = Mx \*/ - movd %ebx, %mm5 - punpcklwd %mm5, %mm5 - punpckldq %mm5, %mm5 - - /*\ p = sptr; v = (*p * Mx) >> 9 \*/ - movl %esi, %eax - movd (%eax), %mm0 - punpcklbw %mm7, %mm0 - psllw $7, %mm0 - pmulhw %mm5, %mm0 - - /*\ i = 0x4000 - Mx \*/ - movl $0x4000, %ebx - subl Mx, %ebx - jbe 5f - jmp 2f -1: - /*\ v += (*++p * Cx) >> 9 \*/ - addl $4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $7, %mm1 - pmulhw %mm3, %mm1 - paddw %mm1, %mm0 - - /*\ i -= Cx; while (i > Cx) \*/ - subl Cx, %ebx -2: - cmpl Cx, %ebx - jg 1b - - /*\ mm6 = i \*/ - movd %ebx, %mm6 - punpcklwd %mm6, %mm6 - punpckldq %mm6, %mm6 - - /*\ v += (*++p * i) >> 9 \*/ - addl $4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $7, %mm1 - pmulhw %mm6, %mm1 - paddw %mm1, %mm0 -5: - /*\ v *= My \*/ - movd My, %mm4 - punpcklwd %mm4, %mm4 - punpckldq %mm4, %mm4 - psllw $2, %mm0 - pmulhw %mm4, %mm0 - - /*\ j = 0x4000 - My \*/ - movl $0x4000, %edx - subl My, %edx - jbe 6f - jmp 4f -3: - /*\ sptr += sow; p = sptr \*/ - addl sow_4, %esi - movl %esi, %eax - /*\ vx = (*p * Mx) >> 9 \*/ - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $7, %mm1 - pmulhw %mm5, %mm1 - - /*\ i = 0x4000 - Mx \*/ - movl $0x4000, %ebx - subl Mx, %ebx - jbe 5f - jmp 2f -1: - /*\ vx += (*++p * Cx) >> 9 \*/ - addl $4, %eax - movd (%eax), %mm2 - punpcklbw %mm7, %mm2 - psllw $7, %mm2 - pmulhw %mm3, %mm2 - paddw %mm2, %mm1 - - /*\ i -= Cx; while (i > Cx) \*/ - subl Cx, %ebx -2: - cmpl Cx, %ebx - jg 1b - - /*\ vx += (*++p * i) >> 9 \*/ - addl $4, %eax - movd (%eax), %mm2 - punpcklbw %mm7, %mm2 - psllw $7, %mm2 - pmulhw %mm6, %mm2 - paddw %mm2, %mm1 -5: - /*\ v += (vx * Cy) >> 14 \*/ - movd Cy, %mm4 - punpcklwd %mm4, %mm4 - punpckldq %mm4, %mm4 - psllw $2, %mm1 - pmulhw %mm4, %mm1 - paddw %mm1, %mm0 - - /*\ j -= Cy; while (j > Cy) \*/ - subl Cy, %edx -4: - cmpl Cy, %edx - jg 3b - - /*\ sptr += sow; p = sptr \*/ - addl sow_4, %esi - movl %esi, %eax - /*\ vx = (*p * Mx) >> 9 \*/ - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $7, %mm1 - pmulhw %mm5, %mm1 - - /*\ i = 0x4000 - Mx \*/ - movl $0x4000, %ebx - subl Mx, %ebx - jbe 5f - jmp 2f -1: - /*\ vx += (*++p * Cx) >> 9 \*/ - addl $4, %eax - movd (%eax), %mm2 - punpcklbw %mm7, %mm2 - psllw $7, %mm2 - pmulhw %mm3, %mm2 - paddw %mm2, %mm1 - - /*\ i -= Cx; while (i > Cx) \*/ - subl Cx, %ebx -2: - cmpl Cx, %ebx - jg 1b - - /*\ vx += (*++p * i) >> 9 \*/ - addl $4, %eax - movd (%eax), %mm2 - punpcklbw %mm7, %mm2 - psllw $7, %mm2 - pmulhw %mm6, %mm2 - paddw %mm2, %mm1 -5: - /*\ v += (vx * j) >> 14 \*/ - movd %edx, %mm4 - punpcklwd %mm4, %mm4 - punpckldq %mm4, %mm4 - psllw $2, %mm1 - pmulhw %mm4, %mm1 - paddw %mm1, %mm0 -6: - /*\ dptr[x] = mm0 >> 5 \*/ - psrlw $5, %mm0 - packuswb %mm0, %mm0 - movd %mm0, (%edi, %ecx, 4) - - /*\ while (++x) \*/ - incl %ecx - jnz .down_down_loop_x - - /*\ dptr += dow \*/ - movl dow, %eax - leal (%edi, %eax, 4), %edi - /*\ yap++; yp++ \*/ - addl $4, yap - addl $4, yp - /*\ while (y--) \*/ - decl y - jnz .down_down_loop_y - - jmp .scale_leave - -.scale_leave: - emms - popl %esi - popl %edi - popl %edx - popl %ecx - popl %ebx - movl %ebp, %esp - popl %ebp - ret - -SIZE(mimageScale_mmx_AARGBA) - - .section .note.GNU-stack,"",@progbits diff --git a/ksplash/ksplashx/defs.cpp b/ksplash/ksplashx/defs.cpp deleted file mode 100644 index 217969d1..00000000 --- a/ksplash/ksplashx/defs.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "defs.h" -#include - -bool freadline( char* buf, int bufsize, FILE* datafile ) - { - if( fgets( buf, bufsize, datafile ) == 0 ) - { - buf[ 0 ] = '\0'; - return false; - } - char* nl = strchr( buf, '\n' ); - if( nl != NULL ) - *nl = '\0'; - return true; - } - -void strip_whitespace( char* line ) - { - char* dst = line; - char* src = line; - while( *src == ' ' ) - ++src; - while( ( *dst++ = *src++ ) != '\0' ) - ; - --dst; - while( dst >= line && *dst == ' ' ) - *dst-- = '\0'; - } - -bool begins_with( const char* line, const char* str ) - { - int len = strlen( str ); - return strncmp( line, str, len ); - } diff --git a/ksplash/ksplashx/defs.h b/ksplash/ksplashx/defs.h deleted file mode 100644 index 36392184..00000000 --- a/ksplash/ksplashx/defs.h +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef QWINDOWDEFS_H -#define QWINDOWDEFS_H - -#include - -#define Q_WS_X11 - -#define Q_EXPORT -#define QT_NO_DATASTREAM -#define QT_NO_IMAGE_TEXT -#define QT_NO_IMAGE_TRANSFORMATION -#define QT_NO_IMAGE_MIRROR -#define QT_NO_COMPONENT -#define QT_NO_IMAGEIO -#define QT_NO_MIME -#define QT_NO_QIMAGEIO -#define QT_NO_STRINGLIST -#define QT_NO_XFTFREETYPE -#ifndef QT_NO_STL -#define QT_NO_STL -#endif -#ifndef QT_NO_ASCII_CAST -#define QT_NO_ASCII_CAST -#endif -#ifndef QT_NO_CAST_ASCII -#define QT_NO_CAST_ASCII -#endif - -#define QT_STATIC_CONST static const -#define QT_STATIC_CONST_IMPL const - -typedef int QCOORD; // coordinate type -const QCOORD QCOORD_MAX = 2147483647; -const QCOORD QCOORD_MIN = -QCOORD_MAX - 1; - -typedef unsigned int QRgb; // RGB triplet - -#define qMax(a, b) ((b) < (a) ? (a) : (b)) -#define qMin(a, b) ((a) < (b) ? (a) : (b)) -#define qAbs(a) ((a) >= 0 ? (a) : -(a)) - -#define Q_UNUSED(x) (void)x; - -#define Q_CHECK_PTR(p) - -#define Q_ASSERT(x) - -typedef unsigned char uchar; -typedef unsigned uint; - -typedef signed char Q_INT8; // 8 bit signed -typedef unsigned char Q_UINT8; // 8 bit unsigned -typedef short Q_INT16; // 16 bit signed -typedef unsigned short Q_UINT16; // 16 bit unsigned -typedef int Q_INT32; // 32 bit signed -typedef unsigned int quint32; // 32 bit unsigned -typedef long Q_LONG; // word up to 64 bit signed -typedef unsigned long Q_ULONG; // word up to 64 bit unsigned - - -#if 0 -const QRgb RGB_MASK = 0x00ffffff; // masks RGB values - -Q_EXPORT inline int qRed( QRgb rgb ) // get red part of RGB -{ return (int)((rgb >> 16) & 0xff); } - -Q_EXPORT inline int qGreen( QRgb rgb ) // get green part of RGB -{ return (int)((rgb >> 8) & 0xff); } - -Q_EXPORT inline int qBlue( QRgb rgb ) // get blue part of RGB -{ return (int)(rgb & 0xff); } - -Q_EXPORT inline int qAlpha( QRgb rgb ) // get alpha part of RGBA -{ return (int)((rgb >> 24) & 0xff); } - -Q_EXPORT inline QRgb qRgb( int r, int g, int b )// set RGB value -{ return (0xff << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); } - -Q_EXPORT inline QRgb qRgba( int r, int g, int b, int a )// set RGBA value -{ return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); } - -Q_EXPORT inline int qGray( int r, int g, int b )// convert R,G,B to gray 0..255 -{ return (r*11+g*16+b*5)/32; } - -Q_EXPORT inline int qGray( QRgb rgb ) // convert RGB to gray 0..255 -{ return qGray( qRed(rgb), qGreen(rgb), qBlue(rgb) ); } -#endif - -inline -Q_EXPORT void qWarning( const char *, ... ) // print warning message -#if defined(Q_CC_GNU) && !defined(__INSURE__) - __attribute__ ((format (printf, 1, 2))) -#endif - {} - -inline -Q_EXPORT void qFatal( const char *, ... ) // print fatal message and exit -#if defined(Q_CC_GNU) - __attribute__ ((format (printf, 1, 2))) -#endif - { - abort(); - } - -#include - -bool freadline( char* buf, int bufsize, FILE* datafile ); -void strip_whitespace( char* line ); -bool begins_with( const char* line, const char* str ); - -#endif diff --git a/ksplash/ksplashx/kcpuinfo.cpp b/ksplash/ksplashx/kcpuinfo.cpp deleted file mode 100644 index eda4f6f2..00000000 --- a/ksplash/ksplashx/kcpuinfo.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2003 Fredrik Hglund - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#include -#include "kcpuinfo.h" - - -#if defined(__GNUC__) -# define HAVE_GNU_INLINE_ASM -#endif - -static int getCpuFeatures() -{ - volatile int features = 0; - -#if defined( HAVE_GNU_INLINE_ASM ) && defined( __i386__ ) - bool haveCPUID = false; - int result = 0; - - // First check if the CPU supports the CPUID instruction - __asm__ __volatile__( - // Try to toggle the CPUID bit in the EFLAGS register - "pushf \n\t" // Push the EFLAGS register onto the stack - "popl %%ecx \n\t" // Pop the value into ECX - "movl %%ecx, %%edx \n\t" // Copy ECX to EDX - "xorl $0x00200000, %%ecx \n\t" // Toggle bit 21 (CPUID) in ECX - "pushl %%ecx \n\t" // Push the modified value onto the stack - "popf \n\t" // Pop it back into EFLAGS - - // Check if the CPUID bit was successfully toggled - "pushf \n\t" // Push EFLAGS back onto the stack - "popl %%ecx \n\t" // Pop the value into ECX - "xorl %%eax, %%eax \n\t" // Zero out the EAX register - "cmpl %%ecx, %%edx \n\t" // Compare ECX with EDX - "je .Lno_cpuid_support%= \n\t" // Jump if they're identical - "movl $1, %%eax \n\t" // Set EAX to true - ".Lno_cpuid_support%=: \n\t" - : "=a"(haveCPUID) : : "%ecx", "%edx" ); - - // If we don't have CPUID we won't have the other extensions either - if ( ! haveCPUID ) - return 0L; - - // Execute CPUID with the feature request bit set - __asm__ __volatile__( - "pushl %%ebx \n\t" // Save EBX - "movl $1, %%eax \n\t" // Set EAX to 1 (features request) - "cpuid \n\t" // Call CPUID - "popl %%ebx \n\t" // Restore EBX - : "=d"(result) : : "%eax", "%ecx" ); - - // Test bit 23 (MMX support) - if ( result & 0x00800000 ) - features |= KCPUInfo::IntelMMX; -#endif //HAVE_GNU_INLINE_ASM - - return features; -} - -unsigned int KCPUInfo::s_features = getCpuFeatures(); - - diff --git a/ksplash/ksplashx/kcpuinfo.h b/ksplash/ksplashx/kcpuinfo.h deleted file mode 100644 index 6d840b03..00000000 --- a/ksplash/ksplashx/kcpuinfo.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2003 Fredrik Hglund - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef KCPUINFO_H -#define KCPUINFO_H - - -/** - * This class provides a means for applications to obtain information at - * runtime about processor support for certain architecture extensions, - * such as MMX. - */ -class KCPUInfo -{ - public: - /** - * This enum contains the list of architecture extensions you - * can query. - */ - enum Extensions { - IntelMMX = 1 << 0, //!< Intel's MMX instructions. - }; - - /** - * Returns true if the processor supports @p extension, - * and false otherwise. - * - * @param extension the feature to query. - * @return If true, the processor supports @p extension. - * @see Extensions - */ - static bool haveExtension( unsigned int extension ) - { return s_features & extension; } - - private: - static unsigned int s_features; -}; - -#endif - diff --git a/ksplash/ksplashx/main.cpp b/ksplash/ksplashx/main.cpp deleted file mode 100644 index 26cb8273..00000000 --- a/ksplash/ksplashx/main.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************** - -Copyright (C) 2007 Lubos Lunak - -Please see file LICENSE for the licensing terms of ksplashx as a whole. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*********************************************************************/ - -#include "pixmap.h" -#include "splash.h" -#include -#include -#include -#include -#include - -int screen_number = 0; -int number_of_screens = 1; - -static void usage( char* name ) - { - fprintf( stderr, "Usage: %s [--test] [--pid]\n", name ); - exit( 1 ); - } - -int main( int argc, char* argv[] ) - { - if( argc != 2 && argc != 3 && argc != 4 ) - usage( argv[ 0 ] ); - bool test = false; - bool print_pid = false; - int* cpid = 0; - for( int i = 2; // 1 is the theme - i < argc; - ++i ) - { - if( strcmp( argv[ i ], "--test" ) == 0 ) - test = true; - else if( strcmp( argv[ i ], "--pid" ) == 0 ) - print_pid = true; - else - usage( argv[ 0 ] ); - } - const char* theme = argv[ 1 ]; - if( strcmp( theme, "DefaultFullscreen" ) == 0 ) - theme = "Default"; // these are now the same - int parent_pipe = -1; - if( print_pid ) - { - int pipes[ 2 ]; - if( pipe( pipes ) < 0 ) - { - perror( "pipe()" ); - abort(); - } - pid_t pid = fork(); - if( pid < 0 ) - { - perror( "fork()" ); - abort(); - } - if( pid == 0 ) - { // child - close( pipes[ 0 ] ); - parent_pipe = pipes[ 1 ]; - close( 0 ); // close stdin,stdout,stderr, otherwise startkde will block - close( 1 ); - close( 2 ); - Display* dpy = XOpenDisplay(NULL); - if (!dpy) - { - exit(1); - } - number_of_screens = ScreenCount(dpy); - if (number_of_screens > 1) - { - cpid = (int*)calloc(number_of_screens, sizeof(int)); - screen_number = DefaultScreen(dpy); - char* display_name; - display_name = XDisplayString(dpy); - int breakpos = strlen(display_name); - for (int i = strlen(display_name) - 1; i >= 0; i--) - { - if (display_name[i] == '.') - { - breakpos = i; - break; - } - } - // Calculate the array size: part before the dot + length of the screen - // string (which is log10 + 1) + 1 for the dot itself + 8 for "DISPLAY=" + \0 - const int envir_len = breakpos + log10(static_cast(number_of_screens)) + 11; - char *envir = new char[envir_len]; - char *server_name = new char[breakpos + 1]; - strncpy(server_name, display_name, breakpos); - server_name[breakpos] = '\0'; - - XCloseDisplay(dpy); - dpy = 0; - for (int i = 0; i < number_of_screens; i++) - { - if (i != screen_number) - { - cpid[i] = fork(); - if (cpid[i] == 0) - { - screen_number = i; - // Break here because we are the child process, we don't - // want to fork() anymore - break; - } - } - } - snprintf(envir, envir_len, "DISPLAY=%s.%d", server_name, screen_number); - putenv(strdup(envir)); - delete[] envir; - delete[] server_name; - } - else - XCloseDisplay(dpy); - } - else - { // parent - close( pipes[ 1 ] ); - char buf; - while( read( pipes[ 0 ], &buf, 1 ) < 0 - && ( errno == EINTR || errno == EAGAIN || errno == ECHILD )) - ; - if( print_pid ) - printf( "%d\n", pid ); - return 0; - } - } - if( !openDisplay()) - return 2; - if( test ) - XSynchronize( qt_xdisplay(), True ); - runSplash( theme, test, parent_pipe ); - closeDisplay(); - if (number_of_screens > 1) - { - for (int i = 1; i < number_of_screens; i++) - kill(cpid[i], SIGTERM); - } - free(cpid); - } diff --git a/ksplash/ksplashx/pixmap.cpp b/ksplash/ksplashx/pixmap.cpp deleted file mode 100644 index 101a5ada..00000000 --- a/ksplash/ksplashx/pixmap.cpp +++ /dev/null @@ -1,1044 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include - -#ifdef HAVE_XSHM -#define QT_MITSHM_CONVERSIONS -#endif - -#include "qimage.h" -#include "qnamespace.h" -#include "qcolor.h" - -#include -#include - -#include "pixmap.h" - -#include "x11_defs.h" - -#ifdef QT_MITSHM_CONVERSIONS -#include -#include -#include -#include -#endif - -// Returns position of highest bit set or -1 if none -static int highest_bit( uint v ) -{ - int i; - uint b = (uint)1 << 31; - for ( i=31; ((b & v) == 0) && i>=0; i-- ) - b >>= 1; - return i; -} - -// Returns position of lowest set bit in 'v' as an integer (0-31), or -1 -static int lowest_bit( uint v ) -{ - int i; - unsigned long lb; - lb = 1; - for (i=0; ((v & lb) == 0) && i<32; i++, lb<<=1); - return i==32 ? -1 : i; -} - -// Counts the number of bits set in 'v' -static uint n_bits( uint v ) -{ - int i = 0; - while ( v ) { - v = v & (v - 1); - i++; - } - return i; -} - -inline static void qSafeXDestroyImage( XImage *x ) -{ - if ( x->data ) { - free( x->data ); - x->data = 0; - } - XDestroyImage( x ); -} - -#ifdef QT_MITSHM_CONVERSIONS - -static bool qt_mitshm_error = false; -static int qt_mitshm_errorhandler( Display*, XErrorEvent* ) -{ - qt_mitshm_error = true; - return 0; -} - -static XImage* qt_XShmCreateImage( Display* dpy, Visual* visual, unsigned int depth, - int format, int /*offset*/, char* /*data*/, unsigned int width, unsigned int height, - int /*bitmap_pad*/, int /*bytes_per_line*/, XShmSegmentInfo* shminfo ) -{ - if( width * height * depth < 100*100*32 ) - return NULL; - static int shm_inited = -1; - if( shm_inited == -1 ) { - if( XShmQueryExtension( dpy )) - shm_inited = 1; - else - shm_inited = 0; - } - if( shm_inited == 0 ) - return NULL; - XImage* xi = XShmCreateImage( dpy, visual, depth, format, NULL, shminfo, width, - height ); - if( xi == NULL ) - return NULL; - shminfo->shmid = shmget( IPC_PRIVATE, xi->bytes_per_line * xi->height, - IPC_CREAT|0600); - if( shminfo->shmid < 0 ) { - XDestroyImage( xi ); - return NULL; - } - shminfo->readOnly = False; - shminfo->shmaddr = (char*)shmat( shminfo->shmid, 0, 0 ); - if( shminfo->shmaddr == (char*)-1 ) { - XDestroyImage( xi ); - shmctl( shminfo->shmid, IPC_RMID, 0 ); - return NULL; - } - xi->data = shminfo->shmaddr; -#ifndef QT_MITSHM_RMID_IGNORES_REFCOUNT - // mark as deleted to automatically free the memory in case - // of a crash (but this doesn't work e.g. on Solaris) - shmctl( shminfo->shmid, IPC_RMID, 0 ); -#endif - if( shm_inited == 1 ) { // first time - XErrorHandler old_h = XSetErrorHandler( qt_mitshm_errorhandler ); - XShmAttach( dpy, shminfo ); - shm_inited = 2; - XSync( dpy, False ); - XSetErrorHandler( old_h ); - if( qt_mitshm_error ) { // oops ... perhaps we are remote? - shm_inited = 0; - XDestroyImage( xi ); - shmdt( shminfo->shmaddr ); -#ifdef QT_MITSHM_RMID_IGNORES_REFCOUNT - shmctl( shminfo->shmid, IPC_RMID, 0 ); -#endif - return NULL; - } - } else - XShmAttach( dpy, shminfo ); - return xi; -} - -static void qt_XShmDestroyImage( XImage* xi, XShmSegmentInfo* shminfo ) -{ - XShmDetach( QPaintDevice::x11AppDisplay(), shminfo ); - XDestroyImage( xi ); - shmdt( shminfo->shmaddr ); -#ifdef QT_MITSHM_RMID_IGNORES_REFCOUNT - shmctl( shminfo->shmid, IPC_RMID, 0 ); -#endif -} - -#endif // QT_MITSHM_CONVERSIONS - - -PixmapData PP::convertFromImage( const QImage &img, int conversion_flags ) -{ - if ( img.isNull() ) { -#if defined(QT_CHECK_NULL) - qWarning( "QPixmap::convertFromImage: Cannot convert a null image" ); -#endif - return PixmapData(); - } -//# detach(); // detach other references - QImage image = img; - const uint w = image.width(); - const uint h = image.height(); - int d = image.depth(); - const int dd = x11Depth(); - bool force_mono = (dd == 1 || //#*isQBitmap() || - (conversion_flags & Qt::ColorMode_Mask)==MonoOnly ); - -#if 0 - // get rid of the mask - delete data->mask; - data->mask = 0; - - // get rid of alpha pixmap - delete data->alphapm; - data->alphapm = 0; -#endif - - // must be monochrome - if ( force_mono ) { - if ( d != 1 ) { - // dither - image = image.convertDepth( 1, conversion_flags ); - d = 1; - } - } else { // can be both - bool conv8 = false; - if ( d > 8 && dd <= 8 ) { // convert to 8 bit - if ( (conversion_flags & DitherMode_Mask) == AutoDither ) - conversion_flags = (conversion_flags & ~DitherMode_Mask) - | PreferDither; - conv8 = true; - } else if ( (conversion_flags & ColorMode_Mask) == ColorOnly ) { - conv8 = d == 1; // native depth wanted - } else if ( d == 1 ) { - if ( image.numColors() == 2 ) { - QRgb c0 = image.color(0); // Auto: convert to best - QRgb c1 = image.color(1); - conv8 = qMin(c0,c1) != qRgb(0,0,0) || qMax(c0,c1) != qRgb(255,255,255); - } else { - // eg. 1-color monochrome images (they do exist). - conv8 = true; - } - } - if ( conv8 ) { - image = image.convertDepth( 8, conversion_flags ); - d = 8; - } - } - - if ( d == 1 ) { // 1 bit pixmap (bitmap) - abort(); -#if 0 - if ( hd ) { // delete old X pixmap - -#ifndef QT_NO_XFTFREETYPE - if (rendhd) { - XftDrawDestroy( (XftDraw *) rendhd ); - rendhd = 0; - } -#endif // QT_NO_XFTFREETYPE - - XFreePixmap( x11Display(), hd ); - } - - // make sure image.color(0) == color0 (white) and image.color(1) == color1 (black) - if (image.color(0) == Qt::black.rgb() && image.color(1) == Qt::white.rgb()) { - image.invertPixels(); - image.setColor(0, Qt::white.rgb()); - image.setColor(1, Qt::black.rgb()); - } - - char *bits; - uchar *tmp_bits; - int bpl = (w+7)/8; - int ibpl = image.bytesPerLine(); - if ( image.bitOrder() == QImage::BigEndian || bpl != ibpl ) { - tmp_bits = new uchar[bpl*h]; - Q_CHECK_PTR( tmp_bits ); - bits = (char *)tmp_bits; - uchar *p, *b, *end; - uint y, count; - if ( image.bitOrder() == QImage::BigEndian ) { - const uchar *f = qt_get_bitflip_array(); - b = tmp_bits; - for ( y=0; y 4 ) { - *b++ = f[*p++]; - *b++ = f[*p++]; - *b++ = f[*p++]; - *b++ = f[*p++]; - count -= 4; - } - while ( p < end ) - *b++ = f[*p++]; - } - } else { // just copy - b = tmp_bits; - p = image.scanLine( 0 ); - for ( y=0; yw = w; data->h = h; data->d = 1; - - if ( image.hasAlphaBuffer() ) { - QBitmap m; - m = image.createAlphaMask( conversion_flags ); - setMask( m ); - } - return true; -#endif - } - - Display *dpy = x11Display(); - Visual *visual = (Visual *)x11Visual(); - XImage *xi = 0; - bool trucol = (visual->c_class == TrueColor); - int nbytes = image.byteCount(); - uchar *newbits= 0; - int newbits_size = 0; -#ifdef QT_MITSHM_CONVERSIONS - bool mitshm_ximage = false; - XShmSegmentInfo shminfo; -#endif - - if ( trucol ) { // truecolor display - QRgb pix[256]; // pixel translation table - const bool d8 = d == 8; - const uint red_mask = (uint)visual->red_mask; - const uint green_mask = (uint)visual->green_mask; - const uint blue_mask = (uint)visual->blue_mask; - const int red_shift = highest_bit( red_mask ) - 7; - const int green_shift = highest_bit( green_mask ) - 7; - const int blue_shift = highest_bit( blue_mask ) - 7; - const uint rbits = highest_bit(red_mask) - lowest_bit(red_mask) + 1; - const uint gbits = highest_bit(green_mask) - lowest_bit(green_mask) + 1; - const uint bbits = highest_bit(blue_mask) - lowest_bit(blue_mask) + 1; - - if ( d8 ) { // setup pixel translation - QRgb *ctable = image.colorTable(); - for ( int i=0; i 0 ? r << red_shift : r >> -red_shift; - g = green_shift > 0 ? g << green_shift : g >> -green_shift; - b = blue_shift > 0 ? b << blue_shift : b >> -blue_shift; - pix[i] = (b & blue_mask) | (g & green_mask) | (r & red_mask) - | ~(blue_mask | green_mask | red_mask); - } - } - -#ifdef QT_MITSHM_CONVERSIONS - xi = qt_XShmCreateImage( dpy, visual, dd, ZPixmap, 0, 0, w, h, 32, 0, &shminfo ); - if( xi != NULL ) { - mitshm_ximage = true; - newbits = (uchar*)xi->data; - } - else -#endif - xi = XCreateImage( dpy, visual, dd, ZPixmap, 0, 0, w, h, 32, 0 ); - Q_CHECK_PTR( xi ); - if( newbits == NULL ) - newbits = (uchar *)malloc( xi->bytes_per_line*h ); - Q_CHECK_PTR( newbits ); - if ( !newbits ) // no memory - return PixmapData(); - int bppc = xi->bits_per_pixel; - - bool contig_bits = n_bits(red_mask) == rbits && - n_bits(green_mask) == gbits && - n_bits(blue_mask) == bbits; - bool dither_tc = - // Want it? - (conversion_flags & Dither_Mask) != ThresholdDither && - (conversion_flags & DitherMode_Mask) != AvoidDither && - // Need it? - bppc < 24 && !d8 && - // Can do it? (Contiguous bits?) - contig_bits; - - static bool init=false; - static int D[16][16]; - if ( dither_tc && !init ) { - // I also contributed this code to XV - WWA. - /* - The dither matrix, D, is obtained with this formula: - - D2 = [ 0 2 ] - [ 3 1 ] - - - D2*n = [ 4*Dn 4*Dn+2*Un ] - [ 4*Dn+3*Un 4*Dn+1*Un ] - */ - int n,i,j; - init=1; - - /* Set D2 */ - D[0][0]=0; - D[1][0]=2; - D[0][1]=3; - D[1][1]=1; - - /* Expand using recursive definition given above */ - for (n=2; n<16; n*=2) { - for (i=0; i 8 && xi->byte_order == LSBFirst ) - bppc++; - - int wordsize; - bool bigendian; - qSysInfo( &wordsize, &bigendian ); - bool same_msb_lsb = ( xi->byte_order == MSBFirst ) == ( bigendian ); - - if( bppc == 8 ) // 8 bit - mode = BPP8; - else if( bppc == 16 || bppc == 17 ) { // 16 bit MSB/LSB - if( red_shift == 8 && green_shift == 3 && blue_shift == -3 - && !d8 && same_msb_lsb ) - mode = BPP16_8_3_M3; - else if( red_shift == 7 && green_shift == 2 && blue_shift == -3 - && !d8 && same_msb_lsb ) - mode = BPP16_7_2_M3; - else - mode = bppc == 17 ? BPP16_LSB : BPP16_MSB; - } else if( bppc == 24 || bppc == 25 ) { // 24 bit MSB/LSB - mode = bppc == 25 ? BPP24_LSB : BPP24_MSB; - } else if( bppc == 32 || bppc == 33 ) { // 32 bit MSB/LSB - if( red_shift == 16 && green_shift == 8 && blue_shift == 0 - && !d8 && same_msb_lsb ) - mode = BPP32_16_8_0; - else - mode = bppc == 33 ? BPP32_LSB : BPP32_MSB; - } else - qFatal("Logic error 3"); - -#define GET_PIXEL \ - int pixel; \ - if ( d8 ) pixel = pix[*src++]; \ - else { \ - int r = qRed ( *p ); \ - int g = qGreen( *p ); \ - int b = qBlue ( *p++ ); \ - r = red_shift > 0 \ - ? r << red_shift : r >> -red_shift; \ - g = green_shift > 0 \ - ? g << green_shift : g >> -green_shift; \ - b = blue_shift > 0 \ - ? b << blue_shift : b >> -blue_shift; \ - pixel = (r & red_mask)|(g & green_mask) | (b & blue_mask) \ - | ~(blue_mask | green_mask | red_mask); \ - } - -// optimized case - no d8 case, shift only once instead of twice, mask only once instead of twice, -// use direct values instead of variables, and use only one statement -// (*p >> 16), (*p >> 8 ) and (*p) are qRed(),qGreen() and qBlue() without masking -// shifts have to be passed including the shift operator (e.g. '>>3'), because of the direction -#define GET_PIXEL_OPT(red_shift,green_shift,blue_shift,red_mask,green_mask,blue_mask) \ - int pixel = ((( *p >> 16 ) red_shift ) & red_mask ) \ - | ((( *p >> 8 ) green_shift ) & green_mask ) \ - | ((( *p ) blue_shift ) & blue_mask ); \ - ++p; - -#define GET_PIXEL_DITHER_TC \ - int r = qRed ( *p ); \ - int g = qGreen( *p ); \ - int b = qBlue ( *p++ ); \ - const int thres = D[x%16][y%16]; \ - if ( r <= (255-(1<<(8-rbits))) && ((r< thres) \ - r += (1<<(8-rbits)); \ - if ( g <= (255-(1<<(8-gbits))) && ((g< thres) \ - g += (1<<(8-gbits)); \ - if ( b <= (255-(1<<(8-bbits))) && ((b< thres) \ - b += (1<<(8-bbits)); \ - r = red_shift > 0 \ - ? r << red_shift : r >> -red_shift; \ - g = green_shift > 0 \ - ? g << green_shift : g >> -green_shift; \ - b = blue_shift > 0 \ - ? b << blue_shift : b >> -blue_shift; \ - int pixel = (r & red_mask)|(g & green_mask) | (b & blue_mask); - -// again, optimized case -// can't be optimized that much :( -#define GET_PIXEL_DITHER_TC_OPT(red_shift,green_shift,blue_shift,red_mask,green_mask,blue_mask, \ - rbits,gbits,bbits) \ - const int thres = D[x%16][y%16]; \ - int r = qRed ( *p ); \ - if ( r <= (255-(1<<(8-rbits))) && ((r< thres) \ - r += (1<<(8-rbits)); \ - int g = qGreen( *p ); \ - if ( g <= (255-(1<<(8-gbits))) && ((g< thres) \ - g += (1<<(8-gbits)); \ - int b = qBlue ( *p++ ); \ - if ( b <= (255-(1<<(8-bbits))) && ((b< thres) \ - b += (1<<(8-bbits)); \ - int pixel = (( r red_shift ) & red_mask ) \ - | (( g green_shift ) & green_mask ) \ - | (( b blue_shift ) & blue_mask ); - -#define CYCLE(body) \ - for ( uint y=0; ybytes_per_line*y; \ - QRgb* p = (QRgb *)src; \ - body \ - } - - if ( dither_tc ) { - switch ( mode ) { - case BPP16_8_3_M3: - CYCLE( - Q_INT16* dst16 = (Q_INT16*)dst; - for ( uint x=0; x>3,0xf800,0x7e0,0x1f,5,6,5) - *dst16++ = pixel; - } - ) - break; - case BPP16_7_2_M3: - CYCLE( - Q_INT16* dst16 = (Q_INT16*)dst; - for ( uint x=0; x>3,0x7c00,0x3e0,0x1f,5,5,5) - *dst16++ = pixel; - } - ) - break; - case BPP16_MSB: // 16 bit MSB - CYCLE( - for ( uint x=0; x> 8); - *dst++ = pixel; - } - ) - break; - case BPP16_LSB: // 16 bit LSB - CYCLE( - for ( uint x=0; x> 8; - } - ) - break; - default: - qFatal("Logic error"); - } - } else { - switch ( mode ) { - case BPP8: // 8 bit - CYCLE( - Q_UNUSED(p); - for ( uint x=0; x>3,0xf800,0x7e0,0x1f) - *dst16++ = pixel; - } - ) - break; - case BPP16_7_2_M3: - CYCLE( - Q_INT16* dst16 = (Q_INT16*)dst; - for ( uint x=0; x>3,0x7c00,0x3e0,0x1f) - *dst16++ = pixel; - } - ) - break; - case BPP16_MSB: // 16 bit MSB - CYCLE( - for ( uint x=0; x> 8); - *dst++ = pixel; - } - ) - break; - case BPP16_LSB: // 16 bit LSB - CYCLE( - for ( uint x=0; x> 8; - } - ) - break; - case BPP24_MSB: // 24 bit MSB - CYCLE( - for ( uint x=0; x> 16; - *dst++ = pixel >> 8; - *dst++ = pixel; - } - ) - break; - case BPP24_LSB: // 24 bit LSB - CYCLE( - for ( uint x=0; x> 8; - *dst++ = pixel >> 16; - } - ) - break; - case BPP32_16_8_0: - CYCLE( - memcpy( dst, p, w * 4 ); - ) - break; - case BPP32_MSB: // 32 bit MSB - CYCLE( - for ( uint x=0; x> 24; - *dst++ = pixel >> 16; - *dst++ = pixel >> 8; - *dst++ = pixel; - } - ) - break; - case BPP32_LSB: // 32 bit LSB - CYCLE( - for ( uint x=0; x> 8; - *dst++ = pixel >> 16; - *dst++ = pixel >> 24; - } - ) - break; - default: - qFatal("Logic error 2"); - } - } - xi->data = (char *)newbits; - } - - if ( d == 8 && !trucol ) { // 8 bit pixmap - int pop[256]; // pixel popularity - - if ( image.numColors() == 0 ) - image.setNumColors( 1 ); - - memset( pop, 0, sizeof(int)*256 ); // reset popularity array - uint i; - for ( i=0; i 0 ) - ncols++; - } - for ( i=image.numColors(); i<256; i++ ) // ignore out-of-range pixels - pop[i] = 0; - - // works since we make sure above to have at least - // one color in the image - if ( ncols == 0 ) - ncols = 1; - - PIX pixarr[256]; // pixel array - PIX pixarr_sorted[256]; // pixel array (sorted) - memset( pixarr, 0, ncols*sizeof(PIX) ); - PIX *px = &pixarr[0]; - int maxpop = 0; - int maxpix = 0; - Q_CHECK_PTR( pixarr ); - uint j = 0; - QRgb* ctable = image.colorTable(); - for ( i=0; i<256; i++ ) { // init pixel array - if ( pop[i] > 0 ) { - px->r = qRed ( ctable[i] ); - px->g = qGreen( ctable[i] ); - px->b = qBlue ( ctable[i] ); - px->n = 0; - px->use = pop[i]; - if ( pop[i] > maxpop ) { // select most popular entry - maxpop = pop[i]; - maxpix = j; - } - px->index = i; - px->mindist = 1000000; - px++; - j++; - } - } - pixarr_sorted[0] = pixarr[maxpix]; - pixarr[maxpix].use = 0; - - for ( i=1; i< (uint) ncols; i++ ) { // sort pixels - int minpix = -1, mindist = -1; - px = &pixarr_sorted[i-1]; - int r = px->r; - int g = px->g; - int b = px->b; - int dist; - if ( (i & 1) || i<10 ) { // sort on max distance - for ( int j=0; juse ) { - dist = (px->r - r)*(px->r - r) + - (px->g - g)*(px->g - g) + - (px->b - b)*(px->b - b); - if ( px->mindist > dist ) - px->mindist = dist; - if ( px->mindist > mindist ) { - mindist = px->mindist; - minpix = j; - } - } - } - } else { // sort on max popularity - for ( int j=0; juse ) { - dist = (px->r - r)*(px->r - r) + - (px->g - g)*(px->g - g) + - (px->b - b)*(px->b - b); - if ( px->mindist > dist ) - px->mindist = dist; - if ( px->use > mindist ) { - mindist = px->use; - minpix = j; - } - } - } - } - pixarr_sorted[i] = pixarr[minpix]; - pixarr[minpix].use = 0; - } - - uint pix[256]; // pixel translation table - px = &pixarr_sorted[0]; - for ( i=0; i< (uint) ncols; i++ ) { // allocate colors - QColor c( px->r, px->g, px->b ); - pix[px->index] = c.pixel(x11Screen()); - px++; - } - - p = newbits; - for ( i=0; i< (uint) nbytes; i++ ) { // translate pixels - *p = pix[*p]; - p++; - } - } - - if ( !xi ) { // X image not created -#ifdef QT_MITSHM_CONVERSIONS - xi = qt_XShmCreateImage( dpy, visual, dd, ZPixmap, 0, 0, w, h, 32, 0, &shminfo ); - if( xi != NULL ) - mitshm_ximage = true; - else -#endif - xi = XCreateImage( dpy, visual, dd, ZPixmap, 0, 0, w, h, 32, 0 ); - if ( xi->bits_per_pixel == 16 ) { // convert 8 bpp ==> 16 bpp - ushort *p2; - int p2inc = xi->bytes_per_line/sizeof(ushort); - ushort *newerbits = (ushort *)malloc( xi->bytes_per_line * h ); - newbits_size = xi->bytes_per_line * h; - Q_CHECK_PTR( newerbits ); - if ( !newerbits ) // no memory - return PixmapData(); - uchar* p = newbits; - for ( uint y=0; ybits_per_pixel != 8 ) { -#if defined(QT_CHECK_RANGE) - qWarning( "QPixmap::convertFromImage: Display not supported " - "(bpp=%d)", xi->bits_per_pixel ); -#endif - } -#ifdef QT_MITSHM_CONVERSIONS - if( newbits_size > 0 && mitshm_ximage ) { // need to copy to shared memory - memcpy( xi->data, newbits, newbits_size ); - free( newbits ); - newbits = (uchar*)xi->data; - } - else -#endif - xi->data = (char *)newbits; - } - -#if 0 - if ( hd && (width() != (int)w || height() != (int)h || this->depth() != dd) ) { - -#ifndef QT_NO_XFTFREETYPE - if (rendhd) { - XftDrawDestroy( (XftDraw *) rendhd ); - rendhd = 0; - } -#endif // QT_NO_XFTFREETYPE - - XFreePixmap( dpy, hd ); // don't reuse old pixmap - hd = 0; - } -#endif - PixmapData dat; - PixmapData* data = &dat; - data->hd = None; - Pixmap& hd = data->hd; - - if ( !hd ) { // create new pixmap - hd = (HANDLE)XCreatePixmap( x11Display(), - RootWindow(x11Display(), x11Screen() ), - w, h, dd ); - -#ifndef QT_NO_XFTFREETYPE - if ( qt_has_xft ) { - if ( data->d == 1 ) { - rendhd = (HANDLE) XftDrawCreateBitmap( x11Display (), hd ); - } else { - rendhd = (HANDLE) XftDrawCreate( x11Display (), hd, - (Visual *) x11Visual(), x11Colormap() ); - } - } -#endif // QT_NO_XFTFREETYPE - - } - -#ifdef QT_MITSHM_CONVERSIONS - if( mitshm_ximage ) - XShmPutImage( dpy, hd, qt_xget_readonly_gc( x11Screen(), false ), - xi, 0, 0, 0, 0, w, h, False ); - else -#endif - XPutImage( dpy, hd, qt_xget_readonly_gc( x11Screen(), false ), - xi, 0, 0, 0, 0, w, h ); - - data->w = w; - data->h = h; - data->d = dd; - - XImage* axi = NULL; -#ifdef QT_MITSHM_CONVERSIONS - bool mitshm_aximage = false; - XShmSegmentInfo ashminfo; -#endif - if ( image.hasAlphaBuffer() ) { - abort(); -#if 0 - QBitmap m; - m = image.createAlphaMask( conversion_flags ); - setMask( m ); - -#ifndef QT_NO_XFTFREETYPE - // does this image have an alphamap (and not just a 1bpp mask)? - bool alphamap = image.depth() == 32; - if (image.depth() == 8) { - const QRgb * const rgb = image.colorTable(); - for (int i = 0, count = image.numColors(); i < count; ++i) { - const int alpha = qAlpha(rgb[i]); - if (alpha != 0 && alpha != 0xff) { - alphamap = true; - break; - } - } - } - - if (qt_use_xrender && qt_has_xft && alphamap) { - data->alphapm = new QPixmap; // create a null pixmap - - // setup pixmap data - data->alphapm->data->w = w; - data->alphapm->data->h = h; - data->alphapm->data->d = 8; - - // create 8bpp pixmap and render picture - data->alphapm->hd = - XCreatePixmap(x11Display(), RootWindow(x11Display(), x11Screen()), - w, h, 8); - - data->alphapm->rendhd = - (HANDLE) XftDrawCreateAlpha( x11Display(), data->alphapm->hd, 8 ); - -#ifdef QT_MITSHM_CONVERSIONS - axi = qt_XShmCreateImage( x11Display(), (Visual*)x11Visual(), - 8, ZPixmap, 0, 0, w, h, 8, 0, &ashminfo ); - if( axi != NULL ) - mitshm_aximage = true; - else -#endif - axi = XCreateImage(x11Display(), (Visual *) x11Visual(), - 8, ZPixmap, 0, 0, w, h, 8, 0); - - if (axi) { - if( axi->data==NULL ) { - // the data is deleted by qSafeXDestroyImage - axi->data = (char *) malloc(h * axi->bytes_per_line); - Q_CHECK_PTR( axi->data ); - } - char *aptr = axi->data; - - if (image.depth() == 32) { - const int *iptr = (const int *) image.bits(); - if( axi->bytes_per_line == (int)w ) { - int max = w * h; - while (max--) - *aptr++ = *iptr++ >> 24; // squirt - } else { - for (uint i = 0; i < h; ++i ) { - for (uint j = 0; j < w; ++j ) - *aptr++ = *iptr++ >> 24; // squirt - aptr += ( axi->bytes_per_line - w ); - } - } - } else if (image.depth() == 8) { - const QRgb * const rgb = image.colorTable(); - for (uint y = 0; y < h; ++y) { - const uchar *iptr = image.scanLine(y); - for (uint x = 0; x < w; ++x) - *aptr++ = qAlpha(rgb[*iptr++]); - aptr += ( axi->bytes_per_line - w ); - } - } - - GC gc = XCreateGC(x11Display(), data->alphapm->hd, 0, 0); -#ifdef QT_MITSHM_CONVERSIONS - if( mitshm_aximage ) - XShmPutImage( dpy, data->alphapm->hd, gc, axi, 0, 0, 0, 0, w, h, False ); - else -#endif - XPutImage(dpy, data->alphapm->hd, gc, axi, 0, 0, 0, 0, w, h); - XFreeGC(x11Display(), gc); - } - } -#endif // QT_NO_XFTFREETYPE -#endif - } - -#ifdef QT_MITSHM_CONVERSIONS - if( mitshm_ximage || mitshm_aximage ) - XSync( x11Display(), False ); // wait until processed -#endif - - if ( data->optim != BestOptim ) { // throw away image -#ifdef QT_MITSHM_CONVERSIONS - if( mitshm_ximage ) - qt_XShmDestroyImage( xi, &shminfo ); - else -#endif - qSafeXDestroyImage( xi ); - data->ximage = 0; - } else { // keep ximage that we created -#ifdef QT_MITSHM_CONVERSIONS - if( mitshm_ximage ) { // copy the XImage? - qt_XShmDestroyImage( xi, &shminfo ); - xi = 0; - } -#endif - data->ximage = xi; - } - if( axi ) { -#ifdef QT_MITSHM_CONVERSIONS - if( mitshm_aximage ) - qt_XShmDestroyImage( axi, &ashminfo ); - else -#endif - qSafeXDestroyImage(axi); - } - return *data; -} diff --git a/ksplash/ksplashx/pixmap.h b/ksplash/ksplashx/pixmap.h deleted file mode 100644 index 3609e615..00000000 --- a/ksplash/ksplashx/pixmap.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef PIXMAP_H -#define PIXMAP_H - -#include "qnamespace.h" - -#include "x11_defs.h" - -class QImage; - -enum Optimization { DefaultOptim, NoOptim, MemoryOptim=NoOptim, - NormalOptim, BestOptim }; - -struct PixmapData - { - PixmapData() : hd( None ), optim( NoOptim ), ximage( NULL ) {} - Pixmap hd; - int w; - int h; - int d; - Optimization optim; - XImage* ximage; - }; - -class PP : public Qt // inherit from Qt to reduce needed code changes in the function - { - public: - static PixmapData convertFromImage( const QImage& img, int conversion_flags ); - }; - -inline -PixmapData imageToPixmap( const QImage& im ) - { - return PP::convertFromImage( im, 0 ); - } - -QImage splash_read_png_image(FILE* f); - -#endif diff --git a/ksplash/ksplashx/qcolor.cpp b/ksplash/ksplashx/qcolor.cpp deleted file mode 100644 index 40bb309b..00000000 --- a/ksplash/ksplashx/qcolor.cpp +++ /dev/null @@ -1,1030 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Implementation of QColor class -** -** Created : 940112 -** -** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "qcolor.h" -#include "qnamespace.h" -#include "qdatastream.h" - -#include -#include - -/*! - \class QColor qcolor.h - \brief The QColor class provides colors based on RGB or HSV values. - - \ingroup images - \ingroup graphics - \ingroup appearance - - A color is normally specified in terms of RGB (red, green and blue) - components, but it is also possible to specify HSV (hue, saturation - and value) or set a color name (the names are copied from from the - X11 color database). - - In addition to the RGB value, a QColor also has a pixel value and a - validity. The pixel value is used by the underlying window system - to refer to a color. It can be thought of as an index into the - display hardware's color table. - - The validity (isValid()) indicates whether the color is legal at - all. For example, a RGB color with RGB values out of range is - illegal. For performance reasons, QColor mostly disregards illegal - colors. The result of using an invalid color is unspecified and - will usually be surprising. - - There are 19 predefined QColor objects: \c white, \c black, \c - red, \c darkRed, \c green, \c darkGreen, \c blue, \c darkBlue, \c - cyan, \c darkCyan, \c magenta, \c darkMagenta, \c yellow, \c - darkYellow, \c gray, \c darkGray, \c lightGray, \c color0 and \c - color1, accessible as members of the Qt namespace (ie. \c Qt::red). - - \img qt-colors.png Qt Colors - - The colors \c color0 (zero pixel value) and \c color1 (non-zero - pixel value) are special colors for drawing in \link QBitmap - bitmaps\endlink. Painting with \c color0 sets the bitmap bits to 0 - (transparent, i.e. background), and painting with \c color1 sets the - bits to 1 (opaque, i.e. foreground). - - The QColor class has an efficient, dynamic color allocation - strategy. A color is normally allocated the first time it is used - (lazy allocation), that is, whenever the pixel() function is called: - - \list 1 - \i Is the pixel value valid? If it is, just return it; otherwise, - allocate a pixel value. - \i Check an internal hash table to see if we allocated an equal RGB - value earlier. If we did, set the pixel value and return. - \i Try to allocate the RGB value. If we succeed, we get a pixel value - that we save in the internal table with the RGB value. - Return the pixel value. - \i The color could not be allocated. Find the closest matching - color and save it in the internal table. - \endlist - - A color can be set by passing setNamedColor() an RGB string like - "#112233", or a color name, e.g. "blue". The names are taken from - X11's rgb.txt database but can also be used under Windows. To get - a lighter or darker color use light() and dark() respectively. - Colors can also be set using setRgb() and setHsv(). The color - components can be accessed in one go with rgb() and hsv(), or - individually with red(), green() and blue(). - - Use maxColors() and numBitPlanes() to determine the maximum number - of colors and the number of bit planes supported by the underlying - window system, - - If you need to allocate many colors temporarily, for example in an - image viewer application, enterAllocContext(), leaveAllocContext() and - destroyAllocContext() will prove useful. - - \section1 HSV Colors - - Because many people don't know the HSV color model very well, we'll - cover it briefly here. - - The RGB model is hardware-oriented. Its representation is close to - what most monitors show. In contrast, HSV represents color in a way - more suited to the human perception of color. For example, the - relationships "stronger than", "darker than" and "the opposite of" - are easily expressed in HSV but are much harder to express in RGB. - - HSV, like RGB, has three components: - - \list - - \i H, for hue, is either 0-359 if the color is chromatic (not - gray), or meaningless if it is gray. It represents degrees on the - color wheel familiar to most people. Red is 0 (degrees), green is - 120 and blue is 240. - - \i S, for saturation, is 0-255, and the bigger it is, the - stronger the color is. Grayish colors have saturation near 0; very - strong colors have saturation near 255. - - \i V, for value, is 0-255 and represents lightness or brightness - of the color. 0 is black; 255 is as far from black as possible. - - \endlist - - Here are some examples: Pure red is H=0, S=255, V=255. A dark red, - moving slightly towards the magenta, could be H=350 (equivalent to - -10), S=255, V=180. A grayish light red could have H about 0 (say - 350-359 or 0-10), S about 50-100, and S=255. - - Qt returns a hue value of -1 for achromatic colors. If you pass a - too-big hue value, Qt forces it into range. Hue 360 or 720 is - treated as 0; hue 540 is treated as 180. - - \sa QPalette, QColorGroup, QApplication::setColorSpec(), - \link http://www.inforamp.net/~poynton/Poynton-color.html Color FAQ\endlink -*/ - -/***************************************************************************** - Global colors - *****************************************************************************/ - -#define COLOR0_PIX 0 -#define COLOR1_PIX 1 - -static QColor stdcol[19]; - -QT_STATIC_CONST_IMPL QColor & Qt::color0 = stdcol[0]; -QT_STATIC_CONST_IMPL QColor & Qt::color1 = stdcol[1]; -QT_STATIC_CONST_IMPL QColor & Qt::black = stdcol[2]; -QT_STATIC_CONST_IMPL QColor & Qt::white = stdcol[3]; -QT_STATIC_CONST_IMPL QColor & Qt::darkGray = stdcol[4]; -QT_STATIC_CONST_IMPL QColor & Qt::gray = stdcol[5]; -QT_STATIC_CONST_IMPL QColor & Qt::lightGray = stdcol[6]; -QT_STATIC_CONST_IMPL QColor & Qt::red = stdcol[7]; -QT_STATIC_CONST_IMPL QColor & Qt::green = stdcol[8]; -QT_STATIC_CONST_IMPL QColor & Qt::blue = stdcol[9]; -QT_STATIC_CONST_IMPL QColor & Qt::cyan = stdcol[10]; -QT_STATIC_CONST_IMPL QColor & Qt::magenta = stdcol[11]; -QT_STATIC_CONST_IMPL QColor & Qt::yellow = stdcol[12]; -QT_STATIC_CONST_IMPL QColor & Qt::darkRed = stdcol[13]; -QT_STATIC_CONST_IMPL QColor & Qt::darkGreen = stdcol[14]; -QT_STATIC_CONST_IMPL QColor & Qt::darkBlue = stdcol[15]; -QT_STATIC_CONST_IMPL QColor & Qt::darkCyan = stdcol[16]; -QT_STATIC_CONST_IMPL QColor & Qt::darkMagenta = stdcol[17]; -QT_STATIC_CONST_IMPL QColor & Qt::darkYellow = stdcol[18]; - - -/***************************************************************************** - QColor member functions - *****************************************************************************/ - -bool QColor::color_init = false; // color system not initialized -bool QColor::globals_init = false; // global color not initialized -QColor::ColorModel QColor::colormodel = d32; - - -QColor* QColor::globalColors() -{ - return stdcol; -} - - -/*! - Initializes the global colors. This function is called if a global - color variable is initialized before the constructors for our - global color objects are executed. Without this mechanism, - assigning a color might assign an uninitialized value. - - Example: - \code - QColor myColor = red; // will initialize red etc. - - int main( int argc, char **argc ) - { - } - \endcode -*/ - -void QColor::initGlobalColors() -{ - globals_init = true; - - #ifdef Q_WS_X11 - // HACK: we need a way to recognize color0 and color1 uniquely, so - // that we can use color0 and color1 with fixed pixel values on - // all screens - stdcol[ 0].d.argb = qRgba(255, 255, 255, 1); - stdcol[ 1].d.argb = qRgba( 0, 0, 0, 1); - #else - stdcol[ 0].d.argb = qRgb(255,255,255); - stdcol[ 1].d.argb = 0; - #endif // Q_WS_X11 - stdcol[ 0].setPixel( COLOR0_PIX ); - stdcol[ 1].setPixel( COLOR1_PIX ); - - // From the "The Palette Manager: How and Why" by Ron Gery, March 23, - // 1992, archived on MSDN: - // The Windows system palette is broken up into two sections, - // one with fixed colors and one with colors that can be changed - // by applications. The system palette predefines 20 entries; - // these colors are known as the static or reserved colors and - // consist of the 16 colors found in the Windows version 3.0 VGA - // driver and 4 additional colors chosen for their visual appeal. - // The DEFAULT_PALETTE stock object is, as the name implies, the - // default palette selected into a device context (DC) and consists - // of these static colors. Applications can set the remaining 236 - // colors using the Palette Manager. - // The 20 reserved entries have indices in [0,9] and [246,255]. We - // reuse 17 of them. - stdcol[ 2].setRgb( 0, 0, 0 ); // index 0 black - stdcol[ 3].setRgb( 255, 255, 255 ); // index 255 white - stdcol[ 4].setRgb( 128, 128, 128 ); // index 248 medium gray - stdcol[ 5].setRgb( 160, 160, 164 ); // index 247 light gray - stdcol[ 6].setRgb( 192, 192, 192 ); // index 7 light gray - stdcol[ 7].setRgb( 255, 0, 0 ); // index 249 red - stdcol[ 8].setRgb( 0, 255, 0 ); // index 250 green - stdcol[ 9].setRgb( 0, 0, 255 ); // index 252 blue - stdcol[10].setRgb( 0, 255, 255 ); // index 254 cyan - stdcol[11].setRgb( 255, 0, 255 ); // index 253 magenta - stdcol[12].setRgb( 255, 255, 0 ); // index 251 yellow - stdcol[13].setRgb( 128, 0, 0 ); // index 1 dark red - stdcol[14].setRgb( 0, 128, 0 ); // index 2 dark green - stdcol[15].setRgb( 0, 0, 128 ); // index 4 dark blue - stdcol[16].setRgb( 0, 128, 128 ); // index 6 dark cyan - stdcol[17].setRgb( 128, 0, 128 ); // index 5 dark magenta - stdcol[18].setRgb( 128, 128, 0 ); // index 3 dark yellow -} - -/*! - \enum QColor::Spec - - The type of color specified, either RGB or HSV, e.g. in the - \c{QColor::QColor( x, y, z, colorSpec)} constructor. - - \value Rgb - \value Hsv -*/ - - -/*! - \fn QColor::QColor() - - Constructs an invalid color with the RGB value (0, 0, 0). An - invalid color is a color that is not properly set up for the - underlying window system. - - The alpha value of an invalid color is unspecified. - - \sa isValid() -*/ - - -/*! - \fn QColor::QColor( int r, int g, int b ) - - Constructs a color with the RGB value \a r, \a g, \a b, in the - same way as setRgb(). - - The color is left invalid if any or the arguments are illegal. - - \sa setRgb() -*/ - - -/*! - Constructs a color with the RGB value \a rgb and a custom pixel - value \a pixel. - - If \a pixel == 0xffffffff (the default), then the color uses the - RGB value in a standard way. If \a pixel is something else, then - the pixel value is set directly to \a pixel, skipping the normal - allocation procedure. -*/ - -QColor::QColor( QRgb rgb, uint pixel ) -{ - if ( pixel == 0xffffffff ) { - setRgb( rgb ); - } else { - d.argb = rgb; - setPixel( pixel ); - } -} - -void QColor::setPixel( uint pixel ) -{ - switch ( colormodel ) { - case d8: - d.d8.direct = true; - d.d8.invalid = false; - d.d8.dirty = false; - d.d8.pix = pixel; - break; - case d32: - d.d32.pix = pixel; - break; - } -} - - -/*! - Constructs a color with the RGB or HSV value \a x, \a y, \a z. - - The arguments are an RGB value if \a colorSpec is QColor::Rgb. \a - x (red), \a y (green), and \a z (blue). All of them must be in the - range 0-255. - - The arguments are an HSV value if \a colorSpec is QColor::Hsv. \a - x (hue) must be -1 for achromatic colors and 0-359 for chromatic - colors; \a y (saturation) and \a z (value) must both be in the - range 0-255. - - \sa setRgb(), setHsv() -*/ - -QColor::QColor( int x, int y, int z, Spec colorSpec ) -{ - d.d32.argb = Invalid; - d.d32.pix = Dirt; - if ( colorSpec == Hsv ) - setHsv( x, y, z ); - else - setRgb( x, y, z ); -} - - -/*! - Constructs a named color in the same way as setNamedColor() using - name \a name. - - The color is left invalid if \a name cannot be parsed. - - \sa setNamedColor() -*/ - -#if 0 -QColor::QColor( const QString& name ) -{ - setNamedColor( name ); -} -#endif - -/*! - Constructs a named color in the same way as setNamedColor() using - name \a name. - - The color is left invalid if \a name cannot be parsed. - - \sa setNamedColor() -*/ - -QColor::QColor( const char *name ) -{ -#if 0 - setNamedColor( QString(name) ); -#else - setNamedColor( name ); -#endif -} - - -/*! - Constructs a color that is a copy of \a c. -*/ - -QColor::QColor( const QColor &c ) -{ - if ( !globals_init ) - initGlobalColors(); - d.argb = c.d.argb; - d.d32.pix = c.d.d32.pix; -} - - -/*! - Assigns a copy of the color \a c and returns a reference to this - color. -*/ - -QColor &QColor::operator=( const QColor &c ) -{ - if ( !globals_init ) - initGlobalColors(); - d.argb = c.d.argb; - d.d32.pix = c.d.d32.pix; - return *this; -} - - -/*! - \fn bool QColor::isValid() const - - Returns false if the color is invalid, i.e. it was constructed using the - default constructor; otherwise returns true. -*/ - -/*! - \internal -*/ -bool QColor::isDirty() const -{ - if ( colormodel == d8 ) { - return d.d8.dirty; - } else { - return d.d32.probablyDirty(); - } -} - -/*! - Returns the name of the color in the format "#RRGGBB", i.e. a "#" - character followed by three two-digit hexadecimal numbers. - - \sa setNamedColor() -*/ - -#if 0 -QString QColor::name() const -{ -#ifndef QT_NO_SPRINTF - QString s; - s.sprintf( "#%02x%02x%02x", red(), green(), blue() ); - return s; -#else - char s[20]; - sprintf( s, "#%02x%02x%02x", red(), green(), blue() ); - return QString(s); -#endif -} -#endif - -#if 0 -static int hex2int( QChar hexchar ) -{ - int v; - if ( hexchar.isDigit() ) - v = hexchar.digitValue(); - else if ( hexchar >= 'A' && hexchar <= 'F' ) - v = hexchar.cell() - 'A' + 10; - else if ( hexchar >= 'a' && hexchar <= 'f' ) - v = hexchar.cell() - 'a' + 10; - else - v = -1; - return v; -} -#else -static int hex2int( char hexchar ) -{ - int v; - if ( hexchar >= '0' && hexchar <= '9' ) - v = hexchar - '0'; - else if ( hexchar >= 'A' && hexchar <= 'F' ) - v = hexchar - 'A' + 10; - else if ( hexchar >= 'a' && hexchar <= 'f' ) - v = hexchar - 'a' + 10; - else - v = -1; - return v; -} -#endif - -/*! - Sets the RGB value to \a name, which may be in one of these - formats: - \list - \i #RGB (each of R, G and B is a single hex digit) - \i #RRGGBB - \i #RRRGGGBBB - \i #RRRRGGGGBBBB - \i A name from the X color database (rgb.txt) (e.g. - "steelblue" or "gainsboro"). These color names also work - under Windows. - \endlist - - The color is invalid if \a name cannot be parsed. -*/ - -#if 0 -void QColor::setNamedColor( const QString &name ) -#else -void QColor::setNamedColor( const char* name ) -#endif -{ -#if 0 - if ( name.isEmpty() ) { -#else - if ( name == NULL || strlen( name ) == 0 ) { -#endif - d.argb = 0; - if ( colormodel == d8 ) { - d.d8.invalid = true; - } else { - d.d32.argb = Invalid; - } - } else if ( name[0] == '#' ) { -#if 0 - const QChar *p = name.unicode()+1; - int len = name.length()-1; -#else - const char *p = name+1; - int len = strlen(name)-1; -#endif - int r, g, b; - if ( len == 12 ) { - r = (hex2int(p[0]) << 4) + hex2int(p[1]); - g = (hex2int(p[4]) << 4) + hex2int(p[5]); - b = (hex2int(p[8]) << 4) + hex2int(p[9]); - } else if ( len == 9 ) { - r = (hex2int(p[0]) << 4) + hex2int(p[1]); - g = (hex2int(p[3]) << 4) + hex2int(p[4]); - b = (hex2int(p[6]) << 4) + hex2int(p[7]); - } else if ( len == 6 ) { - r = (hex2int(p[0]) << 4) + hex2int(p[1]); - g = (hex2int(p[2]) << 4) + hex2int(p[3]); - b = (hex2int(p[4]) << 4) + hex2int(p[5]); - } else if ( len == 3 ) { - r = (hex2int(p[0]) << 4) + hex2int(p[0]); - g = (hex2int(p[1]) << 4) + hex2int(p[1]); - b = (hex2int(p[2]) << 4) + hex2int(p[2]); - } else { - r = g = b = -1; - } - if ( (uint)r > 255 || (uint)g > 255 || (uint)b > 255 ) { - d.d32.argb = Invalid; - d.d32.pix = Dirt; -#if defined(QT_CHECK_RANGE) - qWarning( "QColor::setNamedColor: could not parse color '%s'", - name.local8Bit().data() ); -#endif - } else { - setRgb( r, g, b ); - } - } else { - setSystemNamedColor( name ); - } -} - -#undef max -#undef min - -/*! - \fn void QColor::getHsv( int &h, int &s, int &v ) const - \obsolete -*/ - -/*! \fn void QColor::getHsv( int *h, int *s, int *v ) const - - Returns the current RGB value as HSV. The contents of the \a h, \a - s and \a v pointers are set to the HSV values. If any of the three - pointers are null, the function does nothing. - - The hue (which \a h points to) is set to -1 if the color is - achromatic. - - \warning Colors are stored internally as RGB values, so getHSv() - may return slightly different values to those set by setHsv(). - - \sa setHsv(), rgb() -*/ - -/*! \obsolete Use getHsv() instead. - */ -void QColor::hsv( int *h, int *s, int *v ) const -{ - if ( !h || !s || !v ) - return; - int r = qRed(d.argb); - int g = qGreen(d.argb); - int b = qBlue(d.argb); - uint max = r; // maximum RGB component - int whatmax = 0; // r=>0, g=>1, b=>2 - if ( (uint)g > max ) { - max = g; - whatmax = 1; - } - if ( (uint)b > max ) { - max = b; - whatmax = 2; - } - uint min = r; // find minimum value - if ( (uint)g < min ) min = g; - if ( (uint)b < min ) min = b; - int delta = max-min; - *v = max; // calc value - *s = max ? (510*delta+max)/(2*max) : 0; - if ( *s == 0 ) { - *h = -1; // undefined hue - } else { - switch ( whatmax ) { - case 0: // red is max component - if ( g >= b ) - *h = (120*(g-b)+delta)/(2*delta); - else - *h = (120*(g-b+delta)+delta)/(2*delta) + 300; - break; - case 1: // green is max component - if ( b > r ) - *h = 120 + (120*(b-r)+delta)/(2*delta); - else - *h = 60 + (120*(b-r+delta)+delta)/(2*delta); - break; - case 2: // blue is max component - if ( r > g ) - *h = 240 + (120*(r-g)+delta)/(2*delta); - else - *h = 180 + (120*(r-g+delta)+delta)/(2*delta); - break; - } - } -} - - -/*! - Sets a HSV color value. \a h is the hue, \a s is the saturation - and \a v is the value of the HSV color. - - If \a s or \a v are not in the range 0-255, or \a h is < -1, the - color is not changed. - - \warning Colors are stored internally as RGB values, so getHSv() - may return slightly different values to those set by setHsv(). - - \sa hsv(), setRgb() -*/ - -void QColor::setHsv( int h, int s, int v ) -{ - if ( h < -1 || (uint)s > 255 || (uint)v > 255 ) { -#if defined(QT_CHECK_RANGE) - qWarning( "QColor::setHsv: HSV parameters out of range" ); -#endif - return; - } - int r=v, g=v, b=v; - if ( s == 0 || h == -1 ) { // achromatic case - // Ignore - } else { // chromatic case - if ( (uint)h >= 360 ) - h %= 360; - uint f = h%60; - h /= 60; - uint p = (uint)(2*v*(255-s)+255)/510; - uint q, t; - if ( h&1 ) { - q = (uint)(2*v*(15300-s*f)+15300)/30600; - switch( h ) { - case 1: r=(int)q; g=(int)v, b=(int)p; break; - case 3: r=(int)p; g=(int)q, b=(int)v; break; - case 5: r=(int)v; g=(int)p, b=(int)q; break; - } - } else { - t = (uint)(2*v*(15300-(s*(60-f)))+15300)/30600; - switch( h ) { - case 0: r=(int)v; g=(int)t, b=(int)p; break; - case 2: r=(int)p; g=(int)v, b=(int)t; break; - case 4: r=(int)t; g=(int)p, b=(int)v; break; - } - } - } - setRgb( r, g, b ); -} - - -/*! - \fn QRgb QColor::rgb() const - - Returns the RGB value. - - The return type \e QRgb is equivalent to \c unsigned \c int. - - For an invalid color, the alpha value of the returned color is - unspecified. - - \sa setRgb(), hsv(), qRed(), qBlue(), qGreen(), isValid() -*/ - -/*! \fn void QColor::getRgb( int *r, int *g, int *b ) const - - Sets the contents pointed to by \a r, \a g and \a b to the red, - green and blue components of the RGB value respectively. The value - range for a component is 0..255. - - \sa rgb(), setRgb(), getHsv() -*/ - -/*! \obsolete Use getRgb() instead */ -void QColor::rgb( int *r, int *g, int *b ) const -{ - *r = qRed(d.argb); - *g = qGreen(d.argb); - *b = qBlue(d.argb); -} - - -/*! - Sets the RGB value to \a r, \a g, \a b. The arguments, \a r, \a g - and \a b must all be in the range 0..255. If any of them are - outside the legal range, the color is not changed. - - \sa rgb(), setHsv() -*/ - -void QColor::setRgb( int r, int g, int b ) -{ - if ( (uint)r > 255 || (uint)g > 255 || (uint)b > 255 ) { -#if defined(QT_CHECK_RANGE) - qWarning( "QColor::setRgb: RGB parameter(s) out of range" ); -#endif - return; - } - d.argb = qRgb( r, g, b ); - if ( colormodel == d8 ) { - d.d8.invalid = false; - d.d8.direct = false; - d.d8.dirty = true; - } else { - d.d32.pix = Dirt; - } -} - - -/*! - \overload - Sets the RGB value to \a rgb. - - The type \e QRgb is equivalent to \c unsigned \c int. - - \sa rgb(), setHsv() -*/ - -void QColor::setRgb( QRgb rgb ) -{ - d.argb = rgb; - if ( colormodel == d8 ) { - d.d8.invalid = false; - d.d8.direct = false; - d.d8.dirty = true; - } else { - d.d32.pix = Dirt; - } -} - -/*! - \fn int QColor::red() const - - Returns the R (red) component of the RGB value. -*/ - - -/*! - \fn int QColor::green() const - - Returns the G (green) component of the RGB value. -*/ - -/*! - \fn int QColor::blue() const - - Returns the B (blue) component of the RGB value. -*/ - - -/*! - Returns a lighter (or darker) color, but does not change this - object. - - Returns a lighter color if \a factor is greater than 100. Setting - \a factor to 150 returns a color that is 50% brighter. - - Returns a darker color if \a factor is less than 100. We recommend - using dark() for this purpose. If \a factor is 0 or negative, the - return value is unspecified. - - (This function converts the current RGB color to HSV, multiplies V - by \a factor, and converts the result back to RGB.) - - \sa dark() -*/ - -QColor QColor::light( int factor ) const -{ - if ( factor <= 0 ) // invalid lightness factor - return *this; - else if ( factor < 100 ) // makes color darker - return dark( 10000/factor ); - - int h, s, v; - hsv( &h, &s, &v ); - v = (factor*v)/100; - if ( v > 255 ) { // overflow - s -= v-255; // adjust saturation - if ( s < 0 ) - s = 0; - v = 255; - } - QColor c; - c.setHsv( h, s, v ); - return c; -} - - -/*! - Returns a darker (or lighter) color, but does not change this - object. - - Returns a darker color if \a factor is greater than 100. Setting - \a factor to 300 returns a color that has one-third the - brightness. - - Returns a lighter color if \a factor is less than 100. We - recommend using lighter() for this purpose. If \a factor is 0 or - negative, the return value is unspecified. - - (This function converts the current RGB color to HSV, divides V by - \a factor and converts back to RGB.) - - \sa light() -*/ - -QColor QColor::dark( int factor ) const -{ - if ( factor <= 0 ) // invalid darkness factor - return *this; - else if ( factor < 100 ) // makes color lighter - return light( 10000/factor ); - int h, s, v; - hsv( &h, &s, &v ); - v = (v*100)/factor; - QColor c; - c.setHsv( h, s, v ); - return c; -} - - -/*! - \fn bool QColor::operator==( const QColor &c ) const - - Returns true if this color has the same RGB value as \a c; - otherwise returns false. -*/ - -/*! - \fn bool QColor::operator!=( const QColor &c ) const - Returns true if this color has a different RGB value from \a c; - otherwise returns false. -*/ - -/*! - Returns the pixel value. - - This value is used by the underlying window system to refer to a - color. It can be thought of as an index into the display - hardware's color table, but the value is an arbitrary 32-bit - value. - - \sa alloc() -*/ -uint QColor::pixel() const -{ - if ( isDirty() ) - return ((QColor*)this)->alloc(); - else if ( colormodel == d8 ) - return d.d8.pix; - else - return d.d32.pix; -} - -/*! - \fn QStringList QColor::colorNames() - Returns a QStringList containing the color names Qt knows about. -*/ - -/***************************************************************************** - QColor stream functions - *****************************************************************************/ -#ifndef QT_NO_DATASTREAM -/*! - \relates QColor - Writes a color object, \a c to the stream, \a s. - - \sa \link datastreamformat.html Format of the QDataStream operators \endlink -*/ - -QDataStream &operator<<( QDataStream &s, const QColor &c ) -{ - quint32 p = (quint32)c.rgb(); - if ( s.version() == 1 ) // Swap red and blue - p = ((p << 16) & 0xff0000) | ((p >> 16) & 0xff) | (p & 0xff00ff00); - return s << p; -} - -/*! - \relates QColor - Reads a color object, \a c, from the stream, \a s. - - \sa \link datastreamformat.html Format of the QDataStream operators \endlink -*/ - -QDataStream &operator>>( QDataStream &s, QColor &c ) -{ - quint32 p; - s >> p; - if ( s.version() == 1 ) // Swap red and blue - p = ((p << 16) & 0xff0000) | ((p >> 16) & 0xff) | (p & 0xff00ff00); - c.setRgb( p ); - return s; -} -#endif - -/***************************************************************************** - QColor global functions (documentation only) - *****************************************************************************/ - -/*! - \fn int qRed( QRgb rgb ) - \relates QColor - - Returns the red component of the RGB triplet \a rgb. - \sa qRgb(), QColor::red() -*/ - -/*! - \fn int qGreen( QRgb rgb ) - \relates QColor - - Returns the green component of the RGB triplet \a rgb. - \sa qRgb(), QColor::green() -*/ - -/*! - \fn int qBlue( QRgb rgb ) - \relates QColor - - Returns the blue component of the RGB triplet \a rgb. - \sa qRgb(), QColor::blue() -*/ - -/*! - \fn int qAlpha( QRgb rgba ) - \relates QColor - - Returns the alpha component of the RGBA quadruplet \a rgba. - */ - -/*! - \fn QRgb qRgb( int r, int g, int b ) - \relates QColor - - Returns the RGB triplet \a (r,g,b). - - The return type QRgb is equivalent to \c unsigned \c int. - - \sa qRgba(), qRed(), qGreen(), qBlue() -*/ - -/*! - \fn QRgb qRgba( int r, int g, int b, int a ) - \relates QColor - - Returns the RGBA quadruplet \a (r,g,b,a). - - The return type QRgba is equivalent to \c unsigned \c int. - - \sa qRgb(), qRed(), qGreen(), qBlue() -*/ - -/*! - \fn int qGray( int r, int g, int b ) - \relates QColor - - Returns a gray value 0..255 from the (\a r, \a g, \a b) triplet. - - The gray value is calculated using the formula (r*11 + g*16 + - b*5)/32. -*/ - -/*! - \overload int qGray( qRgb rgb ) - \relates QColor - - Returns a gray value 0..255 from the given \a rgb colour. -*/ diff --git a/ksplash/ksplashx/qcolor.h b/ksplash/ksplashx/qcolor.h deleted file mode 100644 index 9952dbfe..00000000 --- a/ksplash/ksplashx/qcolor.h +++ /dev/null @@ -1,236 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Definition of QColor class -** -** Created : 940112 -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef QCOLOR_H -#define QCOLOR_H - -#ifndef QT_H -#include "qwindowdefs.h" -//##include "qstringlist.h" -#endif // QT_H - -const QRgb RGB_MASK = 0x00ffffff; // masks RGB values - -Q_EXPORT inline int qRed( QRgb rgb ) // get red part of RGB -{ return (int)((rgb >> 16) & 0xff); } - -Q_EXPORT inline int qGreen( QRgb rgb ) // get green part of RGB -{ return (int)((rgb >> 8) & 0xff); } - -Q_EXPORT inline int qBlue( QRgb rgb ) // get blue part of RGB -{ return (int)(rgb & 0xff); } - -Q_EXPORT inline int qAlpha( QRgb rgb ) // get alpha part of RGBA -{ return (int)((rgb >> 24) & 0xff); } - -Q_EXPORT inline QRgb qRgb( int r, int g, int b )// set RGB value -{ return (0xff << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); } - -Q_EXPORT inline QRgb qRgba( int r, int g, int b, int a )// set RGBA value -{ return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); } - -Q_EXPORT inline int qGray( int r, int g, int b )// convert R,G,B to gray 0..255 -{ return (r*11+g*16+b*5)/32; } - -Q_EXPORT inline int qGray( QRgb rgb ) // convert RGB to gray 0..255 -{ return qGray( qRed(rgb), qGreen(rgb), qBlue(rgb) ); } - - -class Q_EXPORT QColor -{ -public: - enum Spec { Rgb, Hsv }; - - QColor(); - QColor( int r, int g, int b ); - QColor( int x, int y, int z, Spec ); - explicit QColor( QRgb rgb, uint pixel=0xffffffff); -#if 0 - QColor( const QString& name ); -#endif - explicit QColor( const char *name ); - QColor( const QColor & ); - QColor &operator=( const QColor & ); - - bool isValid() const; - bool isDirty() const; -#if 0 - QString name() const; - void setNamedColor( const QString& name ); -#else - void setNamedColor( const char* name ); -#endif - - QRgb rgb() const; - void setRgb( int r, int g, int b ); - void setRgb( QRgb rgb ); - void getRgb( int *r, int *g, int *b ) const { rgb( r, g, b ); } - void rgb( int *r, int *g, int *b ) const; // obsolete - - int red() const; - int green() const; - int blue() const; - - void setHsv( int h, int s, int v ); - void getHsv( int *h, int *s, int *v ) const { hsv( h, s, v ); } - void hsv( int *h, int *s, int *v ) const; // obsolete - void getHsv( int &h, int &s, int &v ) const { hsv( &h, &s, &v ); } // obsolete - - QColor light( int f = 150 ) const; - QColor dark( int f = 200 ) const; - - bool operator==( const QColor &c ) const; - bool operator!=( const QColor &c ) const; - - uint alloc(); - uint pixel() const; - -#if defined(Q_WS_X11) - // ### in 4.0, make this take a default argument of -1 for default screen? - uint alloc( int screen ); - uint pixel( int screen ) const; -#endif - - static int maxColors(); - static int numBitPlanes(); - - static int enterAllocContext(); - static void leaveAllocContext(); - static int currentAllocContext(); - static void destroyAllocContext( int ); - - - static void initialize(); - static void cleanup(); -#ifndef QT_NO_STRINGLIST - static QStringList colorNames(); -#endif - enum { Dirt = 0x44495254, Invalid = 0x49000000 }; - -private: -#if 0 - void setSystemNamedColor( const QString& name ); -#else - void setSystemNamedColor( const char* name ); -#endif - void setPixel( uint pixel ); - static void initGlobalColors(); - static uint argbToPix32(QRgb); - static QColor* globalColors(); - static bool color_init; - static bool globals_init; - static enum ColorModel { d8, d32 } colormodel; - union { - QRgb argb; - struct D8 { - QRgb argb; - uchar pix; - uchar invalid; - uchar dirty; - uchar direct; - } d8; - struct D32 { - QRgb argb; - uint pix; - bool invalid() const { return argb == QColor::Invalid && pix == QColor::Dirt; } - bool probablyDirty() const { return pix == QColor::Dirt; } - } d32; - } d; -}; - - -inline QColor::QColor() -{ d.d32.argb = Invalid; d.d32.pix = Dirt; } - -inline QColor::QColor( int r, int g, int b ) -{ - d.d32.argb = Invalid; - d.d32.pix = Dirt; - setRgb( r, g, b ); -} - -inline QRgb QColor::rgb() const -{ return d.argb; } - -inline int QColor::red() const -{ return qRed(d.argb); } - -inline int QColor::green() const -{ return qGreen(d.argb); } - -inline int QColor::blue() const -{ return qBlue(d.argb); } - -inline bool QColor::isValid() const -{ - if ( colormodel == d8 ) - return !d.d8.invalid; - else - return !d.d32.invalid(); -} - -inline bool QColor::operator==( const QColor &c ) const -{ - return d.argb == c.d.argb && isValid() == c.isValid(); -} - -inline bool QColor::operator!=( const QColor &c ) const -{ - return !operator==(c); -} - - -/***************************************************************************** - QColor stream functions - *****************************************************************************/ - -#ifndef QT_NO_DATASTREAM -Q_EXPORT QDataStream &operator<<( QDataStream &, const QColor & ); -Q_EXPORT QDataStream &operator>>( QDataStream &, QColor & ); -#endif - -#endif // QCOLOR_H diff --git a/ksplash/ksplashx/qcolor_p.cpp b/ksplash/ksplashx/qcolor_p.cpp deleted file mode 100644 index bfb4a9c8..00000000 --- a/ksplash/ksplashx/qcolor_p.cpp +++ /dev/null @@ -1,820 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Named color support for non-X platforms. -** The color names have been borrowed from X. -** -** Created : 000228 -** -** Copyright (C) 2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "qglobal.h" -#if defined(Q_CC_BOR) -// needed for qsort() because of a std namespace problem on Borland -#include "qplatformdefs.h" -#endif - -#include "qcolor.h" - -#ifndef QT_NO_COLORNAMES - -#include -#include -#include - -#undef QRGB -#define QRGB(r,g,b) (r*65536 + g*256 + b) - -const int rgbTblSize = 657; - -static int qstricmp( const char *str1, const char *str2 ) -{ - const uchar *s1 = (const uchar *)str1; - const uchar *s2 = (const uchar *)str2; - int res; - uchar c; - if ( !s1 || !s2 ) - return s1 ? 1 : ( s2 ? -1 : 0 ); - for ( ; !(res = (c=tolower(*s1)) - tolower(*s2)); s1++, s2++ ) - if ( !c ) // strings are equal - break; - return res; -} - -static const struct RGBData { - uint value; - const char *name; -} rgbTbl[] = { - { 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" }, - { QRGB(207,207,207), "grey81" }, - { QRGB(209,209,209), "grey82" }, - { QRGB(212,212,212), "grey83" }, - { QRGB(214,214,214), "grey84" }, - { QRGB(217,217,217), "grey85" }, - { QRGB(219,219,219), "grey86" }, - { QRGB(222,222,222), "grey87" }, - { QRGB(224,224,224), "grey88" }, - { QRGB(227,227,227), "grey89" }, - { QRGB( 23, 23, 23), "grey9" }, - { QRGB(229,229,229), "grey90" }, - { QRGB(232,232,232), "grey91" }, - { QRGB(235,235,235), "grey92" }, - { QRGB(237,237,237), "grey93" }, - { QRGB(240,240,240), "grey94" }, - { QRGB(242,242,242), "grey95" }, - { QRGB(245,245,245), "grey96" }, - { QRGB(247,247,247), "grey97" }, - { QRGB(250,250,250), "grey98" }, - { QRGB(252,252,252), "grey99" }, - { QRGB(240,255,240), "honeydew" }, - { QRGB(240,255,240), "honeydew1" }, - { QRGB(224,238,224), "honeydew2" }, - { QRGB(193,205,193), "honeydew3" }, - { QRGB(131,139,131), "honeydew4" }, - { QRGB(255,105,180), "hotpink" }, - { QRGB(255,110,180), "hotpink1" }, - { QRGB(238,106,167), "hotpink2" }, - { QRGB(205, 96,144), "hotpink3" }, - { QRGB(139, 58, 98), "hotpink4" }, - { QRGB(205, 92, 92), "indianred" }, - { QRGB(255,106,106), "indianred1" }, - { QRGB(238, 99, 99), "indianred2" }, - { QRGB(205, 85, 85), "indianred3" }, - { QRGB(139, 58, 58), "indianred4" }, - { QRGB(255,255,240), "ivory" }, - { QRGB(255,255,240), "ivory1" }, - { QRGB(238,238,224), "ivory2" }, - { QRGB(205,205,193), "ivory3" }, - { QRGB(139,139,131), "ivory4" }, - { QRGB(240,230,140), "khaki" }, - { QRGB(255,246,143), "khaki1" }, - { QRGB(238,230,133), "khaki2" }, - { QRGB(205,198,115), "khaki3" }, - { QRGB(139,134, 78), "khaki4" }, - { QRGB(230,230,250), "lavender" }, - { QRGB(255,240,245), "lavenderblush" }, - { QRGB(255,240,245), "lavenderblush1" }, - { QRGB(238,224,229), "lavenderblush2" }, - { QRGB(205,193,197), "lavenderblush3" }, - { QRGB(139,131,134), "lavenderblush4" }, - { QRGB(124,252, 0), "lawngreen" }, - { QRGB(255,250,205), "lemonchiffon" }, - { QRGB(255,250,205), "lemonchiffon1" }, - { QRGB(238,233,191), "lemonchiffon2" }, - { QRGB(205,201,165), "lemonchiffon3" }, - { QRGB(139,137,112), "lemonchiffon4" }, - { QRGB(173,216,230), "lightblue" }, - { QRGB(191,239,255), "lightblue1" }, - { QRGB(178,223,238), "lightblue2" }, - { QRGB(154,192,205), "lightblue3" }, - { QRGB(104,131,139), "lightblue4" }, - { QRGB(240,128,128), "lightcoral" }, - { QRGB(224,255,255), "lightcyan" }, - { QRGB(224,255,255), "lightcyan1" }, - { QRGB(209,238,238), "lightcyan2" }, - { QRGB(180,205,205), "lightcyan3" }, - { QRGB(122,139,139), "lightcyan4" }, - { QRGB(238,221,130), "lightgoldenrod" }, - { QRGB(255,236,139), "lightgoldenrod1" }, - { QRGB(238,220,130), "lightgoldenrod2" }, - { QRGB(205,190,112), "lightgoldenrod3" }, - { QRGB(139,129, 76), "lightgoldenrod4" }, - { QRGB(250,250,210), "lightgoldenrodyellow" }, - { QRGB(211,211,211), "lightgray" }, - { QRGB(144,238,144), "lightgreen" }, - { QRGB(211,211,211), "lightgrey" }, - { QRGB(255,182,193), "lightpink" }, - { QRGB(255,174,185), "lightpink1" }, - { QRGB(238,162,173), "lightpink2" }, - { QRGB(205,140,149), "lightpink3" }, - { QRGB(139, 95,101), "lightpink4" }, - { QRGB(255,160,122), "lightsalmon" }, - { QRGB(255,160,122), "lightsalmon1" }, - { QRGB(238,149,114), "lightsalmon2" }, - { QRGB(205,129, 98), "lightsalmon3" }, - { QRGB(139, 87, 66), "lightsalmon4" }, - { QRGB( 32,178,170), "lightseagreen" }, - { QRGB(135,206,250), "lightskyblue" }, - { QRGB(176,226,255), "lightskyblue1" }, - { QRGB(164,211,238), "lightskyblue2" }, - { QRGB(141,182,205), "lightskyblue3" }, - { QRGB( 96,123,139), "lightskyblue4" }, - { QRGB(132,112,255), "lightslateblue" }, - { QRGB(119,136,153), "lightslategray" }, - { QRGB(119,136,153), "lightslategrey" }, - { QRGB(176,196,222), "lightsteelblue" }, - { QRGB(202,225,255), "lightsteelblue1" }, - { QRGB(188,210,238), "lightsteelblue2" }, - { QRGB(162,181,205), "lightsteelblue3" }, - { QRGB(110,123,139), "lightsteelblue4" }, - { QRGB(255,255,224), "lightyellow" }, - { QRGB(255,255,224), "lightyellow1" }, - { QRGB(238,238,209), "lightyellow2" }, - { QRGB(205,205,180), "lightyellow3" }, - { QRGB(139,139,122), "lightyellow4" }, - { QRGB( 50,205, 50), "limegreen" }, - { QRGB(250,240,230), "linen" }, - { QRGB(255, 0,255), "magenta" }, - { QRGB(255, 0,255), "magenta1" }, - { QRGB(238, 0,238), "magenta2" }, - { QRGB(205, 0,205), "magenta3" }, - { QRGB(139, 0,139), "magenta4" }, - { QRGB(176, 48, 96), "maroon" }, - { QRGB(255, 52,179), "maroon1" }, - { QRGB(238, 48,167), "maroon2" }, - { QRGB(205, 41,144), "maroon3" }, - { QRGB(139, 28, 98), "maroon4" }, - { QRGB(102,205,170), "mediumaquamarine" }, - { QRGB( 0, 0,205), "mediumblue" }, - { QRGB(186, 85,211), "mediumorchid" }, - { QRGB(224,102,255), "mediumorchid1" }, - { QRGB(209, 95,238), "mediumorchid2" }, - { QRGB(180, 82,205), "mediumorchid3" }, - { QRGB(122, 55,139), "mediumorchid4" }, - { QRGB(147,112,219), "mediumpurple" }, - { QRGB(171,130,255), "mediumpurple1" }, - { QRGB(159,121,238), "mediumpurple2" }, - { QRGB(137,104,205), "mediumpurple3" }, - { QRGB( 93, 71,139), "mediumpurple4" }, - { QRGB( 60,179,113), "mediumseagreen" }, - { QRGB(123,104,238), "mediumslateblue" }, - { QRGB( 0,250,154), "mediumspringgreen" }, - { QRGB( 72,209,204), "mediumturquoise" }, - { QRGB(199, 21,133), "mediumvioletred" }, - { QRGB( 25, 25,112), "midnightblue" }, - { QRGB(245,255,250), "mintcream" }, - { QRGB(255,228,225), "mistyrose" }, - { QRGB(255,228,225), "mistyrose1" }, - { QRGB(238,213,210), "mistyrose2" }, - { QRGB(205,183,181), "mistyrose3" }, - { QRGB(139,125,123), "mistyrose4" }, - { QRGB(255,228,181), "moccasin" }, - { QRGB(255,222,173), "navajowhite" }, - { QRGB(255,222,173), "navajowhite1" }, - { QRGB(238,207,161), "navajowhite2" }, - { QRGB(205,179,139), "navajowhite3" }, - { QRGB(139,121, 94), "navajowhite4" }, - { QRGB( 0, 0,128), "navy" }, - { QRGB( 0, 0,128), "navyblue" }, - { QRGB(253,245,230), "oldlace" }, - { QRGB(107,142, 35), "olivedrab" }, - { QRGB(192,255, 62), "olivedrab1" }, - { QRGB(179,238, 58), "olivedrab2" }, - { QRGB(154,205, 50), "olivedrab3" }, - { QRGB(105,139, 34), "olivedrab4" }, - { QRGB(255,165, 0), "orange" }, - { QRGB(255,165, 0), "orange1" }, - { QRGB(238,154, 0), "orange2" }, - { QRGB(205,133, 0), "orange3" }, - { QRGB(139, 90, 0), "orange4" }, - { QRGB(255, 69, 0), "orangered" }, - { QRGB(255, 69, 0), "orangered1" }, - { QRGB(238, 64, 0), "orangered2" }, - { QRGB(205, 55, 0), "orangered3" }, - { QRGB(139, 37, 0), "orangered4" }, - { QRGB(218,112,214), "orchid" }, - { QRGB(255,131,250), "orchid1" }, - { QRGB(238,122,233), "orchid2" }, - { QRGB(205,105,201), "orchid3" }, - { QRGB(139, 71,137), "orchid4" }, - { QRGB(238,232,170), "palegoldenrod" }, - { QRGB(152,251,152), "palegreen" }, - { QRGB(154,255,154), "palegreen1" }, - { QRGB(144,238,144), "palegreen2" }, - { QRGB(124,205,124), "palegreen3" }, - { QRGB( 84,139, 84), "palegreen4" }, - { QRGB(175,238,238), "paleturquoise" }, - { QRGB(187,255,255), "paleturquoise1" }, - { QRGB(174,238,238), "paleturquoise2" }, - { QRGB(150,205,205), "paleturquoise3" }, - { QRGB(102,139,139), "paleturquoise4" }, - { QRGB(219,112,147), "palevioletred" }, - { QRGB(255,130,171), "palevioletred1" }, - { QRGB(238,121,159), "palevioletred2" }, - { QRGB(205,104,137), "palevioletred3" }, - { QRGB(139, 71, 93), "palevioletred4" }, - { QRGB(255,239,213), "papayawhip" }, - { QRGB(255,218,185), "peachpuff" }, - { QRGB(255,218,185), "peachpuff1" }, - { QRGB(238,203,173), "peachpuff2" }, - { QRGB(205,175,149), "peachpuff3" }, - { QRGB(139,119,101), "peachpuff4" }, - { QRGB(205,133, 63), "peru" }, - { QRGB(255,192,203), "pink" }, - { QRGB(255,181,197), "pink1" }, - { QRGB(238,169,184), "pink2" }, - { QRGB(205,145,158), "pink3" }, - { QRGB(139, 99,108), "pink4" }, - { QRGB(221,160,221), "plum" }, - { QRGB(255,187,255), "plum1" }, - { QRGB(238,174,238), "plum2" }, - { QRGB(205,150,205), "plum3" }, - { QRGB(139,102,139), "plum4" }, - { QRGB(176,224,230), "powderblue" }, - { QRGB(160, 32,240), "purple" }, - { QRGB(155, 48,255), "purple1" }, - { QRGB(145, 44,238), "purple2" }, - { QRGB(125, 38,205), "purple3" }, - { QRGB( 85, 26,139), "purple4" }, - { QRGB(255, 0, 0), "red" }, - { QRGB(255, 0, 0), "red1" }, - { QRGB(238, 0, 0), "red2" }, - { QRGB(205, 0, 0), "red3" }, - { QRGB(139, 0, 0), "red4" }, - { QRGB(188,143,143), "rosybrown" }, - { QRGB(255,193,193), "rosybrown1" }, - { QRGB(238,180,180), "rosybrown2" }, - { QRGB(205,155,155), "rosybrown3" }, - { QRGB(139,105,105), "rosybrown4" }, - { QRGB( 65,105,225), "royalblue" }, - { QRGB( 72,118,255), "royalblue1" }, - { QRGB( 67,110,238), "royalblue2" }, - { QRGB( 58, 95,205), "royalblue3" }, - { QRGB( 39, 64,139), "royalblue4" }, - { QRGB(139, 69, 19), "saddlebrown" }, - { QRGB(250,128,114), "salmon" }, - { QRGB(255,140,105), "salmon1" }, - { QRGB(238,130, 98), "salmon2" }, - { QRGB(205,112, 84), "salmon3" }, - { QRGB(139, 76, 57), "salmon4" }, - { QRGB(244,164, 96), "sandybrown" }, - { QRGB( 46,139, 87), "seagreen" }, - { QRGB( 84,255,159), "seagreen1" }, - { QRGB( 78,238,148), "seagreen2" }, - { QRGB( 67,205,128), "seagreen3" }, - { QRGB( 46,139, 87), "seagreen4" }, - { QRGB(255,245,238), "seashell" }, - { QRGB(255,245,238), "seashell1" }, - { QRGB(238,229,222), "seashell2" }, - { QRGB(205,197,191), "seashell3" }, - { QRGB(139,134,130), "seashell4" }, - { QRGB(160, 82, 45), "sienna" }, - { QRGB(255,130, 71), "sienna1" }, - { QRGB(238,121, 66), "sienna2" }, - { QRGB(205,104, 57), "sienna3" }, - { QRGB(139, 71, 38), "sienna4" }, - { QRGB(135,206,235), "skyblue" }, - { QRGB(135,206,255), "skyblue1" }, - { QRGB(126,192,238), "skyblue2" }, - { QRGB(108,166,205), "skyblue3" }, - { QRGB( 74,112,139), "skyblue4" }, - { QRGB(106, 90,205), "slateblue" }, - { QRGB(131,111,255), "slateblue1" }, - { QRGB(122,103,238), "slateblue2" }, - { QRGB(105, 89,205), "slateblue3" }, - { QRGB( 71, 60,139), "slateblue4" }, - { QRGB(112,128,144), "slategray" }, - { QRGB(198,226,255), "slategray1" }, - { QRGB(185,211,238), "slategray2" }, - { QRGB(159,182,205), "slategray3" }, - { QRGB(108,123,139), "slategray4" }, - { QRGB(112,128,144), "slategrey" }, - { QRGB(255,250,250), "snow" }, - { QRGB(255,250,250), "snow1" }, - { QRGB(238,233,233), "snow2" }, - { QRGB(205,201,201), "snow3" }, - { QRGB(139,137,137), "snow4" }, - { QRGB( 0,255,127), "springgreen" }, - { QRGB( 0,255,127), "springgreen1" }, - { QRGB( 0,238,118), "springgreen2" }, - { QRGB( 0,205,102), "springgreen3" }, - { QRGB( 0,139, 69), "springgreen4" }, - { QRGB( 70,130,180), "steelblue" }, - { QRGB( 99,184,255), "steelblue1" }, - { QRGB( 92,172,238), "steelblue2" }, - { QRGB( 79,148,205), "steelblue3" }, - { QRGB( 54,100,139), "steelblue4" }, - { QRGB(210,180,140), "tan" }, - { QRGB(255,165, 79), "tan1" }, - { QRGB(238,154, 73), "tan2" }, - { QRGB(205,133, 63), "tan3" }, - { QRGB(139, 90, 43), "tan4" }, - { QRGB(216,191,216), "thistle" }, - { QRGB(255,225,255), "thistle1" }, - { QRGB(238,210,238), "thistle2" }, - { QRGB(205,181,205), "thistle3" }, - { QRGB(139,123,139), "thistle4" }, - { QRGB(255, 99, 71), "tomato" }, - { QRGB(255, 99, 71), "tomato1" }, - { QRGB(238, 92, 66), "tomato2" }, - { QRGB(205, 79, 57), "tomato3" }, - { QRGB(139, 54, 38), "tomato4" }, - { QRGB( 64,224,208), "turquoise" }, - { QRGB( 0,245,255), "turquoise1" }, - { QRGB( 0,229,238), "turquoise2" }, - { QRGB( 0,197,205), "turquoise3" }, - { QRGB( 0,134,139), "turquoise4" }, - { QRGB(238,130,238), "violet" }, - { QRGB(208, 32,144), "violetred" }, - { QRGB(255, 62,150), "violetred1" }, - { QRGB(238, 58,140), "violetred2" }, - { QRGB(205, 50,120), "violetred3" }, - { QRGB(139, 34, 82), "violetred4" }, - { QRGB(245,222,179), "wheat" }, - { QRGB(255,231,186), "wheat1" }, - { QRGB(238,216,174), "wheat2" }, - { QRGB(205,186,150), "wheat3" }, - { QRGB(139,126,102), "wheat4" }, - { QRGB(255,255,255), "white" }, - { QRGB(245,245,245), "whitesmoke" }, - { QRGB(255,255, 0), "yellow" }, - { QRGB(255,255, 0), "yellow1" }, - { QRGB(238,238, 0), "yellow2" }, - { QRGB(205,205, 0), "yellow3" }, - { QRGB(139,139, 0), "yellow4" }, - { QRGB(154,205, 50), "yellowgreen" } }; - -#if defined(Q_C_CALLBACKS) -extern "C" { -#endif - -#ifdef Q_OS_TEMP -static int __cdecl rgb_cmp( const void *d1, const void *d2 ) -#else -static int rgb_cmp( const void *d1, const void *d2 ) -#endif -{ - return qstricmp( ((RGBData *)d1)->name, ((RGBData *)d2)->name ); -} - -#if defined(Q_C_CALLBACKS) -} -#endif - -bool qt_get_named_rgb( const char *name, QRgb* rgb ) -{ - Q_LONG len = strlen(name)+1; - char *name_no_space = (char *)malloc(len); - for(Q_LONG o=0,i=0; i < len; i++) { - if(name[i] != '\t' && name[i] != ' ') - name_no_space[o++] = name[i]; - } - - RGBData x; - x.name = name_no_space; - // Function bsearch() is supposed to be - // void *bsearch(const void *key, const void *base, ... - // So why (char*)? Are there broken bsearch() declarations out there? - RGBData *r = (RGBData*)bsearch((char*)&x, (char*)rgbTbl, rgbTblSize, - sizeof(RGBData), rgb_cmp); - free(name_no_space); - if ( r ) { - *rgb = r->value; - return true; - } else { - return false; - } -} - -uint qt_get_rgb_val( const char *name ) -{ - QRgb r; - qt_get_named_rgb(name,&r); - return r; -} -#ifndef QT_NO_STRINGLIST -QStringList QColor::colorNames() -{ - int i = 0; - QStringList lst; - for ( i = 0; i < rgbTblSize; i++ ) - lst << rgbTbl[i].name; - - return lst; -} -#endif -#else - -bool qt_get_named_rgb( const char *, QRgb* ) -{ - return false; -} - -uint qt_get_rgb_val( const char * ) -{ - return 0; -} -#ifndef QT_NO_STRINGLIST -QStringList QColor::colorNames() -{ - return QStringList(); -} -#endif -#endif // QT_NO_COLORNAMES diff --git a/ksplash/ksplashx/qcolor_p.h b/ksplash/ksplashx/qcolor_p.h deleted file mode 100644 index 3743796b..00000000 --- a/ksplash/ksplashx/qcolor_p.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Named color support for non-X platforms. -** The color names have been borrowed from X. -** -** Created : 000228 -** -** Copyright (C) 2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef QCOLOR_P_H -#define QCOLOR_P_H - - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of qmenudata.cpp, qmenubar.cpp, qmenubar.cpp, qpopupmenu.cpp, -// qmotifstyle.cpp and qwindowssstyle.cpp. This header file may change -// from version to version without notice, or even be removed. -// -// We mean it. -// -// - -#ifndef QT_H -#endif // QT_H - -extern uint qt_get_rgb_val( const char *name ); -extern bool qt_get_named_rgb( const char *, QRgb* ); -extern void qt_reset_color_avail(); - -#endif diff --git a/ksplash/ksplashx/qcolor_x11.cpp b/ksplash/ksplashx/qcolor_x11.cpp deleted file mode 100644 index 76648518..00000000 --- a/ksplash/ksplashx/qcolor_x11.cpp +++ /dev/null @@ -1,863 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Implementation of QColor class for X11 -** -** Created : 940112 -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses for Unix/X11 may use this file in accordance with the Qt Commercial -** License Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "qcolor.h" -#include "qcolor_p.h" -//#include "string.h" -//#include "qpaintdevice.h" -//#include "qapplication.h" -//#include "qapplication_p.h" -//#include "qt_x11_p.h" -#include "x11_defs.h" -#include "string.h" - -int qt_ncols_option = 216; // used in qcolor_x11.cpp - -// NOT REVISED - -/***************************************************************************** - The color dictionary speeds up color allocation significantly for X11. - When there are no more colors, QColor::alloc() will set the colors_avail - flag to FALSE and try to find the nearest color. - NOTE: From deep within the event loop, the colors_avail flag is reset to - TRUE (calls the function qt_reset_color_avail()), because some other - application might free its colors, thereby making them available for - this Qt application. - *****************************************************************************/ - -//#include "qintdict.h" - -struct QColorData { - uint pix; // allocated pixel value - int context; // allocation context -}; - -#if 0 -typedef QIntDict QColorDict; -typedef QIntDictIterator QColorDictIt; -static const uint col_std_dict = 419; -static const uint col_large_dict = 18397; -#endif -static int current_alloc_context = 0; // current color alloc context - -class QColorScreenData { -public: - QColorScreenData() - { -//# colorDict = 0; - colors_avail = true; - g_vis = 0; - g_carr = 0; - g_carr_fetch = true; - g_cells = 0; - g_our_alloc = 0; - color_reduce = false; - } - -//# QColorDict *colorDict; // dict of allocated colors - bool colors_avail; // X colors available - bool g_truecolor; // truecolor visual - Visual *g_vis; // visual - XColor *g_carr; // color array - bool g_carr_fetch; // perform XQueryColors? - int g_cells; // number of entries in g_carr - bool *g_our_alloc; // our allocated colors - uint red_mask , green_mask , blue_mask; - int red_shift, green_shift, blue_shift; - bool color_reduce; - int col_div_r; - int col_div_g; - int col_div_b; -}; - -static int screencount = 0; -static QColorScreenData **screendata = 0; // array of screendata pointers - - -/* - This function is called from the event loop. It resets the colors_avail - flag so that the application can retry to allocate read-only colors - that other applications may have deallocated lately. - - The g_our_alloc and g_carr are global arrays that optimize color - approximation when there are no more colors left to allocate. -*/ - -void qt_reset_color_avail() -{ - int i; - for ( i = 0; i < screencount; i++ ) { - screendata[i]->colors_avail = true; - screendata[i]->g_carr_fetch = true; // do XQueryColors if !colors_avail - } -} - - -/* - Finds the nearest color. -*/ - -static int find_nearest_color( int r, int g, int b, int* mindist_out, - QColorScreenData *sd ) -{ - int mincol = -1; - int mindist = 200000; - int rx, gx, bx, dist; - XColor *xc = &sd->g_carr[0]; - for ( int i=0; ig_cells; i++ ) { - rx = r - (xc->red >> 8); - gx = g - (xc->green >> 8); - bx = b - (xc->blue>> 8); - dist = rx*rx + gx*gx + bx*bx; // calculate distance - if ( dist < mindist ) { // minimal? - mindist = dist; - mincol = i; - } - xc++; - } - *mindist_out = mindist; - return mincol; -} - - -/***************************************************************************** - QColor misc internal functions - *****************************************************************************/ - -static int highest_bit( uint v ) -{ - int i; - uint b = (uint)1 << 31; // get pos of highest bit in v - for ( i=31; ((b & v) == 0) && i>=0; i-- ) - b >>= 1; - return i; -} - - -/***************************************************************************** - QColor static member functions - *****************************************************************************/ - -/*! - Returns the maximum number of colors supported by the underlying - window system if the window system uses a palette. - - Otherwise returns -1. Use numBitPlanes() to calculate the available - colors in that case. -*/ - -int QColor::maxColors() -{ - Visual *visual = (Visual *) QPaintDevice::x11AppVisual(); - if (visual->c_class & 1) - return QPaintDevice::x11AppCells(); - return -1; -} - -/*! - Returns the number of color bit planes for the underlying window - system. - - The returned value is equal to the default pixmap depth. - - \sa QPixmap::defaultDepth() -*/ - -int QColor::numBitPlanes() -{ - return QPaintDevice::x11AppDepth(); -} - - -/*! - Internal initialization required for QColor. - This function is called from the QApplication constructor. - - \sa cleanup() -*/ - -void QColor::initialize() -{ - static const int blackIdx = 2; - static const int whiteIdx = 3; - - if ( color_init ) // already initialized - return; - color_init = true; - - Display *dpy = QPaintDevice::x11AppDisplay(); - int spec = QApplication::colorSpec(); - - screencount = ScreenCount( dpy ); - screendata = new QColorScreenData*[ screencount ]; - - int scr = QPaintDevice::x11AppScreen(); - - for ( scr = 0; scr < screencount; ++scr ) { - screendata[scr] = new QColorScreenData; - screendata[scr]->g_vis = (Visual *) QPaintDevice::x11AppVisual( scr ); - screendata[scr]->g_truecolor = screendata[scr]->g_vis->c_class == TrueColor; - - int ncols= QPaintDevice::x11AppCells( scr ); - - if ( screendata[scr]->g_truecolor ) { - colormodel = d32; - } else { - colormodel = d8; - // Create the g_our_alloc array, which remembers which color pixels - // we allocated. - screendata[scr]->g_cells = qMin(ncols,256); - screendata[scr]->g_carr = new XColor[screendata[scr]->g_cells]; - Q_CHECK_PTR( screendata[scr]->g_carr ); - memset( screendata[scr]->g_carr, 0, - screendata[scr]->g_cells*sizeof(XColor) ); - screendata[scr]->g_carr_fetch = true; // run XQueryColors on demand - screendata[scr]->g_our_alloc = new bool[screendata[scr]->g_cells]; - Q_CHECK_PTR( screendata[scr]->g_our_alloc ); - memset( screendata[scr]->g_our_alloc, false, - screendata[scr]->g_cells*sizeof(bool) ); - XColor *xc = &screendata[scr]->g_carr[0]; - for ( int i=0; ig_cells; i++ ) { - xc->pixel = i; // g_carr[i] = color i - xc++; - } - } - - if ( screendata[scr]->g_truecolor ) { // truecolor - screendata[scr]->red_mask = (uint)screendata[scr]->g_vis->red_mask; - screendata[scr]->green_mask = (uint)screendata[scr]->g_vis->green_mask; - screendata[scr]->blue_mask = (uint)screendata[scr]->g_vis->blue_mask; - screendata[scr]->red_shift = - highest_bit( screendata[scr]->red_mask ) - 7; - screendata[scr]->green_shift = - highest_bit( screendata[scr]->green_mask ) - 7; - screendata[scr]->blue_shift = - highest_bit( screendata[scr]->blue_mask ) - 7; - } - - if ( spec == (int)QApplication::ManyColor ) { - screendata[scr]->color_reduce = true; - - switch ( qt_ncols_option ) { - case 216: - // 6:6:6 - screendata[scr]->col_div_r = screendata[scr]->col_div_g = - screendata[scr]->col_div_b = (255/(6-1)); - break; - default: { - // 2:3:1 proportions, solved numerically - if ( qt_ncols_option > 255 ) qt_ncols_option = 255; - if ( qt_ncols_option < 1 ) qt_ncols_option = 1; - int nr = 2; - int ng = 2; - int nb = 2; - for (;;) { - if ( nb*2 < nr && (nb+1)*nr*ng < qt_ncols_option ) - nb++; - else if ( nr*3 < ng*2 && nb*(nr+1)*ng < qt_ncols_option ) - nr++; - else if ( nb*nr*(ng+1) < qt_ncols_option ) - ng++; - else break; - } - qt_ncols_option = nr*ng*nb; - screendata[scr]->col_div_r = (255/(nr-1)); - screendata[scr]->col_div_g = (255/(ng-1)); - screendata[scr]->col_div_b = (255/(nb-1)); - } - } - } - } - - scr = QPaintDevice::x11AppScreen(); - - // Initialize global color objects - if ( QPaintDevice::x11AppDefaultVisual(scr) && - QPaintDevice::x11AppDefaultColormap(scr) ) { - globalColors()[blackIdx].setPixel((uint) BlackPixel(dpy, scr)); - globalColors()[whiteIdx].setPixel((uint) WhitePixel(dpy, scr)); - } else { - globalColors()[blackIdx].alloc(scr); - globalColors()[whiteIdx].alloc(scr); - } - -#if 0 /* 0 == allocate colors on demand */ - setLazyAlloc( false ); // allocate global colors - ((QColor*)(&darkGray))-> alloc(); - ((QColor*)(&gray))-> alloc(); - ((QColor*)(&lightGray))-> alloc(); - ((QColor*)(&::red))-> alloc(); - ((QColor*)(&::green))-> alloc(); - ((QColor*)(&::blue))-> alloc(); - ((QColor*)(&cyan))-> alloc(); - ((QColor*)(&magenta))-> alloc(); - ((QColor*)(&yellow))-> alloc(); - ((QColor*)(&darkRed))-> alloc(); - ((QColor*)(&darkGreen))-> alloc(); - ((QColor*)(&darkBlue))-> alloc(); - ((QColor*)(&darkCyan))-> alloc(); - ((QColor*)(&darkMagenta))-> alloc(); - ((QColor*)(&darkYellow))-> alloc(); - setLazyAlloc( true ); -#endif -} - -/*! - Internal clean up required for QColor. - This function is called from the QApplication destructor. - - \sa initialize() -*/ - -void QColor::cleanup() -{ - if ( !color_init ) - return; - color_init = false; - int scr; - for ( scr = 0; scr < screencount; scr++ ) { - if ( screendata[scr]->g_carr ) { - delete [] screendata[scr]->g_carr; - screendata[scr]->g_carr = 0; - } - if ( screendata[scr]->g_our_alloc ) { - delete [] screendata[scr]->g_our_alloc; - screendata[scr]->g_our_alloc = 0; - } -#if 0 - if ( screendata[scr]->colorDict ) { - screendata[scr]->colorDict->setAutoDelete( true ); - screendata[scr]->colorDict->clear(); - delete screendata[scr]->colorDict; - screendata[scr]->colorDict = 0; - } -#endif - delete screendata[scr]; - screendata[scr] = 0; - } - delete [] screendata; - screendata = 0; - screencount = 0; -} - - -/***************************************************************************** - QColor member functions - *****************************************************************************/ - -/*! - \internal - Allocates the color on screen \a screen. Only used in X11. - - \sa alloc(), pixel() -*/ -uint QColor::alloc( int screen ) -{ - Display *dpy = QPaintDevice::x11AppDisplay(); - if ( screen < 0 ) - screen = QPaintDevice::x11AppScreen(); - if ( !color_init ) - return dpy ? (uint)BlackPixel(dpy, screen) : 0; - int r = qRed(d.argb); - int g = qGreen(d.argb); - int b = qBlue(d.argb); - uint pix = 0; - QColorScreenData *sd = screendata[screen]; - if ( sd->g_truecolor ) { // truecolor: map to pixel - r = sd->red_shift > 0 ? r << sd->red_shift : r >> -sd->red_shift; - g = sd->green_shift > 0 ? g << sd->green_shift : g >> -sd->green_shift; - b = sd->blue_shift > 0 ? b << sd->blue_shift : b >> -sd->blue_shift; - pix = (b & sd->blue_mask) | (g & sd->green_mask) | (r & sd->red_mask) - | ~(sd->blue_mask | sd->green_mask | sd->red_mask); - if ( screen == QPaintDevice::x11AppScreen() ) - d.d32.pix = pix; - return pix; - } -#if 0 - QColorData *c = sd->colorDict->find( (long)(d.argb) ); - if ( c ) { // found color in dictionary - pix = c->pix; - if ( screen == QPaintDevice::x11AppScreen() ) { - d.d8.invalid = false; // color ok - d.d8.dirty = false; - d.d8.pix = pix; // use same pixel value - if ( c->context != current_alloc_context ) { - c->context = 0; // convert to default context - sd->g_our_alloc[pix] = true; // reuse without XAllocColor - } - } - return pix; - } -#endif - - XColor col; - col.red = r << 8; - col.green = g << 8; - col.blue = b << 8; - - bool try_again = false; - bool try_alloc = !sd->color_reduce; - int try_count = 0; - - do { - // This loop is run until we manage to either allocate or - // find an approximate color, it stops after a few iterations. - - try_again = false; - - if ( try_alloc && sd->colors_avail && - XAllocColor(dpy, QPaintDevice::x11AppColormap( screen ),&col) ) { - // We could allocate the color - pix = (uint) col.pixel; - if ( screen == QPaintDevice::x11AppScreen() ) { - d.d8.pix = pix; - d.d8.invalid = false; - d.d8.dirty = false; - sd->g_carr[d.d8.pix] = col; // update color array - if ( current_alloc_context == 0 ) - sd->g_our_alloc[d.d8.pix] = true; // reuse without XAllocColor - } - } else { - // No available colors, or we did not want to allocate one - int i; - sd->colors_avail = false; // no more available colors - if ( sd->g_carr_fetch ) { // refetch color array - sd->g_carr_fetch = false; - XQueryColors( dpy, QPaintDevice::x11AppColormap( screen ), sd->g_carr, - sd->g_cells ); - } - int mindist; - i = find_nearest_color( r, g, b, &mindist, sd ); - - if ( mindist != 0 && !try_alloc ) { - // Not an exact match with an existing color - int rr = ((r+sd->col_div_r/2)/sd->col_div_r)*sd->col_div_r; - int rg = ((g+sd->col_div_g/2)/sd->col_div_g)*sd->col_div_g; - int rb = ((b+sd->col_div_b/2)/sd->col_div_b)*sd->col_div_b; - int rx = rr - r; - int gx = rg - g; - int bx = rb - b; - int dist = rx*rx + gx*gx + bx*bx; // calculate distance - if ( dist < mindist ) { - // reduced color is closer - try to alloc it - r = rr; - g = rg; - b = rb; - col.red = r << 8; - col.green = g << 8; - col.blue = b << 8; - try_alloc = true; - try_again = true; - sd->colors_avail = true; - continue; // Try alloc reduced color - } - } - - if ( i == -1 ) { // no nearest color?! - int unused, value; - hsv(&unused, &unused, &value); - if (value < 128) { // dark, use black - d.argb = qRgb(0,0,0); - pix = (uint)BlackPixel( dpy, screen ); - if ( screen == QPaintDevice::x11AppScreen() ) { - d.d8.invalid = false; - d.d8.dirty = false; - d.d8.pix = pix; - } - } else { // light, use white - d.argb = qRgb(0xff,0xff,0xff); - pix = (uint)WhitePixel( dpy, screen ); - if ( screen == QPaintDevice::x11AppScreen() ) { - d.d8.invalid = false; - d.d8.dirty = false; - d.d8.pix = pix; - } - } - return pix; - } - if ( sd->g_our_alloc[i] ) { // we've already allocated it - ; // i == g_carr[i].pixel - } else { - // Try to allocate existing color - col = sd->g_carr[i]; - if ( XAllocColor(dpy, QPaintDevice::x11AppColormap( screen ), &col) ) { - i = (uint)col.pixel; - sd->g_carr[i] = col; // update color array - if ( screen == QPaintDevice::x11AppScreen() ) { - if ( current_alloc_context == 0 ) - sd->g_our_alloc[i] = true; // only in the default context - } - } else { - // Oops, it's gone again - try_count++; - try_again = true; - sd->colors_avail = true; - sd->g_carr_fetch = true; - } - } - if ( !try_again ) { // got it - pix = (uint)sd->g_carr[i].pixel; - if ( screen == QPaintDevice::x11AppScreen() ) { - d.d8.invalid = false; - d.d8.dirty = false; - d.d8.pix = pix; // allocated X11 color - } - } - } - - } while ( try_again && try_count < 2 ); - - if ( try_again ) { // no hope of allocating color - int unused, value; - hsv(&unused, &unused, &value); - if (value < 128) { // dark, use black - d.argb = qRgb(0,0,0); - pix = (uint)BlackPixel( dpy, screen ); - if ( screen == QPaintDevice::x11AppScreen() ) { - d.d8.invalid = false; - d.d8.dirty = false; - d.d8.pix = pix; - } - } else { // light, use white - d.argb = qRgb(0xff,0xff,0xff); - pix = (uint)WhitePixel( dpy, screen ); - if ( screen == QPaintDevice::x11AppScreen() ) { - d.d8.invalid = false; - d.d8.dirty = false; - d.d8.pix = pix; - } - } - return pix; - } -#if 0 - // All colors outside context 0 must go into the dictionary - bool many = sd->colorDict->count() >= sd->colorDict->size() * 8; - if ( many && sd->colorDict->size() == col_std_dict ) { - sd->colorDict->resize( col_large_dict ); - } - if ( !many || current_alloc_context != 0 ) { - c = new QColorData; // insert into color dict - Q_CHECK_PTR( c ); - c->pix = pix; - c->context = current_alloc_context; - sd->colorDict->insert( (long)d.argb, c ); // store color in dict - } -#endif - return pix; -} - -/*! - Allocates the RGB color and returns the pixel value. - - Allocating a color means to obtain a pixel value from the RGB - specification. The pixel value is an index into the global color - table, but should be considered an arbitrary platform-dependent value. - - The pixel() function calls alloc() if necessary, so in general you - don't need to call this function. - - \sa enterAllocContext() -*/ -// ### 4.0 - remove me? -uint QColor::alloc() -{ - return alloc( -1 ); -} - -/*! - \overload - - Returns the pixel value for screen \a screen. - - This value is used by the underlying window system to refer to a color. - It can be thought of as an index into the display hardware's color table, - but the value is an arbitrary 32-bit value. - - \sa alloc() -*/ -uint QColor::pixel( int screen ) const -{ - if (screen != QPaintDevice::x11AppScreen() && - // don't allocate color0 or color1, they have fixed pixel - // values for all screens - d.argb != qRgba(255, 255, 255, 1) && d.argb != qRgba(0, 0, 0, 1)) - return ((QColor*)this)->alloc( screen ); - return pixel(); -} - -#if 0 -void QColor::setSystemNamedColor( const QString& name ) -#else -void QColor::setSystemNamedColor( const char* name ) -#endif -{ - // setSystemNamedColor should look up rgb values from the built in - // color tables first (see qcolor_p.cpp), and failing that, use - // the window system's interface for translating names to rgb values... - // we do this so that things like uic can load an XPM file with named colors - // and convert it to a png without having to use window system functions... -#if 0 - d.argb = qt_get_rgb_val( name.latin1() ); -#else - d.argb = qt_get_rgb_val( name ); -#endif - QRgb rgb; -#if 0 - if ( qt_get_named_rgb( name.latin1(), &rgb ) ) { -#else - if ( qt_get_named_rgb( name, &rgb ) ) { -#endif - setRgb( qRed(rgb), qGreen(rgb), qBlue(rgb) ); - if ( colormodel == d8 ) { - d.d8.invalid = false; - d.d8.dirty = true; - d.d8.pix = 0; - } else { - alloc(); - } - } else if ( !color_init ) { -#if defined(QT_CHECK_STATE) - qWarning( "QColor::setSystemNamedColor: Cannot perform this operation " - "because QApplication does not exist" ); -#endif - // set color to invalid - *this = QColor(); - } else { - XColor col, hw_col; - if ( XLookupColor(QPaintDevice::x11AppDisplay(), -#if 0 - QPaintDevice::x11AppColormap(), name.latin1(), -#else - QPaintDevice::x11AppColormap(), name, -#endif - &col, &hw_col) ) { - setRgb( col.red>>8, col.green>>8, col.blue>>8 ); - } else { - // set color to invalid - *this = QColor(); - } - } -} - -#define MAX_CONTEXTS 16 -static int context_stack[MAX_CONTEXTS]; -static int context_ptr = 0; - -static void init_context_stack() -{ - static bool did_init = false; - if ( !did_init ) { - did_init = true; - context_stack[0] = current_alloc_context = 0; - } -} - - -/*! - Enters a color allocation context and returns a non-zero unique - identifier. - - Color allocation contexts are useful for programs that need to - allocate many colors and throw them away later, like image - viewers. The allocation context functions work for true color - displays as well as for colormap displays, except that - QColor::destroyAllocContext() does nothing for true color. - - Example: - \code - QPixmap loadPixmap( QString fileName ) - { - static int alloc_context = 0; - if ( alloc_context ) - QColor::destroyAllocContext( alloc_context ); - alloc_context = QColor::enterAllocContext(); - QPixmap pm( fileName ); - QColor::leaveAllocContext(); - return pm; - } - \endcode - - The example code loads a pixmap from file. It frees up all colors - that were allocated the last time loadPixmap() was called. - - The initial/default context is 0. Qt keeps a list of colors - associated with their allocation contexts. You can call - destroyAllocContext() to get rid of all colors that were allocated - in a specific context. - - Calling enterAllocContext() enters an allocation context. The - allocation context lasts until you call leaveAllocContext(). - QColor has an internal stack of allocation contexts. Each call to - enterAllocContex() must have a corresponding leaveAllocContext(). - - \code - // context 0 active - int c1 = QColor::enterAllocContext(); // enter context c1 - // context c1 active - int c2 = QColor::enterAllocContext(); // enter context c2 - // context c2 active - QColor::leaveAllocContext(); // leave context c2 - // context c1 active - QColor::leaveAllocContext(); // leave context c1 - // context 0 active - // Now, free all colors that were allocated in context c2 - QColor::destroyAllocContext( c2 ); - \endcode - - You may also want to set the application's color specification. - See QApplication::setColorSpec() for more information. - - \sa leaveAllocContext(), currentAllocContext(), destroyAllocContext(), - QApplication::setColorSpec() -*/ - -int QColor::enterAllocContext() -{ - static int context_seq_no = 0; - init_context_stack(); - if ( context_ptr+1 == MAX_CONTEXTS ) { -#if defined(QT_CHECK_STATE) - qWarning( "QColor::enterAllocContext: Context stack overflow" ); -#endif - return 0; - } - current_alloc_context = context_stack[++context_ptr] = ++context_seq_no; - return current_alloc_context; -} - - -/*! - Leaves a color allocation context. - - See enterAllocContext() for a detailed explanation. - - \sa enterAllocContext(), currentAllocContext() -*/ - -void QColor::leaveAllocContext() -{ - init_context_stack(); - if ( context_ptr == 0 ) { -#if defined(QT_CHECK_STATE) - qWarning( "QColor::leaveAllocContext: Context stack underflow" ); -#endif - return; - } - current_alloc_context = context_stack[--context_ptr]; -} - - -/*! - Returns the current color allocation context. - - The default context is 0. - - \sa enterAllocContext(), leaveAllocContext() -*/ - -int QColor::currentAllocContext() -{ - return current_alloc_context; -} - - -/*! - Destroys a color allocation context, \e context. - - This function deallocates all colors that were allocated in the - specified \a context. If \a context == -1, it frees up all colors - that the application has allocated. If \a context == -2, it frees - up all colors that the application has allocated, except those in - the default context. - - The function does nothing for true color displays. - - \sa enterAllocContext(), alloc() -*/ - -void QColor::destroyAllocContext( int context ) -{ - init_context_stack(); - if ( !color_init ) - return; - - int screen; - for ( screen = 0; screen < screencount; ++screen ) { - if ( screendata[screen]->g_truecolor ) - continue; - -#if 1 - Q_UNUSED(context); -#else - ulong pixels[256]; - bool freeing[256]; - memset( freeing, false, screendata[screen]->g_cells*sizeof(bool) ); - QColorData *d; - QColorDictIt it( *screendata[screen]->colorDict ); - int i = 0; - uint rgbv; - while ( (d=it.current()) ) { - rgbv = (uint)it.currentKey(); - if ( (d->context || context==-1) && - (d->context == context || context < 0) ) { - if ( !screendata[screen]->g_our_alloc[d->pix] && !freeing[d->pix] ) { - // will free this color - pixels[i++] = d->pix; - freeing[d->pix] = true; - } - // remove from dict - screendata[screen]->colorDict->remove( (long)rgbv ); - } - ++it; - } - if ( i ) - XFreeColors( QPaintDevice::x11AppDisplay(), - QPaintDevice::x11AppColormap( screen ), - pixels, i, 0 ); -#endif - } -} diff --git a/ksplash/ksplashx/qdatastream.h b/ksplash/ksplashx/qdatastream.h deleted file mode 100644 index 22319352..00000000 --- a/ksplash/ksplashx/qdatastream.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -// Intentionally left empty. diff --git a/ksplash/ksplashx/qglobal.cpp b/ksplash/ksplashx/qglobal.cpp deleted file mode 100644 index 046f5404..00000000 --- a/ksplash/ksplashx/qglobal.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "qglobal.h" - -static bool si_alreadyDone = false; -static int si_wordSize; -static bool si_bigEndian; - -/*! - \relates QApplication - - Obtains information about the system. - - The system's word size in bits (typically 32) is returned in \a - *wordSize. The \a *bigEndian is set to TRUE if this is a big-endian - machine, or to FALSE if this is a little-endian machine. - - In debug mode, this function calls qFatal() with a message if the - computer is truly weird (i.e. different endianness for 16 bit and - 32 bit integers); in release mode it returns FALSE. -*/ - -bool qSysInfo( int *wordSize, bool *bigEndian ) -{ -#if defined(QT_CHECK_NULL) - Q_ASSERT( wordSize != 0 ); - Q_ASSERT( bigEndian != 0 ); -#endif - - if ( si_alreadyDone ) { // run it only once - *wordSize = si_wordSize; - *bigEndian = si_bigEndian; - return true; - } - - si_wordSize = 0; - Q_ULONG n = (Q_ULONG)(~0); - while ( n ) { // detect word size - si_wordSize++; - n /= 2; - } - *wordSize = si_wordSize; - - if ( *wordSize != 64 && - *wordSize != 32 && - *wordSize != 16 ) { // word size: 16, 32 or 64 -#if defined(QT_CHECK_RANGE) - qFatal( "qSysInfo: Unsupported system word size %d", *wordSize ); -#endif - return false; - } - if ( sizeof(Q_INT8) != 1 || sizeof(Q_INT16) != 2 || sizeof(Q_INT32) != 4 || - sizeof(Q_ULONG)*8 != si_wordSize || sizeof(float) != 4 || sizeof(double) != 8 ) { -#if defined(QT_CHECK_RANGE) - qFatal( "qSysInfo: Unsupported system data type size" ); -#endif - return false; - } - - bool be16, be32; // determine byte ordering - short ns = 0x1234; - int nl = 0x12345678; - - unsigned char *p = (unsigned char *)(&ns); // 16-bit integer - be16 = *p == 0x12; - - p = (unsigned char *)(&nl); // 32-bit integer - if ( p[0] == 0x12 && p[1] == 0x34 && p[2] == 0x56 && p[3] == 0x78 ) - be32 = true; - else - if ( p[0] == 0x78 && p[1] == 0x56 && p[2] == 0x34 && p[3] == 0x12 ) - be32 = false; - else - be32 = !be16; - - if ( be16 != be32 ) { // strange machine! -#if defined(QT_CHECK_RANGE) - qFatal( "qSysInfo: Inconsistent system byte order" ); -#endif - return false; - } - - *bigEndian = si_bigEndian = be32; - si_alreadyDone = true; - return true; -} diff --git a/ksplash/ksplashx/qglobal.h b/ksplash/ksplashx/qglobal.h deleted file mode 100644 index d8b5c740..00000000 --- a/ksplash/ksplashx/qglobal.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef QGLOBAL_H -#define QGLOBAL_H - -#include "defs.h" - -Q_EXPORT bool qSysInfo( int *wordSize, bool *bigEndian ); - -#endif diff --git a/ksplash/ksplashx/qimage.cpp b/ksplash/ksplashx/qimage.cpp deleted file mode 100644 index c100dc10..00000000 --- a/ksplash/ksplashx/qimage.cpp +++ /dev/null @@ -1,4866 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Implementation of QImage and QImageIO classes -** -** Created : 950207 -** -** Copyright (C) 1992-2003 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "qimage.h" -#include "qcolor.h" -//#include "qregexp.h" -//#include "qfile.h" -//#include "qdatastream.h" -//#include "qtextstream.h" -//#include "qbuffer.h" -//#include "qptrlist.h" -//#include "qasyncimageio.h" -//#include "qpngio.h" -//#include "qmap.h" -//#include -//#include "qimageformatinterface_p.h" -//#include "qwmatrix.h" -//#include "qapplication.h" -//#include "qmime.h" -//#include "qdragobject.h" -#include -#include -#include -#include -#include "qnamespace.h" -#include "x11_defs.h" - -#ifdef Q_WS_QWS -#include "qgfx_qws.h" -#endif - -// 16bpp images on supported on Qt/Embedded -#if !defined( Q_WS_QWS ) && !defined(QT_NO_IMAGE_16_BIT) -#define QT_NO_IMAGE_16_BIT -#endif - - -/*! - \class QImage - \brief The QImage class provides a hardware-independent pixmap - representation with direct access to the pixel data. - - \ingroup images - \ingroup graphics - \ingroup shared - \mainclass - - It is one of the two classes Qt provides for dealing with images, - the other being QPixmap. QImage is designed and optimized for I/O - and for direct pixel access/manipulation. QPixmap is designed and - optimized for drawing. There are (slow) functions to convert - between QImage and QPixmap: QPixmap::convertToImage() and - QPixmap::convertFromImage(). - - An image has the parameters \link width() width\endlink, \link - height() height\endlink and \link depth() depth\endlink (bits per - pixel, bpp), a color table and the actual \link bits() - pixels\endlink. QImage supports 1-bpp, 8-bpp and 32-bpp image - data. 1-bpp and 8-bpp images use a color lookup table; the pixel - value is a color table index. - - 32-bpp images encode an RGB value in 24 bits and ignore the color - table. The most significant byte is used for the \link - setAlphaBuffer() alpha buffer\endlink. - - An entry in the color table is an RGB triplet encoded as a \c - uint. Use the \link ::qRed() qRed()\endlink, \link ::qGreen() - qGreen()\endlink and \link ::qBlue() qBlue()\endlink functions (\c - qcolor.h) to access the components, and \link ::qRgb() - qRgb\endlink to make an RGB triplet (see the QColor class - documentation). - - 1-bpp (monochrome) images have a color table with a most two - colors. There are two different formats: big endian (MSB first) or - little endian (LSB first) bit order. To access a single bit you - will must do some bit shifts: - - \code - QImage image; - // sets bit at (x,y) to 1 - if ( image.bitOrder() == QImage::LittleEndian ) - *(image.scanLine(y) + (x >> 3)) |= 1 << (x & 7); - else - *(image.scanLine(y) + (x >> 3)) |= 1 << (7 - (x & 7)); - \endcode - - If this looks complicated, it might be a good idea to convert the - 1-bpp image to an 8-bpp image using convertDepth(). - - 8-bpp images are much easier to work with than 1-bpp images - because they have a single byte per pixel: - - \code - QImage image; - // set entry 19 in the color table to yellow - image.setColor( 19, qRgb(255,255,0) ); - // set 8 bit pixel at (x,y) to value yellow (in color table) - *(image.scanLine(y) + x) = 19; - \endcode - - 32-bpp images ignore the color table; instead, each pixel contains - the RGB triplet. 24 bits contain the RGB value; the most - significant byte is reserved for the alpha buffer. - - \code - QImage image; - // sets 32 bit pixel at (x,y) to yellow. - uint *p = (uint *)image.scanLine(y) + x; - *p = qRgb(255,255,0); - \endcode - - On Qt/Embedded, scanlines are aligned to the pixel depth and may - be padded to any degree, while on all other platforms, the - scanlines are 32-bit aligned for all depths. The constructor - taking a \c{uchar*} argument always expects 32-bit aligned data. - On Qt/Embedded, an additional constructor allows the number of - bytes-per-line to be specified. - - QImage supports a variety of methods for getting information about - the image, for example, colorTable(), allGray(), isGrayscale(), - bitOrder(), bytesPerLine(), depth(), dotsPerMeterX() and - dotsPerMeterY(), hasAlphaBuffer(), byteCount(), numColors(), and - width() and height(). - - Pixel colors are retrieved with pixel() and set with setPixel(). - - QImage also supports a number of functions for creating a new - image that is a transformed version of the original. For example, - copy(), convertBitOrder(), convertDepth(), createAlphaMask(), - createHeuristicMask(), mirror(), scale(), smoothScale(), swapRGB() - and xForm(). There are also functions for changing attributes of - an image in-place, for example, setAlphaBuffer(), setColor(), - setDotsPerMeterX() and setDotsPerMeterY() and setNumColors(). - - Images can be loaded and saved in the supported formats. Images - are saved to a file with save(). Images are loaded from a file - with load() (or in the constructor) or from an array of data with - loadFromData(). The lists of supported formats are available from - inputFormatList() and outputFormatList(). - - Strings of text may be added to images using setText(). - - The QImage class uses explicit \link shclass.html sharing\endlink, - similar to that used by QMemArray. - - New image formats can be added as \link plugins-howto.html - plugins\endlink. - - \sa QImageIO QPixmap \link shclass.html Shared Classes\endlink -*/ - - -/*! - \enum QImage::Endian - - This enum type is used to describe the endianness of the CPU and - graphics hardware. - - \value IgnoreEndian Endianness does not matter. Useful for some - operations that are independent of endianness. - \value BigEndian Network byte order, as on SPARC and Motorola CPUs. - \value LittleEndian PC/Alpha byte order. -*/ - -/*! - \enum Qt::ImageConversionFlags - - The conversion flag is a bitwise-OR of the following values. The - options marked "(default)" are set if no other values from the - list are included (since the defaults are zero): - - Color/Mono preference (ignored for QBitmap) - \value AutoColor (default) - If the image has \link - QImage::depth() depth\endlink 1 and contains only - black and white pixels, the pixmap becomes monochrome. - \value ColorOnly The pixmap is dithered/converted to the - \link QPixmap::defaultDepth() native display depth\endlink. - \value MonoOnly The pixmap becomes monochrome. If necessary, - it is dithered using the chosen dithering algorithm. - - Dithering mode preference for RGB channels - \value DiffuseDither (default) - A high-quality dither. - \value OrderedDither A faster, more ordered dither. - \value ThresholdDither No dithering; closest color is used. - - Dithering mode preference for alpha channel - \value ThresholdAlphaDither (default) - No dithering. - \value OrderedAlphaDither A faster, more ordered dither. - \value DiffuseAlphaDither A high-quality dither. - \value NoAlpha Not supported. - - Color matching versus dithering preference - \value PreferDither (default when converting to a pixmap) - Always dither - 32-bit images when the image is converted to 8 bits. - \value AvoidDither (default when converting for the purpose of saving to - file) - Dither 32-bit images only if the image has more than 256 - colors and it is being converted to 8 bits. - \value AutoDither Not supported. - - The following are not values that are used directly, but masks for - the above classes: - \value ColorMode_Mask Mask for the color mode. - \value Dither_Mask Mask for the dithering mode for RGB channels. - \value AlphaDither_Mask Mask for the dithering mode for the alpha channel. - \value DitherMode_Mask Mask for the mode that determines the preference of - color matching versus dithering. - - Using 0 as the conversion flag sets all the default options. -*/ - -#ifndef QT_NO_IMAGE_TEXT -class QImageDataMisc { -public: - QImageDataMisc() { } - QImageDataMisc( const QImageDataMisc& o ) : - text_lang(o.text_lang) { } - - QImageDataMisc& operator=(const QImageDataMisc& o) - { - text_lang = o.text_lang; - return *this; - } - QValueList list() - { - return text_lang.keys(); - } - - QStringList languages() - { - QStringList r; - QMap::Iterator it = text_lang.begin(); - for ( ; it != text_lang.end(); ++it ) { - r.remove( it.key().lang ); - r.append( it.key().lang ); - } - return r; - } - QStringList keys() - { - QStringList r; - QMap::Iterator it = text_lang.begin(); - for ( ; it != text_lang.end(); ++it ) { - r.remove( it.key().key ); - r.append( it.key().key ); - } - return r; - } - - QMap text_lang; -}; -#endif // QT_NO_IMAGE_TEXT - - - -/***************************************************************************** - QImage member functions - *****************************************************************************/ - -// table to flip bits -static const uchar bitflip[256] = { - /* - open OUT, "| fmt"; - for $i (0..255) { - print OUT (($i >> 7) & 0x01) | (($i >> 5) & 0x02) | - (($i >> 3) & 0x04) | (($i >> 1) & 0x08) | - (($i << 7) & 0x80) | (($i << 5) & 0x40) | - (($i << 3) & 0x20) | (($i << 1) & 0x10), ", "; - } - close OUT; - */ - 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, - 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, - 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, - 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, - 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, - 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, - 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, - 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, - 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, - 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, - 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, - 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, - 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, - 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, - 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, - 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255 -}; - -const uchar *qt_get_bitflip_array() // called from QPixmap code -{ - return bitflip; -} - - -/*! - Constructs a null image. - - \sa isNull() -*/ - -QImage::QImage() -{ - init(); -} - -/*! - Constructs an image with \a w width, \a h height, \a depth bits - per pixel, \a numColors colors and bit order \a bitOrder. - - Using this constructor is the same as first constructing a null - image and then calling the create() function. - - \sa create() -*/ - -QImage::QImage( int w, int h, int depth, int numColors, Endian bitOrder ) -{ - init(); - create( w, h, depth, numColors, bitOrder ); -} - -/*! - Constructs an image with size \a size pixels, depth \a depth bits, - \a numColors and \a bitOrder endianness. - - Using this constructor is the same as first constructing a null - image and then calling the create() function. - - \sa create() -*/ -QImage::QImage( const QSize& size, int depth, int numColors, Endian bitOrder ) -{ - init(); - create( size, depth, numColors, bitOrder ); -} - -#ifndef QT_NO_IMAGEIO -/*! - Constructs an image and tries to load the image from the file \a - fileName. - - If \a format is specified, the loader attempts to read the image - using the specified format. If \a format is not specified (which - is the default), the loader reads a few bytes from the header to - guess the file format. - - If the loading of the image failed, this object is a \link - isNull() null\endlink image. - - The QImageIO documentation lists the supported image formats and - explains how to add extra formats. - - \sa load() isNull() QImageIO -*/ - -QImage::QImage( const QString &fileName, const char* format ) -{ - init(); - load( fileName, format ); -} - -/*! - Constructs an image from \a xpm, which must be a valid XPM image. - - Errors are silently ignored. - - Note that it's possible to squeeze the XPM variable a little bit - by using an unusual declaration: - - \code - static const char * const start_xpm[]={ - "16 15 8 1", - "a c #cec6bd", - .... - \endcode - - The extra \c const makes the entire definition read-only, which is - slightly more efficient (e.g. when the code is in a shared - library) and ROMable when the application is to be stored in ROM. -*/ - -QImage::QImage( const char * const xpm[] ) -{ - init(); - // We use a qFatal rather than disabling the whole function, as this - // constructor may be ambiguous. - qFatal("XPM not supported"); -} - -/*! - Constructs an image from the binary data \a array. It tries to - guess the file format. - - If the loading of the image failed, this object is a \link - isNull() null\endlink image. - - \sa loadFromData() isNull() imageFormat() -*/ -QImage::QImage( const QByteArray &array ) -{ - init(); - loadFromData(array); -} -#endif //QT_NO_IMAGEIO - - -/*! - Constructs a \link shclass.html shallow copy\endlink of \a image. -*/ - -QImage::QImage( const QImage &image ) -{ - data = image.data; - data->ref(); -} - -/*! - Constructs an image \a w pixels wide, \a h pixels high with a - color depth of \a depth, that uses an existing memory buffer, \a - yourdata. The buffer must remain valid throughout the life of the - QImage. The image does not delete the buffer at destruction. - - If \a colortable is 0, a color table sufficient for \a numColors - will be allocated (and destructed later). - - Note that \a yourdata must be 32-bit aligned. - - The endianness is given in \a bitOrder. -*/ -QImage::QImage( uchar* yourdata, int w, int h, int depth, - QRgb* colortable, int numColors, - Endian bitOrder ) -{ - init(); - if ( w <= 0 || h <= 0 || depth <= 0 || numColors < 0 ) - return; // invalid parameter(s) - data->w = w; - data->h = h; - data->d = depth; - data->ncols = depth != 32 ? numColors : 0; - if ( !yourdata ) - return; // Image header info can be saved without needing to allocate memory. - int bpl = ((w*depth+31)/32)*4; // bytes per scanline - data->nbytes = bpl*h; - if ( colortable || !data->ncols ) { - data->ctbl = colortable; - data->ctbl_mine = false; - } else { - // calloc since we realloc, etc. later (ick) - data->ctbl = (QRgb*)calloc( data->ncols*sizeof(QRgb), data->ncols ); - data->ctbl_mine = true; - } - uchar** jt = (uchar**)malloc(h*sizeof(uchar*)); - for (int j=0; jbits = jt; - data->bitordr = bitOrder; -} - -#ifdef Q_WS_QWS - -/*! - Constructs an image that uses an existing memory buffer. The - buffer must remain valid for the life of the QImage. The image - does not delete the buffer at destruction. The buffer is passed as - \a yourdata. The image's width is \a w and its height is \a h. The - color depth is \a depth. \a bpl specifies the number of bytes per - line. - - If \a colortable is 0, a color table sufficient for \a numColors - will be allocated (and destructed later). - - The endianness is specified by \a bitOrder. - - \warning This constructor is only available on Qt/Embedded. -*/ -QImage::QImage( uchar* yourdata, int w, int h, int depth, - int bpl, QRgb* colortable, int numColors, - Endian bitOrder ) -{ - init(); - if ( !yourdata || w <= 0 || h <= 0 || depth <= 0 || numColors < 0 ) - return; // invalid parameter(s) - data->w = w; - data->h = h; - data->d = depth; - data->ncols = numColors; - data->nbytes = bpl * h; - if ( colortable || !numColors ) { - data->ctbl = colortable; - data->ctbl_mine = false; - } else { - // calloc since we realloc, etc. later (ick) - data->ctbl = (QRgb*)calloc( numColors*sizeof(QRgb), numColors ); - data->ctbl_mine = true; - } - uchar** jt = (uchar**)malloc(h*sizeof(uchar*)); - for (int j=0; jbits = jt; - data->bitordr = bitOrder; -} -#endif // Q_WS_QWS - -/*! - Destroys the image and cleans up. -*/ - -QImage::~QImage() -{ - if ( data && data->deref() ) { - reset(); - delete data; - } -} - - - - -/*! Convenience function. Gets the data associated with the absolute - name \a abs_name from the default mime source factory and decodes it - to an image. - - \sa QMimeSourceFactory, QImage::fromMimeSource(), QImageDrag::decode() -*/ -#ifndef QT_NO_MIME -QImage QImage::fromMimeSource( const QString &abs_name ) -{ - const QMimeSource *m = QMimeSourceFactory::defaultFactory()->data( abs_name ); - if ( !m ) { -#if defined(QT_CHECK_STATE) - qWarning("QImage::fromMimeSource: Cannot find image \"%s\" in the mime source factory", abs_name.latin1() ); -#endif - return QImage(); - } - QImage img; - QImageDrag::decode( m, img ); - return img; -} -#endif - - -/*! - Assigns a \link shclass.html shallow copy\endlink of \a image to - this image and returns a reference to this image. - - \sa copy() -*/ - -QImage &QImage::operator=( const QImage &image ) -{ - image.data->ref(); // avoid 'x = x' - if ( data->deref() ) { - reset(); - delete data; - } - data = image.data; - return *this; -} - -/*! - \overload - - Sets the image bits to the \a pixmap contents and returns a - reference to the image. - - If the image shares data with other images, it will first - dereference the shared data. - - Makes a call to QPixmap::convertToImage(). -*/ - -#if 0 -QImage &QImage::operator=( const QPixmap &pixmap ) -{ - *this = pixmap.convertToImage(); - return *this; -} -#endif - -/*! - Detaches from shared image data and makes sure that this image is - the only one referring to the data. - - If multiple images share common data, this image makes a copy of - the data and detaches itself from the sharing mechanism. - Nothing is done if there is just a single reference. - - \sa copy() -*/ - -void QImage::detach() -{ - if ( data->count != 1 ) - *this = copy(); -} - -/*! - Returns a \link shclass.html deep copy\endlink of the image. - - \sa detach() -*/ - -QImage QImage::copy() const -{ - if ( isNull() ) { - // maintain the fields of invalid QImages when copied - return QImage( 0, width(), height(), depth(), colorTable(), numColors(), bitOrder() ); - } else { - QImage image; - image.create( width(), height(), depth(), numColors(), bitOrder() ); -#ifdef Q_WS_QWS - // Qt/Embedded can create images with non-default bpl - // make sure we don't crash. - if ( image.byteCount() != byteCount() ) - for ( int i = 0; i < height(); i++ ) - memcpy( image.scanLine(i), scanLine(i), image.bytesPerLine() ); - else -#endif - memcpy( image.bits(), bits(), byteCount() ); - memcpy( image.colorTable(), colorTable(), numColors() * sizeof(QRgb) ); - image.setAlphaBuffer( hasAlphaBuffer() ); - image.data->dpmx = dotsPerMeterX(); - image.data->dpmy = dotsPerMeterY(); - image.data->offset = offset(); -#ifndef QT_NO_IMAGE_TEXT - if ( data->misc ) { - image.data->misc = new QImageDataMisc; - *image.data->misc = misc(); - } -#endif - return image; - } -} - -/*! - \overload - - Returns a \link shclass.html deep copy\endlink of a sub-area of - the image. - - The returned image is always \a w by \a h pixels in size, and is - copied from position \a x, \a y in this image. In areas beyond - this image pixels are filled with pixel 0. - - If the image needs to be modified to fit in a lower-resolution - result (e.g. converting from 32-bit to 8-bit), use the \a - conversion_flags to specify how you'd prefer this to happen. - - \sa bitBlt() Qt::ImageConversionFlags -*/ - -QImage QImage::copy(int x, int y, int w, int h, int conversion_flags) const -{ - int dx = 0; - int dy = 0; - if ( w <= 0 || h <= 0 ) return QImage(); // Nothing to copy - - QImage image( w, h, depth(), numColors(), bitOrder() ); - - if ( x < 0 || y < 0 || x + w > width() || y + h > height() ) { - // bitBlt will not cover entire image - clear it. - // ### should deal with each side separately for efficiency - image.fill(0); - if ( x < 0 ) { - dx = -x; - x = 0; - } - if ( y < 0 ) { - dy = -y; - y = 0; - } - } - - bool has_alpha = hasAlphaBuffer(); - if ( has_alpha ) { - // alpha channel should be only copied, not used by bitBlt(), and - // this is mutable, we will restore the image state before returning - QImage *that = (QImage *) this; - that->setAlphaBuffer( false ); - } - memcpy( image.colorTable(), colorTable(), numColors()*sizeof(QRgb) ); - bitBlt( &image, dx, dy, this, x, y, -1, -1, conversion_flags ); - if ( has_alpha ) { - // restore image state - QImage *that = (QImage *) this; - that->setAlphaBuffer( true ); - } - image.setAlphaBuffer(hasAlphaBuffer()); - image.data->dpmx = dotsPerMeterX(); - image.data->dpmy = dotsPerMeterY(); - image.data->offset = offset(); -#ifndef QT_NO_IMAGE_TEXT - if ( data->misc ) { - image.data->misc = new QImageDataMisc; - *image.data->misc = misc(); - } -#endif - return image; -} - -/*! - \overload QImage QImage::copy(const QRect& r) const - - Returns a \link shclass.html deep copy\endlink of a sub-area of - the image. - - The returned image always has the size of the rectangle \a r. In - areas beyond this image pixels are filled with pixel 0. -*/ - -/*! - \fn bool QImage::isNull() const - - Returns true if it is a null image; otherwise returns FALSE. - - A null image has all parameters set to zero and no allocated data. -*/ - - -/*! - \fn int QImage::width() const - - Returns the width of the image. - - \sa height() size() rect() -*/ - -/*! - \fn int QImage::height() const - - Returns the height of the image. - - \sa width() size() rect() -*/ - -/*! - \fn QSize QImage::size() const - - Returns the size of the image, i.e. its width and height. - - \sa width() height() rect() -*/ - -/*! - \fn QRect QImage::rect() const - - Returns the enclosing rectangle (0, 0, width(), height()) of the - image. - - \sa width() height() size() -*/ - -/*! - \fn int QImage::depth() const - - Returns the depth of the image. - - The image depth is the number of bits used to encode a single - pixel, also called bits per pixel (bpp) or bit planes of an image. - - The supported depths are 1, 8, 16 (Qt/Embedded only) and 32. - - \sa convertDepth() -*/ - -/*! - \fn int QImage::numColors() const - - Returns the size of the color table for the image. - - Notice that numColors() returns 0 for 16-bpp (Qt/Embedded only) - and 32-bpp images because these images do not use color tables, - but instead encode pixel values as RGB triplets. - - \sa setNumColors() colorTable() -*/ - -/*! - \fn QImage::Endian QImage::bitOrder() const - - Returns the bit order for the image. - - If it is a 1-bpp image, this function returns either - QImage::BigEndian or QImage::LittleEndian. - - If it is not a 1-bpp image, this function returns - QImage::IgnoreEndian. - - \sa depth() -*/ - -/*! - \fn uchar **QImage::jumpTable() const - - Returns a pointer to the scanline pointer table. - - This is the beginning of the data block for the image. - - \sa bits() scanLine() -*/ - -/*! - \fn QRgb *QImage::colorTable() const - - Returns a pointer to the color table. - - \sa numColors() -*/ - -/*! - \fn int QImage::byteCount() const - - Returns the number of bytes occupied by the image data. - - \sa bytesPerLine() bits() -*/ - -/*! - \fn int QImage::bytesPerLine() const - - Returns the number of bytes per image scanline. This is equivalent - to byteCount()/height(). - - \sa byteCount() scanLine() -*/ - -/*! - \fn QRgb QImage::color( int i ) const - - Returns the color in the color table at index \a i. The first - color is at index 0. - - A color value is an RGB triplet. Use the \link ::qRed() - qRed()\endlink, \link ::qGreen() qGreen()\endlink and \link - ::qBlue() qBlue()\endlink functions (defined in \c qcolor.h) to - get the color value components. - - \sa setColor() numColors() QColor -*/ - -/*! - \fn void QImage::setColor( int i, QRgb c ) - - Sets a color in the color table at index \a i to \a c. - - A color value is an RGB triplet. Use the \link ::qRgb() - qRgb()\endlink function (defined in \c qcolor.h) to make RGB - triplets. - - \sa color() setNumColors() numColors() -*/ - -/*! - \fn uchar *QImage::scanLine( int i ) const - - Returns a pointer to the pixel data at the scanline with index \a - i. The first scanline is at index 0. - - The scanline data is aligned on a 32-bit boundary. - - \warning If you are accessing 32-bpp image data, cast the returned - pointer to \c{QRgb*} (QRgb has a 32-bit size) and use it to - read/write the pixel value. You cannot use the \c{uchar*} pointer - directly, because the pixel format depends on the byte order on - the underlying platform. Hint: use \link ::qRed() qRed()\endlink, - \link ::qGreen() qGreen()\endlink and \link ::qBlue() - qBlue()\endlink, etc. (qcolor.h) to access the pixels. - - \warning If you are accessing 16-bpp image data, you must handle - endianness yourself. (Qt/Embedded only) - - \sa bytesPerLine() bits() jumpTable() -*/ - -/*! - \fn uchar *QImage::bits() const - - Returns a pointer to the first pixel data. This is equivalent to - scanLine(0). - - \sa byteCount() scanLine() jumpTable() -*/ - - - -void QImage::warningIndexRange( const char *func, int i ) -{ -#if defined(QT_CHECK_RANGE) - qWarning( "QImage::%s: Index %d out of range", func, i ); -#else - Q_UNUSED( func ) - Q_UNUSED( i ) -#endif -} - - -/*! - Resets all image parameters and deallocates the image data. -*/ - -void QImage::reset() -{ - freeBits(); - setNumColors( 0 ); -#ifndef QT_NO_IMAGE_TEXT - delete data->misc; -#endif - reinit(); -} - - -/*! - Fills the entire image with the pixel value \a pixel. - - If the \link depth() depth\endlink of this image is 1, only the - lowest bit is used. If you say fill(0), fill(2), etc., the image - is filled with 0s. If you say fill(1), fill(3), etc., the image is - filled with 1s. If the depth is 8, the lowest 8 bits are used. - - If the depth is 32 and the image has no alpha buffer, the \a pixel - value is written to each pixel in the image. If the image has an - alpha buffer, only the 24 RGB bits are set and the upper 8 bits - (alpha value) are left unchanged. - - Note: QImage::pixel() returns the color of the pixel at the given - coordinates; QColor::pixel() returns the pixel value of the - underlying window system (essentially an index value), so normally - you will want to use QImage::pixel() to use a color from an - existing image or QColor::rgb() to use a specific color. - - \sa invertPixels() depth() hasAlphaBuffer() create() -*/ - -void QImage::fill( uint pixel ) -{ - if ( depth() == 1 || depth() == 8 ) { - if ( depth() == 1 ) { - if ( pixel & 1 ) - pixel = 0xffffffff; - else - pixel = 0; - } else { - uint c = pixel & 0xff; - pixel = c | ((c << 8) & 0xff00) | ((c << 16) & 0xff0000) | - ((c << 24) & 0xff000000); - } - int bpl = bytesPerLine(); - for ( int i=0; i // needed for systemBitOrder -#include -#include -#endif - -// POSIX Large File Support redefines open -> open64 -#if defined(open) -# undef open -#endif - -// POSIX Large File Support redefines truncate -> truncate64 -#if defined(truncate) -# undef truncate -#endif - -/*! - Determines the bit order of the display hardware. Returns - QImage::LittleEndian (LSB first) or QImage::BigEndian (MSB first). - - \sa systemByteOrder() -*/ - -QImage::Endian QImage::systemBitOrder() -{ -#if defined(Q_WS_X11) - return BitmapBitOrder(qt_xdisplay()) == MSBFirst ? BigEndian :LittleEndian; -#else - return BigEndian; -#endif -} - - -/*! - Resizes the color table to \a numColors colors. - - If the color table is expanded all the extra colors will be set to - black (RGB 0,0,0). - - \sa numColors() color() setColor() colorTable() -*/ - -void QImage::setNumColors( int numColors ) -{ - if ( numColors == data->ncols ) - return; - if ( numColors == 0 ) { // use no color table - if ( data->ctbl ) { - if ( data->ctbl_mine ) - free( data->ctbl ); - else - data->ctbl_mine = true; - data->ctbl = 0; - } - data->ncols = 0; - return; - } - if ( data->ctbl && data->ctbl_mine ) { // already has color table - data->ctbl = (QRgb*)realloc( data->ctbl, numColors*sizeof(QRgb) ); - if ( data->ctbl && numColors > data->ncols ) - memset( (char *)&data->ctbl[data->ncols], 0, - (numColors-data->ncols)*sizeof(QRgb) ); - } else { // create new color table - data->ctbl = (QRgb*)calloc( numColors*sizeof(QRgb), 1 ); - data->ctbl_mine = true; - } - data->ncols = data->ctbl == 0 ? 0 : numColors; -} - - -/*! - \fn bool QImage::hasAlphaBuffer() const - - Returns true if alpha buffer mode is enabled; otherwise returns - FALSE. - - \sa setAlphaBuffer() -*/ - -/*! - Enables alpha buffer mode if \a enable is true, otherwise disables - it. The default setting is disabled. - - An 8-bpp image has 8-bit pixels. A pixel is an index into the - \link color() color table\endlink, which contains 32-bit color - values. In a 32-bpp image, the 32-bit pixels are the color values. - - This 32-bit value is encoded as follows: The lower 24 bits are - used for the red, green, and blue components. The upper 8 bits - contain the alpha component. - - The alpha component specifies the transparency of a pixel. 0 means - completely transparent and 255 means opaque. The alpha component - is ignored if you do not enable alpha buffer mode. - - The alpha buffer is used to set a mask when a QImage is translated - to a QPixmap. - - \sa hasAlphaBuffer() createAlphaMask() -*/ - -void QImage::setAlphaBuffer( bool enable ) -{ - data->alpha = enable; -} - - -/*! - Sets the image \a width, \a height, \a depth, its number of colors - (in \a numColors), and bit order. Returns true if successful, or - FALSE if the parameters are incorrect or if memory cannot be - allocated. - - The \a width and \a height is limited to 32767. \a depth must be - 1, 8, or 32. If \a depth is 1, \a bitOrder must be set to - either QImage::LittleEndian or QImage::BigEndian. For other depths - \a bitOrder must be QImage::IgnoreEndian. - - This function allocates a color table and a buffer for the image - data. The image data is not initialized. - - The image buffer is allocated as a single block that consists of a - table of \link scanLine() scanline\endlink pointers (jumpTable()) - and the image data (bits()). - - \sa fill() width() height() depth() numColors() bitOrder() - jumpTable() scanLine() bits() bytesPerLine() byteCount() -*/ - -bool QImage::create( int width, int height, int depth, int numColors, - Endian bitOrder ) -{ - reset(); // reset old data - if ( width <= 0 || height <= 0 || depth <= 0 || numColors < 0 ) - return false; // invalid parameter(s) - if ( depth == 1 && bitOrder == IgnoreEndian ) { -#if defined(QT_CHECK_RANGE) - qWarning( "QImage::create: Bit order is required for 1 bpp images" ); -#endif - return false; - } - if ( depth != 1 ) - bitOrder = IgnoreEndian; - -#if defined(QT_CHECK_RANGE) - if ( depth == 24 ) - qWarning( "QImage::create: 24-bpp images no longer supported, " - "use 32-bpp instead" ); -#endif - switch ( depth ) { - case 1: - case 8: -#ifndef QT_NO_IMAGE_16_BIT - case 16: -#endif -#ifndef QT_NO_IMAGE_TRUECOLOR - case 32: -#endif - break; - default: // invalid depth - return false; - } - - if ( depth == 32 ) - numColors = 0; - setNumColors( numColors ); - if ( data->ncols != numColors ) // could not alloc color table - return false; - - if ( INT_MAX / depth < width) { // sanity check for potential overflow - setNumColors( 0 ); - return false; - } -// Qt/Embedded doesn't waste memory on unnecessary padding. -#ifdef Q_WS_QWS - const int bpl = (width*depth+7)/8; // bytes per scanline - const int pad = 0; -#else - const int bpl = ((width*depth+31)/32)*4; // bytes per scanline - // #### WWA: shouldn't this be (width*depth+7)/8: - const int pad = bpl - (width*depth)/8; // pad with zeros -#endif - if (INT_MAX / bpl < height) { // sanity check for potential overflow - setNumColors( 0 ); - return false; - } - int nbytes = bpl*height; // image size - int ptbl = height*sizeof(uchar*); // pointer table size - int size = nbytes + ptbl; // total size of data block - uchar **p = (uchar **)malloc( size ); // alloc image bits - Q_CHECK_PTR(p); - if ( !p ) { // no memory - setNumColors( 0 ); - return false; - } - data->w = width; - data->h = height; - data->d = depth; - data->nbytes = nbytes; - data->bitordr = bitOrder; - data->bits = p; // set image pointer - //uchar *d = (uchar*)p + ptbl; // setup scanline pointers - uchar *d = (uchar*)(p + height); // setup scanline pointers - while ( height-- ) { - *p++ = d; - if ( pad ) - memset( d+bpl-pad, 0, pad ); - d += bpl; - } - return true; -} - -/*! - \overload bool QImage::create( const QSize&, int depth, int numColors, Endian bitOrder ) -*/ -bool QImage::create( const QSize& size, int depth, int numColors, - QImage::Endian bitOrder ) -{ - return create(size.width(), size.height(), depth, numColors, bitOrder); -} - -/*! - \internal - Initializes the image data structure. -*/ - -void QImage::init() -{ - data = new QImageData; - Q_CHECK_PTR( data ); - reinit(); -} - -void QImage::reinit() -{ - data->w = data->h = data->d = data->ncols = 0; - data->nbytes = 0; - data->ctbl = 0; - data->bits = 0; - data->bitordr = QImage::IgnoreEndian; - data->alpha = false; -#ifndef QT_NO_IMAGE_TEXT - data->misc = 0; -#endif - data->dpmx = 0; - data->dpmy = 0; - data->offset = QPoint(0,0); -} - -/*! - \internal - Deallocates the image data and sets the bits pointer to 0. -*/ - -void QImage::freeBits() -{ - if ( data->bits ) { // dealloc image bits - free( data->bits ); - data->bits = 0; - } -} - - -/***************************************************************************** - Internal routines for converting image depth. - *****************************************************************************/ - -// -// convert_32_to_8: Converts a 32 bits depth (true color) to an 8 bit -// image with a colormap. If the 32 bit image has more than 256 colors, -// we convert the red,green and blue bytes into a single byte encoded -// as 6 shades of each of red, green and blue. -// -// if dithering is needed, only 1 color at most is available for alpha. -// -#ifndef QT_NO_IMAGE_TRUECOLOR -struct QRgbMap { - QRgbMap() : rgb(0xffffffff) { } - bool used() const { return rgb!=0xffffffff; } - uchar pix; - QRgb rgb; -}; - -static bool convert_32_to_8( const QImage *src, QImage *dst, int conversion_flags, QRgb* palette=0, int palette_count=0 ) -{ - QRgb *p; - uchar *b; - bool do_quant = false; - int y, x; - - if ( !dst->create(src->width(), src->height(), 8, 256) ) - return false; - - const int tablesize = 997; // prime - QRgbMap table[tablesize]; - int pix=0; - QRgb amask = src->hasAlphaBuffer() ? 0xffffffff : 0x00ffffff; - if ( src->hasAlphaBuffer() ) - dst->setAlphaBuffer(true); - - if ( palette ) { - // Preload palette into table. - - p = palette; - // Almost same code as pixel insertion below - while ( palette_count-- > 0 ) { - // Find in table... - int hash = (*p & amask) % tablesize; - for (;;) { - if ( table[hash].used() ) { - if ( table[hash].rgb == (*p & amask) ) { - // Found previous insertion - use it - break; - } else { - // Keep searching... - if (++hash == tablesize) hash = 0; - } - } else { - // Cannot be in table - Q_ASSERT ( pix != 256 ); // too many colors - // Insert into table at this unused position - dst->setColor( pix, (*p & amask) ); - table[hash].pix = pix++; - table[hash].rgb = *p & amask; - break; - } - } - p++; - } - } - - if ( (conversion_flags & Qt::DitherMode_Mask) == Qt::PreferDither ) { - do_quant = true; - } else { - for ( y=0; yheight(); y++ ) { // check if <= 256 colors - p = (QRgb *)src->scanLine(y); - b = dst->scanLine(y); - x = src->width(); - while ( x-- ) { - // Find in table... - int hash = (*p & amask) % tablesize; - for (;;) { - if ( table[hash].used() ) { - if ( table[hash].rgb == (*p & amask) ) { - // Found previous insertion - use it - break; - } else { - // Keep searching... - if (++hash == tablesize) hash = 0; - } - } else { - // Cannot be in table - if ( pix == 256 ) { // too many colors - do_quant = true; - // Break right out - x = 0; - y = src->height(); - } else { - // Insert into table at this unused position - dst->setColor( pix, (*p & amask) ); - table[hash].pix = pix++; - table[hash].rgb = (*p & amask); - } - break; - } - } - *b++ = table[hash].pix; // May occur once incorrectly - p++; - } - } - } - int ncols = do_quant ? 256 : pix; - - static uint bm[16][16]; - static int init=0; - if (!init) { - // Build a Bayer Matrix for dithering - - init = 1; - int n, i, j; - - bm[0][0]=0; - - for (n=1; n<16; n*=2) { - for (i=0; isetNumColors( ncols ); - - if ( do_quant ) { // quantization needed - -#define MAX_R 5 -#define MAX_G 5 -#define MAX_B 5 -#define INDEXOF(r,g,b) (((r)*(MAX_G+1)+(g))*(MAX_B+1)+(b)) - - int rc, gc, bc; - - for ( rc=0; rc<=MAX_R; rc++ ) // build 6x6x6 color cube - for ( gc=0; gc<=MAX_G; gc++ ) - for ( bc=0; bc<=MAX_B; bc++ ) { - dst->setColor( INDEXOF(rc,gc,bc), - (amask&0xff000000) - | qRgb( rc*255/MAX_R, gc*255/MAX_G, bc*255/MAX_B ) ); - } - - int sw = src->width(); - - int* line1[3]; - int* line2[3]; - int* pv[3]; - if ( ( conversion_flags & Qt::Dither_Mask ) == Qt::DiffuseDither ) { - line1[0] = new int[src->width()]; - line2[0] = new int[src->width()]; - line1[1] = new int[src->width()]; - line2[1] = new int[src->width()]; - line1[2] = new int[src->width()]; - line2[2] = new int[src->width()]; - pv[0] = new int[sw]; - pv[1] = new int[sw]; - pv[2] = new int[sw]; - } - - for ( y=0; y < src->height(); y++ ) { - p = (QRgb *)src->scanLine(y); - b = dst->scanLine(y); - QRgb *end = p + sw; - - // perform quantization - if ( ( conversion_flags & Qt::Dither_Mask ) == Qt::ThresholdDither ) { -#define DITHER(p,m) ((uchar) ((p * (m) + 127) / 255)) - while ( p < end ) { - rc = qRed( *p ); - gc = qGreen( *p ); - bc = qBlue( *p ); - - *b++ = - INDEXOF( - DITHER(rc, MAX_R), - DITHER(gc, MAX_G), - DITHER(bc, MAX_B) - ); - - p++; - } -#undef DITHER - } else if ( ( conversion_flags & Qt::Dither_Mask ) == Qt::OrderedDither ) { -#define DITHER(p,d,m) ((uchar) ((((256 * (m) + (m) + 1)) * (p) + (d)) / 65536 )) - - int x = 0; - while ( p < end ) { - uint d = bm[y&15][x&15]; - - rc = qRed( *p ); - gc = qGreen( *p ); - bc = qBlue( *p ); - - *b++ = - INDEXOF( - DITHER(rc, d, MAX_R), - DITHER(gc, d, MAX_G), - DITHER(bc, d, MAX_B) - ); - - p++; - x++; - } -#undef DITHER - } else { // Diffuse - int endian = (QImage::systemByteOrder() == QImage::BigEndian); - int x; - uchar* q = src->scanLine(y); - uchar* q2 = src->scanLine(y+1 < src->height() ? y + 1 : 0); - for (int chan = 0; chan < 3; chan++) { - b = dst->scanLine(y); - int *l1 = (y&1) ? line2[chan] : line1[chan]; - int *l2 = (y&1) ? line1[chan] : line2[chan]; - if ( y == 0 ) { - for (int i=0; iheight() ) { - for (int i=0; i>4; - l2[x+1] += err>>4; - } - l2[x]+=(err*5)>>4; - if (x>1) - l2[x-1]+=(err*3)>>4; - } - } else { - for (x=sw; x-->0; ) { - int pix = qMax(qMin(5, (l1[x] * 5 + 128)/ 255), 0); - int err = l1[x] - pix * 255 / 5; - pv[chan][x] = pix; - - // Spread the error around... - if ( x > 0 ) { - l1[x-1] += (err*7)>>4; - l2[x-1] += err>>4; - } - l2[x]+=(err*5)>>4; - if (x+1 < sw) - l2[x+1]+=(err*3)>>4; - } - } - } - if (endian) { - for (x=0; xhasAlphaBuffer() ) { - const int trans = 216; - dst->setColor(trans, 0x00000000); // transparent - QImage mask = src->createAlphaMask(conversion_flags); - uchar* m; - for ( y=0; y < src->height(); y++ ) { - uchar bit = 0x80; - m = mask.scanLine(y); - b = dst->scanLine(y); - int w = src->width(); - for ( x = 0; x>= 1)) { - bit = 0x80; - while ( xcreate(src->width(), src->height(), 32) ) - return false; // create failed - dst->setAlphaBuffer( src->hasAlphaBuffer() ); - for ( int y=0; yheight(); y++ ) { // for each scan line... - uint *p = (uint *)dst->scanLine(y); - uchar *b = src->scanLine(y); - uint *end = p + dst->width(); - while ( p < end ) - *p++ = src->color(*b++); - } - return true; -} - - -static bool convert_1_to_32( const QImage *src, QImage *dst ) -{ - if ( !dst->create(src->width(), src->height(), 32) ) - return false; // could not create - dst->setAlphaBuffer( src->hasAlphaBuffer() ); - for ( int y=0; yheight(); y++ ) { // for each scan line... - uint *p = (uint *)dst->scanLine(y); - uchar *b = src->scanLine(y); - int x; - if ( src->bitOrder() == QImage::BigEndian ) { - for ( x=0; xwidth(); x++ ) { - *p++ = src->color( (*b >> (7 - (x & 7))) & 1 ); - if ( (x & 7) == 7 ) - b++; - } - } else { - for ( x=0; xwidth(); x++ ) { - *p++ = src->color( (*b >> (x & 7)) & 1 ); - if ( (x & 7) == 7 ) - b++; - } - } - } - return true; -} -#endif // QT_NO_IMAGE_TRUECOLOR - -static bool convert_1_to_8( const QImage *src, QImage *dst ) -{ - if ( !dst->create(src->width(), src->height(), 8, 2) ) - return false; // something failed - dst->setAlphaBuffer( src->hasAlphaBuffer() ); - if (src->numColors() >= 2) { - dst->setColor( 0, src->color(0) ); // copy color table - dst->setColor( 1, src->color(1) ); - } else { - // Unlikely, but they do exist - if (src->numColors() >= 1) - dst->setColor( 0, src->color(0) ); - else - dst->setColor( 0, 0xffffffff ); - dst->setColor( 1, 0xff000000 ); - } - for ( int y=0; yheight(); y++ ) { // for each scan line... - uchar *p = dst->scanLine(y); - uchar *b = src->scanLine(y); - int x; - if ( src->bitOrder() == QImage::BigEndian ) { - for ( x=0; xwidth(); x++ ) { - *p++ = (*b >> (7 - (x & 7))) & 1; - if ( (x & 7) == 7 ) - b++; - } - } else { - for ( x=0; xwidth(); x++ ) { - *p++ = (*b >> (x & 7)) & 1; - if ( (x & 7) == 7 ) - b++; - } - } - } - return true; -} - -#ifndef QT_NO_IMAGE_DITHER_TO_1 -// -// dither_to_1: Uses selected dithering algorithm. -// - -static bool dither_to_1( const QImage *src, QImage *dst, - int conversion_flags, bool fromalpha ) -{ - if ( !dst->create(src->width(), src->height(), 1, 2, QImage::BigEndian) ) - return false; // something failed - - enum { Threshold, Ordered, Diffuse } dithermode; - - if ( fromalpha ) { - if ( ( conversion_flags & Qt::AlphaDither_Mask ) == Qt::DiffuseAlphaDither ) - dithermode = Diffuse; - else if ( ( conversion_flags & Qt::AlphaDither_Mask ) == Qt::OrderedAlphaDither ) - dithermode = Ordered; - else - dithermode = Threshold; - } else { - if ( ( conversion_flags & Qt::Dither_Mask ) == Qt::ThresholdDither ) - dithermode = Threshold; - else if ( ( conversion_flags & Qt::Dither_Mask ) == Qt::OrderedDither ) - dithermode = Ordered; - else - dithermode = Diffuse; - } - - dst->setColor( 0, qRgb(255, 255, 255) ); - dst->setColor( 1, qRgb( 0, 0, 0) ); - int w = src->width(); - int h = src->height(); - int d = src->depth(); - uchar gray[256]; // gray map for 8 bit images - bool use_gray = d == 8; - if ( use_gray ) { // make gray map - if ( fromalpha ) { - // Alpha 0x00 -> 0 pixels (white) - // Alpha 0xFF -> 1 pixels (black) - for ( int i=0; inumColors(); i++ ) - gray[i] = (255 - (src->color(i) >> 24)); - } else { - // Pixel 0x00 -> 1 pixels (black) - // Pixel 0xFF -> 0 pixels (white) - for ( int i=0; inumColors(); i++ ) - gray[i] = qGray( src->color(i) & 0x00ffffff ); - } - } - - switch ( dithermode ) { - case Diffuse: { - int *line1 = new int[w]; - int *line2 = new int[w]; - int bmwidth = (w+7)/8; - if ( !(line1 && line2) ) - return false; - uchar *p; - uchar *end; - int *b1, *b2; - int wbytes = w * (d/8); - p = src->bits(); - end = p + wbytes; - b2 = line2; - if ( use_gray ) { // 8 bit image - while ( p < end ) - *b2++ = gray[*p++]; -#ifndef QT_NO_IMAGE_TRUECOLOR - } else { // 32 bit image - if ( fromalpha ) { - while ( p < end ) { - *b2++ = 255 - (*(uint*)p >> 24); - p += 4; - } - } else { - while ( p < end ) { - *b2++ = qGray(*(uint*)p); - p += 4; - } - } -#endif - } - int x, y; - for ( y=0; yscanLine(y+1); - end = p + wbytes; - b2 = line2; - if ( use_gray ) { // 8 bit image - while ( p < end ) - *b2++ = gray[*p++]; -#ifndef QT_NO_IMAGE_TRUECOLOR - } else { // 24 bit image - if ( fromalpha ) { - while ( p < end ) { - *b2++ = 255 - (*(uint*)p >> 24); - p += 4; - } - } else { - while ( p < end ) { - *b2++ = qGray(*(uint*)p); - p += 4; - } - } -#endif - } - } - - int err; - p = dst->scanLine( y ); - memset( p, 0, bmwidth ); - b1 = line1; - b2 = line2; - int bit = 7; - for ( x=1; x<=w; x++ ) { - if ( *b1 < 128 ) { // black pixel - err = *b1++; - *p |= 1 << bit; - } else { // white pixel - err = *b1++ - 255; - } - if ( bit == 0 ) { - p++; - bit = 7; - } else { - bit--; - } - if ( x < w ) - *b1 += (err*7)>>4; // spread error to right pixel - if ( not_last_line ) { - b2[0] += (err*5)>>4; // pixel below - if ( x > 1 ) - b2[-1] += (err*3)>>4; // pixel below left - if ( x < w ) - b2[1] += err>>4; // pixel below right - } - b2++; - } - } - delete [] line1; - delete [] line2; - } break; - case Ordered: { - static uint bm[16][16]; - static int init=0; - if (!init) { - // Build a Bayer Matrix for dithering - - init = 1; - int n, i, j; - - bm[0][0]=0; - - for (n=1; n<16; n*=2) { - for (i=0; ifill( 0 ); - uchar** mline = dst->jumpTable(); -#ifndef QT_NO_IMAGE_TRUECOLOR - if ( d == 32 ) { - uint** line = (uint**)src->jumpTable(); - for ( int i=0; i> 24) >= bm[j++&15][i&15] ) - *m |= 1 << bit; - if ( bit == 0 ) { - m++; - bit = 7; - } else { - bit--; - } - } - } else { - while ( p < end ) { - if ( (uint)qGray(*p++) < bm[j++&15][i&15] ) - *m |= 1 << bit; - if ( bit == 0 ) { - m++; - bit = 7; - } else { - bit--; - } - } - } - } - } else -#endif // QT_NO_IMAGE_TRUECOLOR - /* ( d == 8 ) */ { - uchar** line = src->jumpTable(); - for ( int i=0; ifill( 0 ); - uchar** mline = dst->jumpTable(); -#ifndef QT_NO_IMAGE_TRUECOLOR - if ( d == 32 ) { - uint** line = (uint**)src->jumpTable(); - for ( int i=0; i> 24) >= 128 ) - *m |= 1 << bit; // Set mask "on" - if ( bit == 0 ) { - m++; - bit = 7; - } else { - bit--; - } - } - } else { - while ( p < end ) { - if ( qGray(*p++) < 128 ) - *m |= 1 << bit; // Set pixel "black" - if ( bit == 0 ) { - m++; - bit = 7; - } else { - bit--; - } - } - } - } - } else -#endif //QT_NO_IMAGE_TRUECOLOR - if ( d == 8 ) { - uchar** line = src->jumpTable(); - for ( int i=0; i> 11; - int g=(c & 0x07e0) >> 6; //green/2 - int b=(c & 0x001f); - return r == g && g == b; -} - - -static bool convert_16_to_32( const QImage *src, QImage *dst ) -{ - if ( !dst->create(src->width(), src->height(), 32) ) - return false; // create failed - dst->setAlphaBuffer( src->hasAlphaBuffer() ); - for ( int y=0; yheight(); y++ ) { // for each scan line... - uint *p = (uint *)dst->scanLine(y); - ushort *s = (ushort*)src->scanLine(y); - uint *end = p + dst->width(); - while ( p < end ) - *p++ = qt_conv16ToRgb( *s++ ); - } - return true; -} - - -static bool convert_32_to_16( const QImage *src, QImage *dst ) -{ - if ( !dst->create(src->width(), src->height(), 16) ) - return false; // create failed - dst->setAlphaBuffer( src->hasAlphaBuffer() ); - for ( int y=0; yheight(); y++ ) { // for each scan line... - ushort *p = (ushort *)dst->scanLine(y); - uint *s = (uint*)src->scanLine(y); - ushort *end = p + dst->width(); - while ( p < end ) - *p++ = qt_convRgbTo16( *s++ ); - } - return true; -} - - -#endif - -/*! - Converts the depth (bpp) of the image to \a depth and returns the - converted image. The original image is not changed. - - The \a depth argument must be 1, 8, 16 (Qt/Embedded only) or 32. - - Returns \c *this if \a depth is equal to the image depth, or a - \link isNull() null\endlink image if this image cannot be - converted. - - If the image needs to be modified to fit in a lower-resolution - result (e.g. converting from 32-bit to 8-bit), use the \a - conversion_flags to specify how you'd prefer this to happen. - - \sa Qt::ImageConversionFlags depth() isNull() -*/ - -QImage QImage::convertDepth( int depth, int conversion_flags ) const -{ - QImage image; - if ( data->d == depth ) - image = *this; // no conversion -#ifndef QT_NO_IMAGE_DITHER_TO_1 - else if ( (data->d == 8 || data->d == 32) && depth == 1 ) // dither - dither_to_1( this, &image, conversion_flags, false ); -#endif -#ifndef QT_NO_IMAGE_TRUECOLOR - else if ( data->d == 32 && depth == 8 ) // 32 -> 8 - convert_32_to_8( this, &image, conversion_flags ); - else if ( data->d == 8 && depth == 32 ) // 8 -> 32 - convert_8_to_32( this, &image ); -#endif - else if ( data->d == 1 && depth == 8 ) // 1 -> 8 - convert_1_to_8( this, &image ); -#ifndef QT_NO_IMAGE_TRUECOLOR - else if ( data->d == 1 && depth == 32 ) // 1 -> 32 - convert_1_to_32( this, &image ); -#endif -#ifndef QT_NO_IMAGE_16_BIT - else if ( data->d == 16 && depth != 16 ) { - QImage tmp; - convert_16_to_32( this, &tmp ); - image = tmp.convertDepth( depth, conversion_flags ); - } else if ( data->d != 16 && depth == 16 ) { - QImage tmp = convertDepth( 32, conversion_flags ); - convert_32_to_16( &tmp, &image ); - } -#endif - else { -#if defined(QT_CHECK_RANGE) - if ( isNull() ) - qWarning( "QImage::convertDepth: Image is a null image" ); - else - qWarning( "QImage::convertDepth: Depth %d not supported", depth ); -#endif - } - return image; -} - -/*! - \overload -*/ - -QImage QImage::convertDepth( int depth ) const -{ - return convertDepth( depth, 0 ); -} - -/*! - Returns TRUE if ( \a x, \a y ) is a valid coordinate in the image; - otherwise returns FALSE. - - \sa width() height() pixelIndex() -*/ - -bool QImage::valid( int x, int y ) const -{ - return x >= 0 && x < width() - && y >= 0 && y < height(); -} - -/*! - Returns the pixel index at the given coordinates. - - If (\a x, \a y) is not \link valid() valid\endlink, or if the - image is not a paletted image (depth() \> 8), the results are - undefined. - - \sa valid() depth() -*/ - -int QImage::pixelIndex( int x, int y ) const -{ -#if defined(QT_CHECK_RANGE) - if ( x < 0 || x >= width() ) { - qWarning( "QImage::pixel: x=%d out of range", x ); - return -12345; - } -#endif - uchar * s = scanLine( y ); - switch( depth() ) { - case 1: - if ( bitOrder() == QImage::LittleEndian ) - return (*(s + (x >> 3)) >> (x & 7)) & 1; - else - return (*(s + (x >> 3)) >> (7- (x & 7))) & 1; - case 8: - return (int)s[x]; -#ifndef QT_NO_IMAGE_TRUECOLOR -#ifndef QT_NO_IMAGE_16_BIT - case 16: -#endif - case 32: -#if defined(QT_CHECK_RANGE) - qWarning( "QImage::pixelIndex: Not applicable for %d-bpp images " - "(no palette)", depth() ); -#endif - return 0; -#endif //QT_NO_IMAGE_TRUECOLOR - } - return 0; -} - - -/*! - Returns the color of the pixel at the coordinates (\a x, \a y). - - If (\a x, \a y) is not \link valid() on the image\endlink, the - results are undefined. - - \sa setPixel() qRed() qGreen() qBlue() valid() -*/ - -QRgb QImage::pixel( int x, int y ) const -{ -#if defined(QT_CHECK_RANGE) - if ( x < 0 || x >= width() ) { - qWarning( "QImage::pixel: x=%d out of range", x ); - return 12345; - } -#endif - uchar * s = scanLine( y ); - switch( depth() ) { - case 1: - if ( bitOrder() == QImage::LittleEndian ) - return color( (*(s + (x >> 3)) >> (x & 7)) & 1 ); - else - return color( (*(s + (x >> 3)) >> (7- (x & 7))) & 1 ); - case 8: - return color( (int)s[x] ); -#ifndef QT_NO_IMAGE_16_BIT - case 16: - return qt_conv16ToRgb(((ushort*)s)[x]); -#endif -#ifndef QT_NO_IMAGE_TRUECOLOR - case 32: - return ((QRgb*)s)[x]; -#endif - default: - return 100367; - } -} - - -/*! - Sets the pixel index or color at the coordinates (\a x, \a y) to - \a index_or_rgb. - - If (\a x, \a y) is not \link valid() valid\endlink, the result is - undefined. - - If the image is a paletted image (depth() \<= 8) and \a - index_or_rgb \>= numColors(), the result is undefined. - - \sa pixelIndex() pixel() qRgb() qRgba() valid() -*/ - -void QImage::setPixel( int x, int y, uint index_or_rgb ) -{ - if ( x < 0 || x >= width() ) { -#if defined(QT_CHECK_RANGE) - qWarning( "QImage::setPixel: x=%d out of range", x ); -#endif - return; - } - if ( depth() == 1 ) { - uchar * s = scanLine( y ); - if ( index_or_rgb > 1) { -#if defined(QT_CHECK_RANGE) - qWarning( "QImage::setPixel: index=%d out of range", - index_or_rgb ); -#endif - } else if ( bitOrder() == QImage::LittleEndian ) { - if (index_or_rgb==0) - *(s + (x >> 3)) &= ~(1 << (x & 7)); - else - *(s + (x >> 3)) |= (1 << (x & 7)); - } else { - if (index_or_rgb==0) - *(s + (x >> 3)) &= ~(1 << (7-(x & 7))); - else - *(s + (x >> 3)) |= (1 << (7-(x & 7))); - } - } else if ( depth() == 8 ) { - if (index_or_rgb > (uint)numColors()) { -#if defined(QT_CHECK_RANGE) - qWarning( "QImage::setPixel: index=%d out of range", - index_or_rgb ); -#endif - return; - } - uchar * s = scanLine( y ); - s[x] = index_or_rgb; -#ifndef QT_NO_IMAGE_16_BIT - } else if ( depth() == 16 ) { - ushort * s = (ushort*)scanLine( y ); - s[x] = qt_convRgbTo16(index_or_rgb); -#endif -#ifndef QT_NO_IMAGE_TRUECOLOR - } else if ( depth() == 32 ) { - QRgb * s = (QRgb*)scanLine( y ); - s[x] = index_or_rgb; -#endif - } -} - - -/*! - Converts the bit order of the image to \a bitOrder and returns the - converted image. The original image is not changed. - - Returns \c *this if the \a bitOrder is equal to the image bit - order, or a \link isNull() null\endlink image if this image cannot - be converted. - - \sa bitOrder() systemBitOrder() isNull() -*/ - -QImage QImage::convertBitOrder( Endian bitOrder ) const -{ - if ( isNull() || data->d != 1 || // invalid argument(s) - !(bitOrder == BigEndian || bitOrder == LittleEndian) ) { - QImage nullImage; - return nullImage; - } - if ( data->bitordr == bitOrder ) // nothing to do - return copy(); - - QImage image( data->w, data->h, 1, data->ncols, bitOrder ); - - int bpl = (width() + 7) / 8; - for ( int y = 0; y < data->h; y++ ) { - uchar *p = jumpTable()[y]; - uchar *end = p + bpl; - uchar *b = image.jumpTable()[y]; - while ( p < end ) - *b++ = bitflip[*p++]; - } - memcpy( image.colorTable(), colorTable(), numColors()*sizeof(QRgb) ); - return image; -} - -// ### Candidate (renamed) for qcolor.h -static -bool isGray(QRgb c) -{ - return qRed(c) == qGreen(c) - && qRed(c) == qBlue(c); -} - -/*! - Returns TRUE if all the colors in the image are shades of gray - (i.e. their red, green and blue components are equal); otherwise - returns FALSE. - - This function is slow for large 16-bit (Qt/Embedded only) and 32-bit images. - - \sa isGrayscale() -*/ -bool QImage::allGray() const -{ -#ifndef QT_NO_IMAGE_TRUECOLOR - if (depth()==32) { - int p = width()*height(); - QRgb* b = (QRgb*)bits(); - while (p--) - if (!isGray(*b++)) - return false; -#ifndef QT_NO_IMAGE_16_BIT - } else if (depth()==16) { - int p = width()*height(); - ushort* b = (ushort*)bits(); - while (p--) - if (!is16BitGray(*b++)) - return false; -#endif - } else -#endif //QT_NO_IMAGE_TRUECOLOR - { - if (!data->ctbl) return true; - for (int i=0; ictbl[i])) - return false; - } - return false; -} - -/*! - For 16-bit (Qt/Embedded only) and 32-bit images, this function is - equivalent to allGray(). - - For 8-bpp images, this function returns TRUE if color(i) is - QRgb(i,i,i) for all indices of the color table; otherwise returns - FALSE. - - \sa allGray() depth() -*/ -bool QImage::isGrayscale() const -{ - switch (depth()) { -#ifndef QT_NO_IMAGE_TRUECOLOR - case 32: -#ifndef QT_NO_IMAGE_16_BIT - case 16: -#endif - return allGray(); -#endif //QT_NO_IMAGE_TRUECOLOR - case 8: { - for (int i=0; ictbl[i] != qRgb(i,i,i)) - return false; - return true; - } - } - return false; -} - -#ifndef QT_NO_IMAGE_SMOOTHSCALE -static -void pnmscale(const QImage& src, QImage& dst) -{ - QRgb* xelrow = 0; - QRgb* tempxelrow = 0; - QRgb* xP; - QRgb* nxP; - int rows, cols, rowsread, newrows, newcols; - int row, col, needtoreadrow; - const uchar maxval = 255; - double xscale, yscale; - long sxscale, syscale; - long fracrowtofill, fracrowleft; - long* as; - long* rs; - long* gs; - long* bs; - int rowswritten = 0; - - cols = src.width(); - rows = src.height(); - newcols = dst.width(); - newrows = dst.height(); - - long SCALE; - long HALFSCALE; - - if (cols > 4096) - { - SCALE = 4096; - HALFSCALE = 2048; - } - else - { - int fac = 4096; - - while (cols * fac > 4096) - { - fac /= 2; - } - - SCALE = fac * cols; - HALFSCALE = fac * cols / 2; - } - - xscale = (double) newcols / (double) cols; - yscale = (double) newrows / (double) rows; - - sxscale = (long)(xscale * SCALE); - syscale = (long)(yscale * SCALE); - - if ( newrows != rows ) /* shortcut Y scaling if possible */ - tempxelrow = new QRgb[cols]; - - if ( src.hasAlphaBuffer() ) { - dst.setAlphaBuffer(true); - as = new long[cols]; - for ( col = 0; col < cols; ++col ) - as[col] = HALFSCALE; - } else { - as = 0; - } - rs = new long[cols]; - gs = new long[cols]; - bs = new long[cols]; - rowsread = 0; - fracrowleft = syscale; - needtoreadrow = 1; - for ( col = 0; col < cols; ++col ) - rs[col] = gs[col] = bs[col] = HALFSCALE; - fracrowtofill = SCALE; - - for ( row = 0; row < newrows; ++row ) { - /* First scale Y from xelrow into tempxelrow. */ - if ( newrows == rows ) { - /* shortcut Y scaling if possible */ - tempxelrow = xelrow = (QRgb*)src.scanLine(rowsread++); - } else { - while ( fracrowleft < fracrowtofill ) { - if ( needtoreadrow && rowsread < rows ) - xelrow = (QRgb*)src.scanLine(rowsread++); - for ( col = 0, xP = xelrow; col < cols; ++col, ++xP ) { - if (as) { - as[col] += fracrowleft * qAlpha( *xP ); - rs[col] += fracrowleft * qRed( *xP ) * qAlpha( *xP ) / 255; - gs[col] += fracrowleft * qGreen( *xP ) * qAlpha( *xP ) / 255; - bs[col] += fracrowleft * qBlue( *xP ) * qAlpha( *xP ) / 255; - } else { - rs[col] += fracrowleft * qRed( *xP ); - gs[col] += fracrowleft * qGreen( *xP ); - bs[col] += fracrowleft * qBlue( *xP ); - } - } - fracrowtofill -= fracrowleft; - fracrowleft = syscale; - needtoreadrow = 1; - } - /* Now fracrowleft is >= fracrowtofill, so we can produce a row. */ - if ( needtoreadrow && rowsread < rows ) { - xelrow = (QRgb*)src.scanLine(rowsread++); - needtoreadrow = 0; - } - long a=0; - for ( col = 0, xP = xelrow, nxP = tempxelrow; - col < cols; ++col, ++xP, ++nxP ) - { - long r, g, b; - - if ( as ) { - r = rs[col] + fracrowtofill * qRed( *xP ) * qAlpha( *xP ) / 255; - g = gs[col] + fracrowtofill * qGreen( *xP ) * qAlpha( *xP ) / 255; - b = bs[col] + fracrowtofill * qBlue( *xP ) * qAlpha( *xP ) / 255; - a = as[col] + fracrowtofill * qAlpha( *xP ); - if ( a ) { - r = r * 255 / a * SCALE; - g = g * 255 / a * SCALE; - b = b * 255 / a * SCALE; - } - } else { - r = rs[col] + fracrowtofill * qRed( *xP ); - g = gs[col] + fracrowtofill * qGreen( *xP ); - b = bs[col] + fracrowtofill * qBlue( *xP ); - } - r /= SCALE; - if ( r > maxval ) r = maxval; - g /= SCALE; - if ( g > maxval ) g = maxval; - b /= SCALE; - if ( b > maxval ) b = maxval; - if ( as ) { - a /= SCALE; - if ( a > maxval ) a = maxval; - *nxP = qRgba( (int)r, (int)g, (int)b, (int)a ); - as[col] = HALFSCALE; - } else { - *nxP = qRgb( (int)r, (int)g, (int)b ); - } - rs[col] = gs[col] = bs[col] = HALFSCALE; - } - fracrowleft -= fracrowtofill; - if ( fracrowleft == 0 ) { - fracrowleft = syscale; - needtoreadrow = 1; - } - fracrowtofill = SCALE; - } - - /* Now scale X from tempxelrow into dst and write it out. */ - if ( newcols == cols ) { - /* shortcut X scaling if possible */ - memcpy(dst.scanLine(rowswritten++), tempxelrow, newcols*4); - } else { - long a, r, g, b; - long fraccoltofill, fraccolleft = 0; - int needcol; - - nxP = (QRgb*)dst.scanLine(rowswritten++); - fraccoltofill = SCALE; - a = r = g = b = HALFSCALE; - needcol = 0; - for ( col = 0, xP = tempxelrow; col < cols; ++col, ++xP ) { - fraccolleft = sxscale; - while ( fraccolleft >= fraccoltofill ) { - if ( needcol ) { - ++nxP; - a = r = g = b = HALFSCALE; - } - if ( as ) { - r += fraccoltofill * qRed( *xP ) * qAlpha( *xP ) / 255; - g += fraccoltofill * qGreen( *xP ) * qAlpha( *xP ) / 255; - b += fraccoltofill * qBlue( *xP ) * qAlpha( *xP ) / 255; - a += fraccoltofill * qAlpha( *xP ); - if ( a ) { - r = r * 255 / a * SCALE; - g = g * 255 / a * SCALE; - b = b * 255 / a * SCALE; - } - } else { - r += fraccoltofill * qRed( *xP ); - g += fraccoltofill * qGreen( *xP ); - b += fraccoltofill * qBlue( *xP ); - } - r /= SCALE; - if ( r > maxval ) r = maxval; - g /= SCALE; - if ( g > maxval ) g = maxval; - b /= SCALE; - if ( b > maxval ) b = maxval; - if (as) { - a /= SCALE; - if ( a > maxval ) a = maxval; - *nxP = qRgba( (int)r, (int)g, (int)b, (int)a ); - } else { - *nxP = qRgb( (int)r, (int)g, (int)b ); - } - fraccolleft -= fraccoltofill; - fraccoltofill = SCALE; - needcol = 1; - } - if ( fraccolleft > 0 ) { - if ( needcol ) { - ++nxP; - a = r = g = b = HALFSCALE; - needcol = 0; - } - if (as) { - a += fraccolleft * qAlpha( *xP ); - r += fraccolleft * qRed( *xP ) * qAlpha( *xP ) / 255; - g += fraccolleft * qGreen( *xP ) * qAlpha( *xP ) / 255; - b += fraccolleft * qBlue( *xP ) * qAlpha( *xP ) / 255; - } else { - r += fraccolleft * qRed( *xP ); - g += fraccolleft * qGreen( *xP ); - b += fraccolleft * qBlue( *xP ); - } - fraccoltofill -= fraccolleft; - } - } - if ( fraccoltofill > 0 ) { - --xP; - if (as) { - a += fraccolleft * qAlpha( *xP ); - r += fraccoltofill * qRed( *xP ) * qAlpha( *xP ) / 255; - g += fraccoltofill * qGreen( *xP ) * qAlpha( *xP ) / 255; - b += fraccoltofill * qBlue( *xP ) * qAlpha( *xP ) / 255; - if ( a ) { - r = r * 255 / a * SCALE; - g = g * 255 / a * SCALE; - b = b * 255 / a * SCALE; - } - } else { - r += fraccoltofill * qRed( *xP ); - g += fraccoltofill * qGreen( *xP ); - b += fraccoltofill * qBlue( *xP ); - } - } - if ( ! needcol ) { - r /= SCALE; - if ( r > maxval ) r = maxval; - g /= SCALE; - if ( g > maxval ) g = maxval; - b /= SCALE; - if ( b > maxval ) b = maxval; - if (as) { - a /= SCALE; - if ( a > maxval ) a = maxval; - *nxP = qRgba( (int)r, (int)g, (int)b, (int)a ); - } else { - *nxP = qRgb( (int)r, (int)g, (int)b ); - } - } - } - } - - if ( newrows != rows && tempxelrow )// Robust, tempxelrow might be 0 1 day - delete [] tempxelrow; - if ( as ) // Avoid purify complaint - delete [] as; - if ( rs ) // Robust, rs might be 0 one day - delete [] rs; - if ( gs ) // Robust, gs might be 0 one day - delete [] gs; - if ( bs ) // Robust, bs might be 0 one day - delete [] bs; -} -#endif - -/*! - \enum QImage::ScaleMode - - The functions scale() and smoothScale() use different modes for - scaling the image. The purpose of these modes is to retain the - ratio of the image if this is required. - - \img scaling.png - - \value ScaleFree The image is scaled freely: the resulting image - fits exactly into the specified size; the ratio will not - necessarily be preserved. - \value ScaleMin The ratio of the image is preserved and the - resulting image is guaranteed to fit into the specified size - (it is as large as possible within these constraints) - the - image might be smaller than the requested size. - \value ScaleMax The ratio of the image is preserved and the - resulting image fills the whole specified rectangle (it is as - small as possible within these constraints) - the image might - be larger than the requested size. -*/ - -#ifndef QT_NO_IMAGE_SMOOTHSCALE -/*! - Returns a smoothly scaled copy of the image. The returned image - has a size of width \a w by height \a h pixels if \a mode is \c - ScaleFree. The modes \c ScaleMin and \c ScaleMax may be used to - preserve the ratio of the image: if \a mode is \c ScaleMin, the - returned image is guaranteed to fit into the rectangle specified - by \a w and \a h (it is as large as possible within the - constraints); if \a mode is \c ScaleMax, the returned image fits - at least into the specified rectangle (it is a small as possible - within the constraints). - - For 32-bpp images and 1-bpp/8-bpp color images the result will be - 32-bpp, whereas \link allGray() all-gray \endlink images - (including black-and-white 1-bpp) will produce 8-bit \link - isGrayscale() grayscale \endlink images with the palette spanning - 256 grays from black to white. - - This function uses code based on pnmscale.c by Jef Poskanzer. - - pnmscale.c - read a portable anymap and scale it - - \legalese - - Copyright (C) 1989, 1991 by Jef Poskanzer. - - Permission to use, copy, modify, and distribute this software and - its documentation for any purpose and without fee is hereby - granted, provided that the above copyright notice appear in all - copies and that both that copyright notice and this permission - notice appear in supporting documentation. This software is - provided "as is" without express or implied warranty. - - \sa scale() mirror() -*/ -QImage QImage::smoothScale( int w, int h, ScaleMode mode ) const -{ - return smoothScale( QSize( w, h ), mode ); -} -#endif - -#ifndef QT_NO_IMAGE_SMOOTHSCALE -/*! - \overload - - The requested size of the image is \a s. -*/ -QImage QImage::smoothScale( const QSize& s, ScaleMode mode ) const -{ - if ( isNull() ) { -#if defined(QT_CHECK_RANGE) - qWarning( "QImage::smoothScale: Image is a null image" ); -#endif - return copy(); - } - - QSize newSize = size(); - newSize.scale( s, (QSize::ScaleMode)mode ); // ### remove cast in Qt 4.0 - if ( newSize == size() ) - return copy(); - - if ( depth() == 32 ) { - QImage img( newSize, 32 ); - // 32-bpp to 32-bpp - pnmscale( *this, img ); - return img; - } else if ( depth() != 16 && allGray() && !hasAlphaBuffer() ) { - // Inefficient - return convertDepth(32).smoothScale(newSize, mode).convertDepth(8); - } else { - // Inefficient - return convertDepth(32).smoothScale(newSize, mode); - } -} -#endif - -/*! - Returns a copy of the image scaled to a rectangle of width \a w - and height \a h according to the ScaleMode \a mode. - - \list - \i If \a mode is \c ScaleFree, the image is scaled to (\a w, - \a h). - \i If \a mode is \c ScaleMin, the image is scaled to a rectangle - as large as possible inside (\a w, \a h), preserving the aspect - ratio. - \i If \a mode is \c ScaleMax, the image is scaled to a rectangle - as small as possible outside (\a w, \a h), preserving the aspect - ratio. - \endlist - - If either the width \a w or the height \a h is 0 or negative, this - function returns a \link isNull() null\endlink image. - - This function uses a simple, fast algorithm. If you need better - quality, use smoothScale() instead. - - \sa scaleWidth() scaleHeight() smoothScale() xForm() -*/ -#ifndef QT_NO_IMAGE_TRANSFORMATION -QImage QImage::scale( int w, int h, ScaleMode mode ) const -{ - return scale( QSize( w, h ), mode ); -} -#endif - -/*! - \overload - - The requested size of the image is \a s. -*/ -#ifndef QT_NO_IMAGE_TRANSFORMATION -QImage QImage::scale( const QSize& s, ScaleMode mode ) const -{ - if ( isNull() ) { -#if defined(QT_CHECK_RANGE) - qWarning( "QImage::scale: Image is a null image" ); -#endif - return copy(); - } - if ( s.isEmpty() ) - return QImage(); - - QSize newSize = size(); - newSize.scale( s, (QSize::ScaleMode)mode ); // ### remove cast in Qt 4.0 - if ( newSize == size() ) - return copy(); - - QImage img; - QWMatrix wm; - wm.scale( (double)newSize.width() / width(), (double)newSize.height() / height() ); - img = xForm( wm ); - // ### I should test and resize the image if it has not the right size -// if ( img.width() != newSize.width() || img.height() != newSize.height() ) -// img.resize( newSize.width(), newSize.height() ); - return img; -} -#endif - -/*! - Returns a scaled copy of the image. The returned image has a width - of \a w pixels. This function automatically calculates the height - of the image so that the ratio of the image is preserved. - - If \a w is 0 or negative a \link isNull() null\endlink image is - returned. - - \sa scale() scaleHeight() smoothScale() xForm() -*/ -#ifndef QT_NO_IMAGE_TRANSFORMATION -QImage QImage::scaleWidth( int w ) const -{ - if ( isNull() ) { -#if defined(QT_CHECK_RANGE) - qWarning( "QImage::scaleWidth: Image is a null image" ); -#endif - return copy(); - } - if ( w <= 0 ) - return QImage(); - - QWMatrix wm; - double factor = (double) w / width(); - wm.scale( factor, factor ); - return xForm( wm ); -} -#endif - -/*! - Returns a scaled copy of the image. The returned image has a - height of \a h pixels. This function automatically calculates the - width of the image so that the ratio of the image is preserved. - - If \a h is 0 or negative a \link isNull() null\endlink image is - returned. - - \sa scale() scaleWidth() smoothScale() xForm() -*/ -#ifndef QT_NO_IMAGE_TRANSFORMATION -QImage QImage::scaleHeight( int h ) const -{ - if ( isNull() ) { -#if defined(QT_CHECK_RANGE) - qWarning( "QImage::scaleHeight: Image is a null image" ); -#endif - return copy(); - } - if ( h <= 0 ) - return QImage(); - - QWMatrix wm; - double factor = (double) h / height(); - wm.scale( factor, factor ); - return xForm( wm ); -} -#endif - - -/*! - Returns a copy of the image that is transformed using the - transformation matrix, \a matrix. - - The transformation \a matrix is internally adjusted to compensate - for unwanted translation, i.e. xForm() returns the smallest image - that contains all the transformed points of the original image. - - \sa scale() QPixmap::xForm() QPixmap::trueMatrix() QWMatrix -*/ -#ifndef QT_NO_IMAGE_TRANSFORMATION -QImage QImage::xForm( const QWMatrix &matrix ) const -{ - // This function uses the same algorithm as (and steals quite some - // code from) QPixmap::xForm(). - - if ( isNull() ) - return copy(); - - if ( depth() == 16 ) { - // inefficient - return convertDepth( 32 ).xForm( matrix ); - } - - // source image data - int ws = width(); - int hs = height(); - int sbpl = bytesPerLine(); - uchar *sptr = bits(); - - // target image data - int wd; - int hd; - - int bpp = depth(); - - // compute size of target image - QWMatrix mat = QPixmap::trueMatrix( matrix, ws, hs ); - if ( mat.m12() == 0.0F && mat.m21() == 0.0F ) { - if ( mat.m11() == 1.0F && mat.m22() == 1.0F ) // identity matrix - return copy(); - hd = qRound( mat.m22() * hs ); - wd = qRound( mat.m11() * ws ); - hd = qAbs( hd ); - wd = qAbs( wd ); - } else { // rotation or shearing - QPointArray a( QRect(0, 0, ws, hs) ); - a = mat.map( a ); - QRect r = a.boundingRect().normalize(); - wd = r.width(); - hd = r.height(); - } - - bool invertible; - mat = mat.invert( &invertible ); // invert matrix - if ( hd == 0 || wd == 0 || !invertible ) // error, return null image - return QImage(); - - // create target image (some of the code is from QImage::copy()) - QImage dImage( wd, hd, depth(), numColors(), bitOrder() ); - memcpy( dImage.colorTable(), colorTable(), numColors()*sizeof(QRgb) ); - dImage.setAlphaBuffer( hasAlphaBuffer() ); - dImage.data->dpmx = dotsPerMeterX(); - dImage.data->dpmy = dotsPerMeterY(); - - switch ( bpp ) { - // initizialize the data - case 1: - memset( dImage.bits(), 0, dImage.byteCount() ); - break; - case 8: - if ( dImage.data->ncols < 256 ) { - // colors are left in the color table, so pick that one as transparent - dImage.setNumColors( dImage.data->ncols+1 ); - dImage.setColor( dImage.data->ncols-1, 0x00 ); - memset( dImage.bits(), dImage.data->ncols-1, dImage.byteCount() ); - } else { - memset( dImage.bits(), 0, dImage.byteCount() ); - } - break; - case 16: - memset( dImage.bits(), 0xff, dImage.byteCount() ); - break; - case 32: - memset( dImage.bits(), 0x00, dImage.byteCount() ); - break; - } - - int type; - if ( bitOrder() == BigEndian ) - type = QT_XFORM_TYPE_MSBFIRST; - else - type = QT_XFORM_TYPE_LSBFIRST; - int dbpl = dImage.bytesPerLine(); - qt_xForm_helper( mat, 0, type, bpp, dImage.bits(), dbpl, 0, hd, sptr, sbpl, - ws, hs ); - return dImage; -} -#endif - -/*! - Builds and returns a 1-bpp mask from the alpha buffer in this - image. Returns a \link isNull() null\endlink image if \link - setAlphaBuffer() alpha buffer mode\endlink is disabled. - - See QPixmap::convertFromImage() for a description of the \a - conversion_flags argument. - - The returned image has little-endian bit order, which you can - convert to big-endianness using convertBitOrder(). - - \sa createHeuristicMask() hasAlphaBuffer() setAlphaBuffer() -*/ -#ifndef QT_NO_IMAGE_DITHER_TO_1 -QImage QImage::createAlphaMask( int conversion_flags ) const -{ - if ( conversion_flags == 1 ) { - // Old code is passing "TRUE". - conversion_flags = Qt::DiffuseAlphaDither; - } - - if ( isNull() || !hasAlphaBuffer() ) - return QImage(); - - if ( depth() == 1 ) { - // A monochrome pixmap, with alpha channels on those two colors. - // Pretty unlikely, so use less efficient solution. - return convertDepth(8, conversion_flags) - .createAlphaMask( conversion_flags ); - } - - QImage mask1; - dither_to_1( this, &mask1, conversion_flags, true ); - return mask1; -} -#endif - -#ifndef QT_NO_IMAGE_HEURISTIC_MASK -/*! - Creates and returns a 1-bpp heuristic mask for this image. It - works by selecting a color from one of the corners, then chipping - away pixels of that color starting at all the edges. - - The four corners vote for which color is to be masked away. In - case of a draw (this generally means that this function is not - applicable to the image), the result is arbitrary. - - The returned image has little-endian bit order, which you can - convert to big-endianness using convertBitOrder(). - - If \a clipTight is TRUE the mask is just large enough to cover the - pixels; otherwise, the mask is larger than the data pixels. - - This function disregards the \link hasAlphaBuffer() alpha buffer - \endlink. - - \sa createAlphaMask() -*/ - -QImage QImage::createHeuristicMask( bool clipTight ) const -{ - if ( isNull() ) { - QImage nullImage; - return nullImage; - } - if ( depth() != 32 ) { - QImage img32 = convertDepth(32); - return img32.createHeuristicMask(clipTight); - } - -#define PIX(x,y) (*((QRgb*)scanLine(y)+x) & 0x00ffffff) - - int w = width(); - int h = height(); - QImage m(w, h, 1, 2, QImage::LittleEndian); - m.setColor( 0, 0xffffff ); - m.setColor( 1, 0 ); - m.fill( 0xff ); - - QRgb background = PIX(0,0); - if ( background != PIX(w-1,0) && - background != PIX(0,h-1) && - background != PIX(w-1,h-1) ) { - background = PIX(w-1,0); - if ( background != PIX(w-1,h-1) && - background != PIX(0,h-1) && - PIX(0,h-1) == PIX(w-1,h-1) ) { - background = PIX(w-1,h-1); - } - } - - int x,y; - bool done = false; - uchar *ypp, *ypc, *ypn; - while( !done ) { - done = true; - ypn = m.scanLine(0); - ypc = 0; - for ( y = 0; y < h; y++ ) { - ypp = ypc; - ypc = ypn; - ypn = (y == h-1) ? 0 : m.scanLine(y+1); - QRgb *p = (QRgb *)scanLine(y); - for ( x = 0; x < w; x++ ) { - // slowness here - it's possible to do six of these tests - // together in one go. oh well. - if ( ( x == 0 || y == 0 || x == w-1 || y == h-1 || - !(*(ypc + ((x-1) >> 3)) & (1 << ((x-1) & 7))) || - !(*(ypc + ((x+1) >> 3)) & (1 << ((x+1) & 7))) || - !(*(ypp + (x >> 3)) & (1 << (x & 7))) || - !(*(ypn + (x >> 3)) & (1 << (x & 7))) ) && - ( (*(ypc + (x >> 3)) & (1 << (x & 7))) ) && - ( (*p & 0x00ffffff) == background ) ) { - done = true; - *(ypc + (x >> 3)) &= ~(1 << (x & 7)); - } - p++; - } - } - } - - if ( !clipTight ) { - ypn = m.scanLine(0); - ypc = 0; - for ( y = 0; y < h; y++ ) { - ypp = ypc; - ypc = ypn; - ypn = (y == h-1) ? 0 : m.scanLine(y+1); - QRgb *p = (QRgb *)scanLine(y); - for ( x = 0; x < w; x++ ) { - if ( (*p & 0x00ffffff) != background ) { - if ( x > 0 ) - *(ypc + ((x-1) >> 3)) |= (1 << ((x-1) & 7)); - if ( x < w-1 ) - *(ypc + ((x+1) >> 3)) |= (1 << ((x+1) & 7)); - if ( y > 0 ) - *(ypp + (x >> 3)) |= (1 << (x & 7)); - if ( y < h-1 ) - *(ypn + (x >> 3)) |= (1 << (x & 7)); - } - p++; - } - } - } - -#undef PIX - - return m; -} -#endif //QT_NO_IMAGE_HEURISTIC_MASK - -#ifndef QT_NO_IMAGE_MIRROR -/* - This code is contributed by Philipp Lang, - GeneriCom Software Germany (www.generi.com) - under the terms of the QPL, Version 1.0 -*/ - -/*! - \overload - - Returns a mirror of the image, mirrored in the horizontal and/or - the vertical direction depending on whether \a horizontal and \a - vertical are set to TRUE or FALSE. The original image is not - changed. - - \sa smoothScale() -*/ -QImage QImage::mirror(bool horizontal, bool vertical) const -{ - int w = width(); - int h = height(); - if ( (w <= 1 && h <= 1) || (!horizontal && !vertical) ) - return copy(); - - // Create result image, copy colormap - QImage result(w, h, depth(), numColors(), bitOrder()); - memcpy(result.colorTable(), colorTable(), numColors()*sizeof(QRgb)); - result.setAlphaBuffer(hasAlphaBuffer()); - - if (depth() == 1) - w = (w+7)/8; - int dxi = horizontal ? -1 : 1; - int dxs = horizontal ? w-1 : 0; - int dyi = vertical ? -1 : 1; - int dy = vertical ? h-1: 0; - - // 1 bit, 8 bit - if (depth() == 1 || depth() == 8) { - for (int sy = 0; sy < h; sy++, dy += dyi) { - Q_UINT8* ssl = (Q_UINT8*)(data->bits[sy]); - Q_UINT8* dsl = (Q_UINT8*)(result.data->bits[dy]); - int dx = dxs; - for (int sx = 0; sx < w; sx++, dx += dxi) - dsl[dx] = ssl[sx]; - } - } -#ifndef QT_NO_IMAGE_TRUECOLOR -#ifndef QT_NO_IMAGE_16_BIT - // 16 bit - else if (depth() == 16) { - for (int sy = 0; sy < h; sy++, dy += dyi) { - Q_UINT16* ssl = (Q_UINT16*)(data->bits[sy]); - Q_UINT16* dsl = (Q_UINT16*)(result.data->bits[dy]); - int dx = dxs; - for (int sx = 0; sx < w; sx++, dx += dxi) - dsl[dx] = ssl[sx]; - } - } -#endif - // 32 bit - else if (depth() == 32) { - for (int sy = 0; sy < h; sy++, dy += dyi) { - quint32* ssl = (quint32*)(data->bits[sy]); - quint32* dsl = (quint32*)(result.data->bits[dy]); - int dx = dxs; - for (int sx = 0; sx < w; sx++, dx += dxi) - dsl[dx] = ssl[sx]; - } - } -#endif - - // special handling of 1 bit images for horizontal mirroring - if (horizontal && depth() == 1) { - int shift = width() % 8; - for (int y = h-1; y >= 0; y--) { - Q_UINT8* a0 = (Q_UINT8*)(result.data->bits[y]); - // Swap bytes - Q_UINT8* a = a0+dxs; - while (a >= a0) { - *a = bitflip[*a]; - a--; - } - // Shift bits if unaligned - if (shift != 0) { - a = a0+dxs; - Q_UINT8 c = 0; - if (bitOrder() == QImage::LittleEndian) { - while (a >= a0) { - Q_UINT8 nc = *a << shift; - *a = (*a >> (8-shift)) | c; - --a; - c = nc; - } - } else { - while (a >= a0) { - Q_UINT8 nc = *a >> shift; - *a = (*a << (8-shift)) | c; - --a; - c = nc; - } - } - } - } - } - - return result; -} - -/*! - Returns a QImage which is a vertically mirrored copy of this - image. The original QImage is not changed. -*/ - -QImage QImage::mirror() const -{ - return mirror(false,true); -} -#endif //QT_NO_IMAGE_MIRROR - -/*! - Returns a QImage in which the values of the red and blue - components of all pixels have been swapped, effectively converting - an RGB image to a BGR image. The original QImage is not changed. -*/ - -QImage QImage::swapRGB() const -{ - QImage res = copy(); - if ( !isNull() ) { -#ifndef QT_NO_IMAGE_TRUECOLOR - if ( depth() == 32 ) { - for ( int i=0; i < height(); i++ ) { - uint *p = (uint*)scanLine( i ); - uint *q = (uint*)res.scanLine( i ); - uint *end = p + width(); - while ( p < end ) { - *q = ((*p << 16) & 0xff0000) | ((*p >> 16) & 0xff) | - (*p & 0xff00ff00); - p++; - q++; - } - } -#ifndef QT_NO_IMAGE_16_BIT - } else if ( depth() == 16 ) { - qWarning( "QImage::swapRGB not implemented for 16bpp" ); -#endif - } else -#endif //QT_NO_IMAGE_TRUECOLOR - { - uint* p = (uint*)colorTable(); - uint* q = (uint*)res.colorTable(); - if ( p && q ) { - for ( int i=0; i < numColors(); i++ ) { - *q = ((*p << 16) & 0xff0000) | ((*p >> 16) & 0xff) | - (*p & 0xff00ff00); - p++; - q++; - } - } - } - } - return res; -} - -#ifndef QT_NO_IMAGEIO -/*! - Returns a string that specifies the image format of the file \a - fileName, or 0 if the file cannot be read or if the format is not - recognized. - - The QImageIO documentation lists the guaranteed supported image - formats, or use QImage::inputFormats() and QImage::outputFormats() - to get lists that include the installed formats. - - \sa load() save() -*/ - -const char* QImage::imageFormat( const QString &fileName ) -{ - return QImageIO::imageFormat( fileName ); -} - -/*! - Returns a list of image formats that are supported for image - input. - - \sa outputFormats() inputFormatList() QImageIO -*/ -QStrList QImage::inputFormats() -{ - return QImageIO::inputFormats(); -} -#ifndef QT_NO_STRINGLIST -/*! - Returns a list of image formats that are supported for image - input. - - Note that if you want to iterate over the list, you should iterate - over a copy, e.g. - \code - QStringList list = myImage.inputFormatList(); - QStringList::const_iterator it = list.begin(); - while( it != list.end() ) { - myProcessing( *it ); - ++it; - } - \endcode - - \sa outputFormatList() inputFormats() QImageIO -*/ -QStringList QImage::inputFormatList() -{ - return QStringList::fromStrList(QImageIO::inputFormats()); -} - - -/*! - Returns a list of image formats that are supported for image - output. - - Note that if you want to iterate over the list, you should iterate - over a copy, e.g. - \code - QStringList list = myImage.outputFormatList(); - QStringList::const_iterator it = list.begin(); - while( it != list.end() ) { - myProcessing( *it ); - ++it; - } - \endcode - - \sa inputFormatList() outputFormats() QImageIO -*/ -QStringList QImage::outputFormatList() -{ - return QStringList::fromStrList(QImageIO::outputFormats()); -} -#endif //QT_NO_STRINGLIST - -/*! - Returns a list of image formats that are supported for image - output. - - \sa inputFormats() outputFormatList() QImageIO -*/ -QStrList QImage::outputFormats() -{ - return QImageIO::outputFormats(); -} - - -/*! - Loads an image from the file \a fileName. Returns TRUE if the - image was successfully loaded; otherwise returns FALSE. - - If \a format is specified, the loader attempts to read the image - using the specified format. If \a format is not specified (which - is the default), the loader reads a few bytes from the header to - guess the file format. - - The QImageIO documentation lists the supported image formats and - explains how to add extra formats. - - \sa loadFromData() save() imageFormat() QPixmap::load() QImageIO -*/ - -bool QImage::load( const QString &fileName, const char* format ) -{ - QImageIO io( fileName, format ); - bool result = io.read(); - if ( result ) - operator=( io.image() ); - return result; -} - -/*! - Loads an image from the first \a len bytes of binary data in \a - buf. Returns TRUE if the image was successfully loaded; otherwise - returns FALSE. - - If \a format is specified, the loader attempts to read the image - using the specified format. If \a format is not specified (which - is the default), the loader reads a few bytes from the header to - guess the file format. - - The QImageIO documentation lists the supported image formats and - explains how to add extra formats. - - \sa load() save() imageFormat() QPixmap::loadFromData() QImageIO -*/ - -bool QImage::loadFromData( const uchar *buf, uint len, const char *format ) -{ - QByteArray a; - a.setRawData( (char *)buf, len ); - QBuffer b( a ); - b.open( IO_ReadOnly ); - QImageIO io( &b, format ); - bool result = io.read(); - b.close(); - a.resetRawData( (char *)buf, len ); - if ( result ) - operator=( io.image() ); - return result; -} - -/*! - \overload - - Loads an image from the QByteArray \a buf. -*/ -bool QImage::loadFromData( QByteArray buf, const char *format ) -{ - return loadFromData( (const uchar *)(buf.data()), buf.size(), format ); -} - -/*! - Saves the image to the file \a fileName, using the image file - format \a format and a quality factor of \a quality. \a quality - must be in the range 0..100 or -1. Specify 0 to obtain small - compressed files, 100 for large uncompressed files, and -1 (the - default) to use the default settings. - - Returns TRUE if the image was successfully saved; otherwise - returns FALSE. - - \sa load() loadFromData() imageFormat() QPixmap::save() QImageIO -*/ - -bool QImage::save( const QString &fileName, const char* format, int quality ) const -{ - if ( isNull() ) - return false; // nothing to save - QImageIO io( fileName, format ); - return doImageIO( &io, quality ); -} - -/*! - \overload - - This function writes a QImage to the QIODevice, \a device. This - can be used, for example, to save an image directly into a - QByteArray: - \code - QImage image; - QByteArray ba; - QBuffer buffer( ba ); - buffer.open( IO_WriteOnly ); - image.save( &buffer, "PNG" ); // writes image into ba in PNG format - \endcode -*/ - -bool QImage::save( QIODevice* device, const char* format, int quality ) const -{ - if ( isNull() ) - return false; // nothing to save - QImageIO io( device, format ); - return doImageIO( &io, quality ); -} - -/* \internal -*/ - -bool QImage::doImageIO( QImageIO* io, int quality ) const -{ - if ( !io ) - return false; - io->setImage( *this ); -#if defined(QT_CHECK_RANGE) - if ( quality > 100 || quality < -1 ) - qWarning( "QPixmap::save: quality out of range [-1,100]" ); -#endif - if ( quality >= 0 ) - io->setQuality( qMin(quality,100) ); - return io->write(); -} -#endif //QT_NO_IMAGEIO - -/***************************************************************************** - QImage stream functions - *****************************************************************************/ -#if !defined(QT_NO_DATASTREAM) && !defined(QT_NO_IMAGEIO) -/*! - \relates QImage - - Writes the image \a image to the stream \a s as a PNG image, or as a - BMP image if the stream's version is 1. - - Note that writing the stream to a file will not produce a valid image file. - - \sa QImage::save() - \link datastreamformat.html Format of the QDataStream operators \endlink -*/ - -QDataStream &operator<<( QDataStream &s, const QImage &image ) -{ - if ( s.version() >= 5 ) { - if ( image.isNull() ) { - s << (Q_INT32) 0; // null image marker - return s; - } else { - s << (Q_INT32) 1; - // continue ... - } - } - QImageIO io; - io.setIODevice( s.device() ); - if ( s.version() == 1 ) - io.setFormat( "BMP" ); - else - io.setFormat( "PNG" ); - - io.setImage( image ); - io.write(); - return s; -} - -/*! - \relates QImage - - Reads an image from the stream \a s and stores it in \a image. - - \sa QImage::load() - \link datastreamformat.html Format of the QDataStream operators \endlink -*/ - -QDataStream &operator>>( QDataStream &s, QImage &image ) -{ - if ( s.version() >= 5 ) { - Q_INT32 nullMarker; - s >> nullMarker; - if ( !nullMarker ) { - image = QImage(); // null image - return s; - } - } - QImageIO io( s.device(), 0 ); - if ( io.read() ) - image = io.image(); - return s; -} -#endif - -/***************************************************************************** - QImageIO member functions - *****************************************************************************/ - -/*! - \class QImageIO qimage.h - - \brief The QImageIO class contains parameters for loading and - saving images. - - \ingroup images - \ingroup graphics - \ingroup io - - QImageIO contains a QIODevice object that is used for image data - I/O. The programmer can install new image file formats in addition - to those that Qt provides. - - Qt currently supports the following image file formats: PNG, BMP, - XBM, XPM and PNM. It may also support JPEG, MNG and GIF, if - specially configured during compilation. The different PNM formats - are: PBM (P1 or P4), PGM (P2 or P5), and PPM (P3 or P6). - - You don't normally need to use this class; QPixmap::load(), - QPixmap::save(), and QImage contain sufficient functionality. - - For image files that contain sequences of images, only the first - is read. See QMovie for loading multiple images. - - PBM, PGM, and PPM format \e output is always in the more condensed - raw format. PPM and PGM files with more than 256 levels of - intensity are scaled down when reading. - - \warning If you are in a country which recognizes software patents - and in which Unisys holds a patent on LZW compression and/or - decompression and you want to use GIF, Unisys may require you to - license the technology. Such countries include Canada, Japan, the - USA, France, Germany, Italy and the UK. - - GIF support may be removed completely in a future version of Qt. - We recommend using the PNG format. - - \sa QImage QPixmap QFile QMovie -*/ - -#ifndef QT_NO_IMAGEIO -struct QImageIOData -{ - const char *parameters; - int quality; - float gamma; -}; - -/*! - Constructs a QImageIO object with all parameters set to zero. -*/ - -QImageIO::QImageIO() -{ - init(); -} - -/*! - Constructs a QImageIO object with the I/O device \a ioDevice and a - \a format tag. -*/ - -QImageIO::QImageIO( QIODevice *ioDevice, const char *format ) - : frmt(format) -{ - init(); - iodev = ioDevice; -} - -/*! - Constructs a QImageIO object with the file name \a fileName and a - \a format tag. -*/ - -QImageIO::QImageIO( const QString &fileName, const char* format ) - : frmt(format), fname(fileName) -{ - init(); -} - -/*! - Contains initialization common to all QImageIO constructors. -*/ - -void QImageIO::init() -{ - d = new QImageIOData(); - d->parameters = 0; - d->quality = -1; // default quality of the current format - d->gamma=0.0f; - iostat = 0; - iodev = 0; -} - -/*! - Destroys the object and all related data. -*/ - -QImageIO::~QImageIO() -{ - if ( d->parameters ) - delete [] (char*)d->parameters; - delete d; -} - - -/***************************************************************************** - QImageIO image handler functions - *****************************************************************************/ - -class QImageHandler -{ -public: - QImageHandler( const char *f, const char *h, const QCString& fl, - image_io_handler r, image_io_handler w ); - QCString format; // image format - QRegExp header; // image header pattern - enum TMode { Untranslated=0, TranslateIn, TranslateInOut } text_mode; - image_io_handler read_image; // image read function - image_io_handler write_image; // image write function - bool obsolete; // support not "published" -}; - -QImageHandler::QImageHandler( const char *f, const char *h, const QCString& fl, - image_io_handler r, image_io_handler w ) - : format(f), header(QString::fromLatin1(h)) -{ - text_mode = Untranslated; - if ( fl.contains('t') ) - text_mode = TranslateIn; - else if ( fl.contains('T') ) - text_mode = TranslateInOut; - obsolete = fl.contains('O'); - read_image = r; - write_image = w; -} - -typedef QPtrList QIHList;// list of image handlers -static QIHList *imageHandlers = 0; -#ifndef QT_NO_COMPONENT -static QPluginManager *plugin_manager = 0; -#else -static void *plugin_manager = 0; -#endif - -void qt_init_image_plugins() -{ -#ifndef QT_NO_COMPONENT - if ( plugin_manager ) - return; - - plugin_manager = new QPluginManager( IID_QImageFormat, QApplication::libraryPaths(), "/imageformats" ); - - QStringList features = plugin_manager->featureList(); - QStringList::const_iterator it = features.begin(); - while ( it != features.end() ) { - QString str = *it; - ++it; - QInterfacePtr iface; - plugin_manager->queryInterface( str, &iface ); - if ( iface ) - iface->installIOHandler( str ); - } -#endif -} - -static void cleanup() -{ - // make sure that image handlers are delete before plugin manager - delete imageHandlers; - imageHandlers = 0; -#ifndef QT_NO_COMPONENT - delete plugin_manager; - plugin_manager = 0; -#endif -} - -void qt_init_image_handlers() // initialize image handlers -{ - if ( !imageHandlers ) { - imageHandlers = new QIHList; - Q_CHECK_PTR( imageHandlers ); - imageHandlers->setAutoDelete( true ); - qAddPostRoutine( cleanup ); -#ifndef QT_NO_IMAGEIO_PNG - qInitPngIO(); -#endif - } -} - -static QImageHandler *get_image_handler( const char *format ) -{ // get pointer to handler - qt_init_image_handlers(); - qt_init_image_plugins(); - QImageHandler *p = imageHandlers->first(); - while ( p ) { // traverse list - if ( p->format == format ) - return p; - p = imageHandlers->next(); - } - return 0; // no such handler -} - - -/*! - Defines an image I/O handler for the image format called \a - format, which is recognized using the \link qregexp.html#details - regular expression\endlink \a header, read using \a readImage and - written using \a writeImage. - - \a flags is a string of single-character flags for this format. - The only flag defined currently is T (upper case), so the only - legal value for \a flags are "T" and the empty string. The "T" - flag means that the image file is a text file, and Qt should treat - all newline conventions as equivalent. (XPM files and some PPM - files are text files for example.) - - \a format is used to select a handler to write a QImage; \a header - is used to select a handler to read an image file. - - If \a readImage is a null pointer, the QImageIO will not be able - to read images in \a format. If \a writeImage is a null pointer, - the QImageIO will not be able to write images in \a format. If - both are null, the QImageIO object is valid but useless. - - Example: - \code - void readGIF( QImageIO *image ) - { - // read the image using the image->ioDevice() - } - - void writeGIF( QImageIO *image ) - { - // write the image using the image->ioDevice() - } - - // add the GIF image handler - - QImageIO::defineIOHandler( "GIF", - "^GIF[0-9][0-9][a-z]", - 0, - readGIF, - writeGIF ); - \endcode - - Before the regex test, all the 0 bytes in the file header are - converted to 1 bytes. This is done because when Qt was - ASCII-based, QRegExp could not handle 0 bytes in strings. - - The regexp is only applied on the first 14 bytes of the file. - - (Note that if one handlerIO supports writing a format and another - supports reading it, Qt supports both reading and writing. If two - handlers support the same operation, Qt chooses one arbitrarily.) -*/ - -void QImageIO::defineIOHandler( const char *format, - const char *header, - const char *flags, - image_io_handler readImage, - image_io_handler writeImage ) -{ - qt_init_image_handlers(); - QImageHandler *p; - p = new QImageHandler( format, header, flags, - readImage, writeImage ); - Q_CHECK_PTR( p ); - imageHandlers->insert( 0, p ); -} - - -/***************************************************************************** - QImageIO normal member functions - *****************************************************************************/ - -/*! - \fn const QImage &QImageIO::image() const - - Returns the image currently set. - - \sa setImage() -*/ - -/*! - \fn int QImageIO::status() const - - Returns the image's IO status. A non-zero value indicates an - error, whereas 0 means that the IO operation was successful. - - \sa setStatus() -*/ - -/*! - \fn const char *QImageIO::format() const - - Returns the image format string or 0 if no format has been - explicitly set. -*/ - -/*! - \fn QIODevice *QImageIO::ioDevice() const - - Returns the IO device currently set. - - \sa setIODevice() -*/ - -/*! - \fn QString QImageIO::fileName() const - - Returns the file name currently set. - - \sa setFileName() -*/ - -/*! - \fn QString QImageIO::description() const - - Returns the image description string. - - \sa setDescription() -*/ - - -/*! - Sets the image to \a image. - - \sa image() -*/ - -void QImageIO::setImage( const QImage &image ) -{ - im = image; -} - -/*! - Sets the image IO status to \a status. A non-zero value indicates - an error, whereas 0 means that the IO operation was successful. - - \sa status() -*/ - -void QImageIO::setStatus( int status ) -{ - iostat = status; -} - -/*! - Sets the image format to \a format for the image to be read or - written. - - It is necessary to specify a format before writing an image, but - it is not necessary to specify a format before reading an image. - - If no format has been set, Qt guesses the image format before - reading it. If a format is set the image will only be read if it - has that format. - - \sa read() write() format() -*/ - -void QImageIO::setFormat( const char *format ) -{ - frmt = format; -} - -/*! - Sets the IO device to be used for reading or writing an image. - - Setting the IO device allows images to be read/written to any - block-oriented QIODevice. - - If \a ioDevice is not null, this IO device will override file name - settings. - - \sa setFileName() -*/ - -void QImageIO::setIODevice( QIODevice *ioDevice ) -{ - iodev = ioDevice; -} - -/*! - Sets the name of the file to read or write an image from to \a - fileName. - - \sa setIODevice() -*/ - -void QImageIO::setFileName( const QString &fileName ) -{ - fname = fileName; -} - -/*! - Returns the quality of the written image, related to the - compression ratio. - - \sa setQuality() QImage::save() -*/ - -int QImageIO::quality() const -{ - return d->quality; -} - -/*! - Sets the quality of the written image to \a q, related to the - compression ratio. - - \a q must be in the range -1..100. Specify 0 to obtain small - compressed files, 100 for large uncompressed files. (-1 signifies - the default compression.) - - \sa quality() QImage::save() -*/ - -void QImageIO::setQuality( int q ) -{ - d->quality = q; -} - -/*! - Returns the image's parameters string. - - \sa setParameters() -*/ - -const char *QImageIO::parameters() const -{ - return d->parameters; -} - -/*! - Sets the image's parameter string to \a parameters. This is for - image handlers that require special parameters. - - Although the current image formats supported by Qt ignore the - parameters string, it may be used in future extensions or by - contributions (for example, JPEG). - - \sa parameters() -*/ - -void QImageIO::setParameters( const char *parameters ) -{ - if ( d && d->parameters ) - delete [] (char*)d->parameters; - d->parameters = qstrdup( parameters ); -} - -/*! - Sets the gamma value at which the image will be viewed to \a - gamma. If the image format stores a gamma value for which the - image is intended to be used, then this setting will be used to - modify the image. Setting to 0.0 will disable gamma correction - (i.e. any specification in the file will be ignored). - - The default value is 0.0. - - \sa gamma() -*/ -void QImageIO::setGamma( float gamma ) -{ - d->gamma=gamma; -} - -/*! - Returns the gamma value at which the image will be viewed. - - \sa setGamma() -*/ -float QImageIO::gamma() const -{ - return d->gamma; -} - -/*! - Sets the image description string for image handlers that support - image descriptions to \a description. - - Currently, no image format supported by Qt uses the description - string. -*/ - -void QImageIO::setDescription( const QString &description ) -{ - descr = description; -} - - -/*! - Returns a string that specifies the image format of the file \a - fileName, or null if the file cannot be read or if the format is - not recognized. -*/ - -const char* QImageIO::imageFormat( const QString &fileName ) -{ - QFile file( fileName ); - if ( !file.open(IO_ReadOnly) ) - return 0; - const char* format = imageFormat( &file ); - file.close(); - return format; -} - -/*! - \overload - - Returns a string that specifies the image format of the image read - from IO device \a d, or 0 if the device cannot be read or if the - format is not recognized. - - Make sure that \a d is at the right position in the device (for - example, at the beginning of the file). - - \sa QIODevice::at() -*/ - -const char *QImageIO::imageFormat( QIODevice *d ) -{ - // if you change this change the documentation for defineIOHandler() - const int buflen = 14; - - char buf[buflen]; - char buf2[buflen]; - qt_init_image_handlers(); - qt_init_image_plugins(); - int pos = d->at(); // save position - int rdlen = d->readBlock( buf, buflen ); // read a few bytes - - if ( rdlen != buflen ) - return 0; - - memcpy( buf2, buf, buflen ); - - const char* format = 0; - for ( int n = 0; n < rdlen; n++ ) - if ( buf[n] == '\0' ) - buf[n] = '\001'; - if ( d->status() == IO_Ok && rdlen > 0 ) { - buf[rdlen - 1] = '\0'; - QString bufStr = QString::fromLatin1(buf); - QImageHandler *p = imageHandlers->first(); - int bestMatch = -1; - while ( p ) { - if ( p->read_image && p->header.search(bufStr) != -1 ) { - // try match with header if a read function is available - if (p->header.matchedLength() > bestMatch) { - // keep looking for best match - format = p->format; - bestMatch = p->header.matchedLength(); - } - } - p = imageHandlers->next(); - } - } - d->at( pos ); // restore position - - return format; -} - -/*! - Returns a sorted list of image formats that are supported for - image input. -*/ -QStrList QImageIO::inputFormats() -{ - QStrList result; - - qt_init_image_handlers(); - qt_init_image_plugins(); - - QImageHandler *p = imageHandlers->first(); - while ( p ) { - if ( p->read_image - && !p->obsolete - && !result.contains(p->format) ) - { - result.inSort(p->format); - } - p = imageHandlers->next(); - } - - return result; -} - -/*! - Returns a sorted list of image formats that are supported for - image output. -*/ -QStrList QImageIO::outputFormats() -{ - QStrList result; - - qt_init_image_handlers(); - qt_init_image_plugins(); - - // Include asynchronous writers (!) first. - // (None) - - QImageHandler *p = imageHandlers->first(); - while ( p ) { - if ( p->write_image - && !p->obsolete - && !result.contains(p->format) ) - { - result.inSort(p->format); - } - p = imageHandlers->next(); - } - - return result; -} - - - -/*! - Reads an image into memory and returns TRUE if the image was - successfully read; otherwise returns FALSE. - - Before reading an image you must set an IO device or a file name. - If both an IO device and a file name have been set, the IO device - will be used. - - Setting the image file format string is optional. - - Note that this function does \e not set the \link format() - format\endlink used to read the image. If you need that - information, use the imageFormat() static functions. - - Example: - - \code - QImageIO iio; - QPixmap pixmap; - iio.setFileName( "vegeburger.bmp" ); - if ( image.read() ) // ok - pixmap = iio.image(); // convert to pixmap - \endcode - - \sa setIODevice() setFileName() setFormat() write() QPixmap::load() -*/ - -bool QImageIO::read() -{ - QFile file; - const char *image_format; - QImageHandler *h; - - if ( iodev ) { // read from io device - // ok, already open - } else if ( !fname.isEmpty() ) { // read from file - file.setName( fname ); - if ( !file.open(IO_ReadOnly) ) - return false; // cannot open file - iodev = &file; - } else { // no file name or io device - return false; - } - if (frmt.isEmpty()) { - // Try to guess format - image_format = imageFormat( iodev ); // get image format - if ( !image_format ) { - if ( file.isOpen() ) { // unknown format - file.close(); - iodev = 0; - } - return false; - } - } else { - image_format = frmt; - } - - h = get_image_handler( image_format ); - if ( file.isOpen() ) { -#if !defined(Q_OS_UNIX) - if ( h && h->text_mode ) { // reopen in translated mode - file.close(); - file.open( IO_ReadOnly | IO_Translate ); - } - else -#endif - file.at( 0 ); // position to start - } - iostat = 1; // assume error - - if ( h && h->read_image ) { - (*h->read_image)( this ); - } - - if ( file.isOpen() ) { // image was read using file - file.close(); - iodev = 0; - } - return iostat == 0; // image successfully read? -} - - -/*! - Writes an image to an IO device and returns TRUE if the image was - successfully written; otherwise returns FALSE. - - Before writing an image you must set an IO device or a file name. - If both an IO device and a file name have been set, the IO device - will be used. - - The image will be written using the specified image format. - - Example: - \code - QImageIO iio; - QImage im; - im = pixmap; // convert to image - iio.setImage( im ); - iio.setFileName( "vegeburger.bmp" ); - iio.setFormat( "BMP" ); - if ( iio.write() ) - // returned TRUE if written successfully - \endcode - - \sa setIODevice() setFileName() setFormat() read() QPixmap::save() -*/ - -bool QImageIO::write() -{ - if ( frmt.isEmpty() ) - return false; - QImageHandler *h = get_image_handler( frmt ); - if ( !h && !plugin_manager) { - qt_init_image_plugins(); - h = get_image_handler( frmt ); - } - if ( !h || !h->write_image ) { -#if defined(QT_CHECK_RANGE) - qWarning( "QImageIO::write: No such image format handler: %s", - format() ); -#endif - return false; - } - QFile file; - if ( !iodev && !fname.isEmpty() ) { - file.setName( fname ); - bool translate = h->text_mode==QImageHandler::TranslateInOut; - int fmode = translate ? IO_WriteOnly|IO_Translate : IO_WriteOnly; - if ( !file.open(fmode) ) // couldn't create file - return false; - iodev = &file; - } - iostat = 1; - (*h->write_image)( this ); - if ( file.isOpen() ) { // image was written using file - file.close(); - iodev = 0; - } - return iostat == 0; // image successfully written? -} -#endif //QT_NO_IMAGEIO - -/*! - Returns an image with depth \a d, using the \a palette_count - colors pointed to by \a palette. If \a d is 1 or 8, the returned - image will have its color table ordered the same as \a palette. - - If the image needs to be modified to fit in a lower-resolution - result (e.g. converting from 32-bit to 8-bit), use the \a - conversion_flags to specify how you'd prefer this to happen. - - Note: currently no closest-color search is made. If colors are - found that are not in the palette, the palette may not be used at - all. This result should not be considered valid because it may - change in future implementations. - - Currently inefficient for non-32-bit images. - - \sa Qt::ImageConversionFlags -*/ -#ifndef QT_NO_IMAGE_TRUECOLOR -QImage QImage::convertDepthWithPalette( int d, QRgb* palette, int palette_count, int conversion_flags ) const -{ - if ( depth() == 1 ) { - return convertDepth( 8, conversion_flags ) - .convertDepthWithPalette( d, palette, palette_count, conversion_flags ); - } else if ( depth() == 8 ) { - // ### this could be easily made more efficient - return convertDepth( 32, conversion_flags ) - .convertDepthWithPalette( d, palette, palette_count, conversion_flags ); - } else { - QImage result; - convert_32_to_8( this, &result, - (conversion_flags&~Qt::DitherMode_Mask) | Qt::AvoidDither, - palette, palette_count ); - return result.convertDepth( d ); - } -} -#endif -static -bool -haveSamePalette(const QImage& a, const QImage& b) -{ - if (a.depth() != b.depth()) return false; - if (a.numColors() != b.numColors()) return false; - QRgb* ca = a.colorTable(); - QRgb* cb = b.colorTable(); - for (int i=a.numColors(); i--; ) { - if (*ca++ != *cb++) return false; - } - return true; -} - -/*! - \relates QImage - - Copies a block of pixels from \a src to \a dst. The pixels - copied from source (src) are converted according to - \a conversion_flags if it is incompatible with the destination - (\a dst). - - \a sx, \a sy is the top-left pixel in \a src, \a dx, \a dy - is the top-left position in \a dst and \a sw, \sh is the - size of the copied block. - - The copying is clipped if areas outside \a src or \a dst are - specified. - - If \a sw is -1, it is adjusted to src->width(). Similarly, if \a - sh is -1, it is adjusted to src->height(). - - Currently inefficient for non 32-bit images. -*/ -void bitBlt( QImage* dst, int dx, int dy, const QImage* src, - int sx, int sy, int sw, int sh, int conversion_flags ) -{ - // Parameter correction - if ( sw < 0 ) sw = src->width(); - if ( sh < 0 ) sh = src->height(); - if ( sx < 0 ) { dx -= sx; sw += sx; sx = 0; } - if ( sy < 0 ) { dy -= sy; sh += sy; sy = 0; } - if ( dx < 0 ) { sx -= dx; sw += dx; dx = 0; } - if ( dy < 0 ) { sy -= dy; sh += dy; dy = 0; } - if ( sx + sw > src->width() ) sw = src->width() - sx; - if ( sy + sh > src->height() ) sh = src->height() - sy; - if ( dx + sw > dst->width() ) sw = dst->width() - dx; - if ( dy + sh > dst->height() ) sh = dst->height() - dy; - if ( sw <= 0 || sh <= 0 ) return; // Nothing left to copy - if ( (dst->data == src->data) && dx==sx && dy==sy ) return; // Same pixels - - // "Easy" to copy if both same depth and one of: - // - 32 bit - // - 8 bit, identical palette - // - 1 bit, identical palette and byte-aligned area - // - if ( haveSamePalette(*dst,*src) - && ( dst->depth() != 1 || - !( (dx&7) || (sx&7) || - ((sw&7) && (sx+sw < src->width()) || - (dx+sw < dst->width()) ) ) ) ) - { - // easy to copy - } else if ( dst->depth() != 32 ) { -#ifndef QT_NO_IMAGE_TRUECOLOR - - QImage dstconv = dst->convertDepth( 32 ); - bitBlt( &dstconv, dx, dy, src, sx, sy, sw, sh, - (conversion_flags&~Qt::DitherMode_Mask) | Qt::AvoidDither ); - *dst = dstconv.convertDepthWithPalette( dst->depth(), - dst->colorTable(), dst->numColors() ); -#endif - return; - } - - // Now assume palette can be ignored - - if ( dst->depth() != src->depth() ) { - if ( (sw == src->width() && sh == src->height()) || dst->depth()==32 ) { - QImage srcconv = src->convertDepth( dst->depth(), conversion_flags ); - bitBlt( dst, dx, dy, &srcconv, sx, sy, sw, sh, conversion_flags ); - } else { - QImage srcconv = src->copy( sx, sy, sw, sh ); // ie. bitBlt - bitBlt( dst, dx, dy, &srcconv, 0, 0, sw, sh, conversion_flags ); - } - return; - } - - // Now assume both are the same depth. - - // Now assume both are 32-bit or 8-bit with compatible palettes. - - // "Easy" - - switch ( dst->depth() ) { - case 1: - { - uchar* d = dst->scanLine(dy) + dx/8; - uchar* s = src->scanLine(sy) + sx/8; - const int bw = (sw+7)/8; - if ( bw < 64 ) { - // Trust ourselves - const int dd = dst->bytesPerLine() - bw; - const int ds = src->bytesPerLine() - bw; - while ( sh-- ) { - for ( int t=bw; t--; ) - *d++ = *s++; - d += dd; - s += ds; - } - } else { - // Trust libc - const int dd = dst->bytesPerLine(); - const int ds = src->bytesPerLine(); - while ( sh-- ) { - memcpy( d, s, bw ); - d += dd; - s += ds; - } - } - } - break; - case 8: - { - uchar* d = dst->scanLine(dy) + dx; - uchar* s = src->scanLine(sy) + sx; - if ( sw < 64 ) { - // Trust ourselves - const int dd = dst->bytesPerLine() - sw; - const int ds = src->bytesPerLine() - sw; - while ( sh-- ) { - for ( int t=sw; t--; ) - *d++ = *s++; - d += dd; - s += ds; - } - } else { - // Trust libc - const int dd = dst->bytesPerLine(); - const int ds = src->bytesPerLine(); - while ( sh-- ) { - memcpy( d, s, sw ); - d += dd; - s += ds; - } - } - } - break; -#ifndef QT_NO_IMAGE_TRUECOLOR - case 32: - if ( src->hasAlphaBuffer() ) { - QRgb* d = (QRgb*)dst->scanLine(dy) + dx; - QRgb* s = (QRgb*)src->scanLine(sy) + sx; - const int dd = dst->width() - sw; - const int ds = src->width() - sw; - while ( sh-- ) { - for ( int t=sw; t--; ) { - unsigned char a = qAlpha(*s); - if ( a == 255 ) - *d++ = *s++; - else if ( a == 0 ) - ++d,++s; // nothing - else { - unsigned char r = ((qRed(*s)-qRed(*d)) * a) / 256 + qRed(*d); - unsigned char g = ((qGreen(*s)-qGreen(*d)) * a) / 256 + qGreen(*d); - unsigned char b = ((qBlue(*s)-qBlue(*d)) * a) / 256 + qBlue(*d); - a = qMax(qAlpha(*d),a); // alternatives... - *d++ = qRgba(r,g,b,a); - ++s; - } - } - d += dd; - s += ds; - } - } else { - QRgb* d = (QRgb*)dst->scanLine(dy) + dx; - QRgb* s = (QRgb*)src->scanLine(sy) + sx; - if ( sw < 64 ) { - // Trust ourselves - const int dd = dst->width() - sw; - const int ds = src->width() - sw; - while ( sh-- ) { - for ( int t=sw; t--; ) - *d++ = *s++; - d += dd; - s += ds; - } - } else { - // Trust libc - const int dd = dst->width(); - const int ds = src->width(); - const int b = sw*sizeof(QRgb); - while ( sh-- ) { - memcpy( d, s, b ); - d += dd; - s += ds; - } - } - } - break; -#endif // QT_NO_IMAGE_TRUECOLOR - } -} - - -/*! - Returns TRUE if this image and image \a i have the same contents; - otherwise returns FALSE. The comparison can be slow, unless there - is some obvious difference, such as different widths, in which - case the function will return quickly. - - \sa operator=() -*/ - -bool QImage::operator==( const QImage & i ) const -{ - // same object, or shared? - if ( i.data == data ) - return true; - // obviously different stuff? - if ( i.data->h != data->h || - i.data->w != data->w ) - return false; - // that was the fast bit... - QImage i1 = convertDepth( 32 ); - QImage i2 = i.convertDepth( 32 ); - int l; - for( l=0; l < data->h; l++ ) - if ( memcmp( i1.scanLine( l ), i2.scanLine( l ), 4*data->w ) ) - return false; - return true; -} - - -/*! - Returns TRUE if this image and image \a i have different contents; - otherwise returns FALSE. The comparison can be slow, unless there - is some obvious difference, such as different widths, in which - case the function will return quickly. - - \sa operator=() -*/ - -bool QImage::operator!=( const QImage & i ) const -{ - return !(*this == i); -} - - - - -/*! - \fn int QImage::dotsPerMeterX() const - - Returns the number of pixels that fit horizontally in a physical - meter. This and dotsPerMeterY() define the intended scale and - aspect ratio of the image. - - \sa setDotsPerMeterX() -*/ - -/*! - \fn int QImage::dotsPerMeterY() const - - Returns the number of pixels that fit vertically in a physical - meter. This and dotsPerMeterX() define the intended scale and - aspect ratio of the image. - - \sa setDotsPerMeterY() -*/ - -/*! - Sets the value returned by dotsPerMeterX() to \a x. -*/ -void QImage::setDotsPerMeterX(int x) -{ - data->dpmx = x; -} - -/*! - Sets the value returned by dotsPerMeterY() to \a y. -*/ -void QImage::setDotsPerMeterY(int y) -{ - data->dpmy = y; -} - -/*! - \fn QPoint QImage::offset() const - - Returns the number of pixels by which the image is intended to be - offset by when positioning relative to other images. -*/ - -/*! - Sets the value returned by offset() to \a p. -*/ -void QImage::setOffset(const QPoint& p) -{ - data->offset = p; -} -#ifndef QT_NO_IMAGE_TEXT -/*! - \internal - - Returns the internal QImageDataMisc object. This object will be - created if it doesn't already exist. -*/ -QImageDataMisc& QImage::misc() const -{ - if ( !data->misc ) - data->misc = new QImageDataMisc; - return *data->misc; -} - -/*! - Returns the string recorded for the keyword \a key in language \a - lang, or in a default language if \a lang is 0. -*/ -QString QImage::text(const char* key, const char* lang) const -{ - QImageTextKeyLang x(key,lang); - return misc().text_lang[x]; -} - -/*! - \overload - - Returns the string recorded for the keyword and language \a kl. -*/ -QString QImage::text(const QImageTextKeyLang& kl) const -{ - return misc().text_lang[kl]; -} - -/*! - Returns the language identifiers for which some texts are - recorded. - - Note that if you want to iterate over the list, you should iterate - over a copy, e.g. - \code - QStringList list = myImage.textLanguages(); - QStringList::const_iterator it = list.begin(); - while( it != list.end() ) { - myProcessing( *it ); - ++it; - } - \endcode - - \sa textList() text() setText() textKeys() -*/ -QStringList QImage::textLanguages() const -{ - if ( !data->misc ) - return QStringList(); - return misc().languages(); -} - -/*! - Returns the keywords for which some texts are recorded. - - Note that if you want to iterate over the list, you should iterate - over a copy, e.g. - \code - QStringList list = myImage.textKeys(); - QStringList::const_iterator it = list.begin(); - while( it != list.end() ) { - myProcessing( *it ); - ++it; - } - \endcode - - \sa textList() text() setText() textLanguages() -*/ -QStringList QImage::textKeys() const -{ - if ( !data->misc ) - return QStringList(); - return misc().keys(); -} - -/*! - Returns a list of QImageTextKeyLang objects that enumerate all the - texts key/language pairs set by setText() for this image. - - Note that if you want to iterate over the list, you should iterate - over a copy, e.g. - \code - QValueList list = myImage.textList(); - QValueList::Iterator it = list.begin(); - while( it != list.end() ) { - myProcessing( *it ); - ++it; - } - \endcode -*/ -QValueList QImage::textList() const -{ - if ( !data->misc ) - return QValueList(); - return misc().list(); -} - -/*! - Records string \a s for the keyword \a key. The \a key should be - a portable keyword recognizable by other software - some suggested - values can be found in - \link http://www.libpng.org/pub/png/spec/PNG-Chunks.html#C.Anc-text - the PNG specification\endlink. \a s can be any text. \a lang should - specify the language code (see - \link ftp://ftp.isi.edu/in-notes/1766 RFC 1766\endlink) or 0. -*/ -void QImage::setText(const char* key, const char* lang, const QString& s) -{ - QImageTextKeyLang x(key,lang); - misc().text_lang.replace(x,s); -} - -#endif // QT_NO_IMAGE_TEXT - -#ifdef Q_WS_QWS -/*! - \internal -*/ -QGfx * QImage::graphicsContext() -{ - QGfx * ret=0; - if(depth()) { - int w = qt_screen->mapToDevice( QSize(width(),height()) ).width(); - int h = qt_screen->mapToDevice( QSize(width(),height()) ).height(); - ret=QGfx::createGfx(depth(),bits(),w,h,bytesPerLine()); - } else { - qDebug("Trying to create image for null depth"); - return 0; - } - if(depth()<=8) { - QRgb * tmp=colorTable(); - int nc=numColors(); - if(tmp==0) { - static QRgb table[2] = { qRgb(255,255,255), qRgb(0,0,0) }; - tmp=table; - nc=2; - } - ret->setClut(tmp,nc); - } - return ret; -} - -#endif diff --git a/ksplash/ksplashx/qimage.h b/ksplash/ksplashx/qimage.h deleted file mode 100644 index 9c33edc9..00000000 --- a/ksplash/ksplashx/qimage.h +++ /dev/null @@ -1,430 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Definition of QImage and QImageIO classes -** -** Created : 950207 -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef QIMAGE_H -#define QIMAGE_H - -#include "qrect.h" -#include "qshared.h" - -class QImageDataMisc; // internal -class QPixmap; -#ifndef QT_NO_IMAGE_TEXT -class Q_EXPORT QImageTextKeyLang { -public: - QImageTextKeyLang(const char* k, const char* l) : key(k), lang(l) { } - QImageTextKeyLang() { } - - QCString key; - QCString lang; - - bool operator< (const QImageTextKeyLang& other) const - { return key < other.key || key==other.key && lang < other.lang; } - bool operator== (const QImageTextKeyLang& other) const - { return key==other.key && lang==other.lang; } -}; -#endif //QT_NO_IMAGE_TEXT - - -class Q_EXPORT QImage -{ -public: - enum Endian { IgnoreEndian, BigEndian, LittleEndian }; - - QImage(); - QImage( int width, int height, int depth, int numColors=0, - Endian bitOrder=IgnoreEndian ); - QImage( const QSize&, int depth, int numColors=0, - Endian bitOrder=IgnoreEndian ); -#ifndef QT_NO_IMAGEIO - explicit QImage( const QString &fileName, const char* format=0 ); - explicit QImage( const char * const xpm[] ); - explicit QImage( const QByteArray &data ); -#endif - QImage( uchar* data, int w, int h, int depth, - QRgb* colortable, int numColors, - Endian bitOrder ); -#ifdef Q_WS_QWS - QImage( uchar* data, int w, int h, int depth, int pbl, - QRgb* colortable, int numColors, - Endian bitOrder ); -#endif - QImage( const QImage & ); - ~QImage(); - - QImage &operator=( const QImage & ); - QImage &operator=( const QPixmap & ); - bool operator==( const QImage & ) const; - bool operator!=( const QImage & ) const; - void detach(); - QImage copy() const; - QImage copy(int x, int y, int w, int h, int conversion_flags=0) const; - QImage copy(const QRect&) const; -#ifndef QT_NO_MIME - static QImage fromMimeSource( const QString& abs_name ); -#endif - bool isNull() const { return data->bits == 0; } - - int width() const { return data->w; } - int height() const { return data->h; } - QSize size() const { return QSize(data->w,data->h); } - QRect rect() const { return QRect(0,0,data->w,data->h); } - int depth() const { return data->d; } - int numColors() const { return data->ncols; } - Endian bitOrder() const { return (Endian) data->bitordr; } - - QRgb color( int i ) const; - void setColor( int i, QRgb c ); - void setNumColors( int ); - - bool hasAlphaBuffer() const; - void setAlphaBuffer( bool ); - - bool allGray() const; - bool isGrayscale() const; - - uchar *bits() const; - uchar *scanLine( int ) const; - uchar **jumpTable() const; - QRgb *colorTable() const; - int byteCount() const; - int bytesPerLine() const; - -#ifdef Q_WS_QWS - QGfx * graphicsContext(); -#endif - - bool create( int width, int height, int depth, int numColors=0, - Endian bitOrder=IgnoreEndian ); - bool create( const QSize&, int depth, int numColors=0, - Endian bitOrder=IgnoreEndian ); - void reset(); - - void fill( uint pixel ); - void invertPixels( bool invertAlpha = true ); - - QImage convertDepth( int ) const; -#ifndef QT_NO_IMAGE_TRUECOLOR - QImage convertDepthWithPalette( int, QRgb* p, int pc, int cf=0 ) const; -#endif - QImage convertDepth( int, int conversion_flags ) const; - QImage convertBitOrder( Endian ) const; - - enum ScaleMode { - ScaleFree, - ScaleMin, - ScaleMax - }; -#ifndef QT_NO_IMAGE_SMOOTHSCALE - QImage smoothScale( int w, int h, ScaleMode mode=ScaleFree ) const; - QImage smoothScale( const QSize& s, ScaleMode mode=ScaleFree ) const; -#endif -#ifndef QT_NO_IMAGE_TRANSFORMATION - QImage scale( int w, int h, ScaleMode mode=ScaleFree ) const; - QImage scale( const QSize& s, ScaleMode mode=ScaleFree ) const; - QImage scaleWidth( int w ) const; - QImage scaleHeight( int h ) const; - QImage xForm( const QWMatrix &matrix ) const; -#endif - -#ifndef QT_NO_IMAGE_DITHER_TO_1 - QImage createAlphaMask( int conversion_flags=0 ) const; -#endif -#ifndef QT_NO_IMAGE_HEURISTIC_MASK - QImage createHeuristicMask( bool clipTight=true ) const; -#endif -#ifndef QT_NO_IMAGE_MIRROR - QImage mirror() const; - QImage mirror(bool horizontally, bool vertically) const; -#endif - QImage swapRGB() const; - - static Endian systemBitOrder(); - static Endian systemByteOrder(); - -#ifndef QT_NO_IMAGEIO - static const char* imageFormat( const QString &fileName ); - static QStrList inputFormats(); - static QStrList outputFormats(); -#ifndef QT_NO_STRINGLIST - static QStringList inputFormatList(); - static QStringList outputFormatList(); -#endif - bool load( const QString &fileName, const char* format=0 ); - bool loadFromData( const uchar *buf, uint len, - const char *format=0 ); - bool loadFromData( QByteArray data, const char* format=0 ); - bool save( const QString &fileName, const char* format, - int quality=-1 ) const; - bool save( QIODevice * device, const char* format, - int quality=-1 ) const; -#endif //QT_NO_IMAGEIO - - bool valid( int x, int y ) const; - int pixelIndex( int x, int y ) const; - QRgb pixel( int x, int y ) const; - void setPixel( int x, int y, uint index_or_rgb ); - - // Auxiliary data - int dotsPerMeterX() const; - int dotsPerMeterY() const; - void setDotsPerMeterX(int); - void setDotsPerMeterY(int); - QPoint offset() const; - void setOffset(const QPoint&); -#ifndef QT_NO_IMAGE_TEXT - QValueList textList() const; - QStringList textLanguages() const; - QStringList textKeys() const; - QString text(const char* key, const char* lang=0) const; - QString text(const QImageTextKeyLang&) const; - void setText(const char* key, const char* lang, const QString&); -#endif -private: - void init(); - void reinit(); - void freeBits(); - static void warningIndexRange( const char *, int ); - - struct QImageData : public QShared { // internal image data - int w; // image width - int h; // image height - int d; // image depth - int ncols; // number of colors - int nbytes; // number of bytes data - int bitordr; // bit order (1 bit depth) - QRgb *ctbl; // color table - uchar **bits; // image data - bool alpha; // alpha buffer - int dpmx; // dots per meter X (or 0) - int dpmy; // dots per meter Y (or 0) - QPoint offset; // offset in pixels -#ifndef QT_NO_IMAGE_TEXT - QImageDataMisc* misc; // less common stuff -#endif - bool ctbl_mine; // this allocated ctbl - } *data; -#ifndef QT_NO_IMAGE_TEXT - QImageDataMisc& misc() const; -#endif -#ifndef QT_NO_IMAGEIO - bool doImageIO( QImageIO* io, int quality ) const; -#endif - friend Q_EXPORT void bitBlt( QImage* dst, int dx, int dy, - const QImage* src, int sx, int sy, - int sw, int sh, int conversion_flags ); -}; - - -// QImage stream functions - -#if !defined(QT_NO_DATASTREAM) && !defined(QT_NO_IMAGEIO) -Q_EXPORT QDataStream &operator<<( QDataStream &, const QImage & ); -Q_EXPORT QDataStream &operator>>( QDataStream &, QImage & ); -#endif - -#ifndef QT_NO_IMAGEIO -class QIODevice; -typedef void (*image_io_handler)( QImageIO * ); // image IO handler - - -struct QImageIOData; - - -class Q_EXPORT QImageIO -{ -public: - QImageIO(); - QImageIO( QIODevice *ioDevice, const char *format ); - QImageIO( const QString &fileName, const char* format ); - ~QImageIO(); - - - const QImage &image() const { return im; } - int status() const { return iostat; } - const char *format() const { return frmt; } - QIODevice *ioDevice() const { return iodev; } - QString fileName() const { return fname; } - int quality() const; - QString description() const { return descr; } - const char *parameters() const; - float gamma() const; - - void setImage( const QImage & ); - void setStatus( int ); - void setFormat( const char * ); - void setIODevice( QIODevice * ); - void setFileName( const QString & ); - void setQuality( int ); - void setDescription( const QString & ); - void setParameters( const char * ); - void setGamma( float ); - - bool read(); - bool write(); - - static const char* imageFormat( const QString &fileName ); - static const char *imageFormat( QIODevice * ); - static QStrList inputFormats(); - static QStrList outputFormats(); - - static void defineIOHandler( const char *format, - const char *header, - const char *flags, - image_io_handler read_image, - image_io_handler write_image ); - -private: - void init(); - - QImage im; // image - int iostat; // IO status - QCString frmt; // image format - QIODevice *iodev; // IO device - QString fname; // file name - char *params; // image parameters //### change to QImageIOData *d in 3.0 - QString descr; // image description - QImageIOData *d; - -private: // Disabled copy constructor and operator= -#if defined(Q_DISABLE_COPY) - QImageIO( const QImageIO & ); - QImageIO &operator=( const QImageIO & ); -#endif -}; - -#endif //QT_NO_IMAGEIO - -Q_EXPORT void bitBlt( QImage* dst, int dx, int dy, const QImage* src, - int sx=0, int sy=0, int sw=-1, int sh=-1, - int conversion_flags=0 ); - - -/***************************************************************************** - QImage member functions - *****************************************************************************/ - -inline bool QImage::hasAlphaBuffer() const -{ - return data->alpha; -} - -inline uchar *QImage::bits() const -{ - return data->bits ? data->bits[0] : 0; -} - -inline uchar **QImage::jumpTable() const -{ - return data->bits; -} - -inline QRgb *QImage::colorTable() const -{ - return data->ctbl; -} - -inline int QImage::byteCount() const -{ - return data->nbytes; -} - -inline int QImage::bytesPerLine() const -{ - return data->h ? data->nbytes/data->h : 0; -} - -inline QImage QImage::copy(const QRect& r) const -{ - return copy(r.x(), r.y(), r.width(), r.height()); -} - -inline QRgb QImage::color( int i ) const -{ -#if defined(QT_CHECK_RANGE) - if ( i >= data->ncols ) - warningIndexRange( "color", i ); -#endif - return data->ctbl ? data->ctbl[i] : (QRgb)-1; -} - -inline void QImage::setColor( int i, QRgb c ) -{ -#if defined(QT_CHECK_RANGE) - if ( i >= data->ncols ) - warningIndexRange( "setColor", i ); -#endif - if ( data->ctbl ) - data->ctbl[i] = c; -} - -inline uchar *QImage::scanLine( int i ) const -{ -#if defined(QT_CHECK_RANGE) - if ( i >= data->h ) - warningIndexRange( "scanLine", i ); -#endif - return data->bits ? data->bits[i] : 0; -} - -inline int QImage::dotsPerMeterX() const -{ - return data->dpmx; -} - -inline int QImage::dotsPerMeterY() const -{ - return data->dpmy; -} - -inline QPoint QImage::offset() const -{ - return data->offset; -} - - -#endif // QIMAGE_H diff --git a/ksplash/ksplashx/qnamespace.h b/ksplash/ksplashx/qnamespace.h deleted file mode 100644 index 7c2e4b98..00000000 --- a/ksplash/ksplashx/qnamespace.h +++ /dev/null @@ -1,915 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Definition of Qt namespace (as class for compiler compatibility) -** -** Created : 980927 -** -** Copyright (C) 1992-2003 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef QNAMESPACE_H -#define QNAMESPACE_H - -#ifndef QT_H -#include "qglobal.h" -#endif // QT_H - - -class QColor; -class QCursor; - - -class Q_EXPORT Qt { -public: - QT_STATIC_CONST QColor & color0; - QT_STATIC_CONST QColor & color1; - QT_STATIC_CONST QColor & black; - QT_STATIC_CONST QColor & white; - QT_STATIC_CONST QColor & darkGray; - QT_STATIC_CONST QColor & gray; - QT_STATIC_CONST QColor & lightGray; - QT_STATIC_CONST QColor & red; - QT_STATIC_CONST QColor & green; - QT_STATIC_CONST QColor & blue; - QT_STATIC_CONST QColor & cyan; - QT_STATIC_CONST QColor & magenta; - QT_STATIC_CONST QColor & yellow; - QT_STATIC_CONST QColor & darkRed; - QT_STATIC_CONST QColor & darkGreen; - QT_STATIC_CONST QColor & darkBlue; - QT_STATIC_CONST QColor & darkCyan; - QT_STATIC_CONST QColor & darkMagenta; - QT_STATIC_CONST QColor & darkYellow; - - // documented in qevent.cpp - enum ButtonState { // mouse/keyboard state values - NoButton = 0x0000, - LeftButton = 0x0001, - RightButton = 0x0002, - MidButton = 0x0004, - MouseButtonMask = 0x0007, - ShiftButton = 0x0100, - ControlButton = 0x0200, - AltButton = 0x0400, - MetaButton = 0x0800, - KeyButtonMask = 0x0f00, - Keypad = 0x4000 - }; - - // documented in qobject.cpp - // ideally would start at 1, as in QSizePolicy, but that breaks other things - enum Orientation { - Horizontal = 0, - Vertical - }; - - // documented in qlistview.cpp - enum SortOrder { - Ascending, - Descending - }; - - // Text formatting flags for QPainter::drawText and QLabel - // the following four enums can be combined to one integer which - // is passed as textflag to drawText and qt_format_text. - - // documented in qpainter.cpp - enum AlignmentFlags { - AlignAuto = 0x0000, // text alignment - AlignLeft = 0x0001, - AlignRight = 0x0002, - AlignHCenter = 0x0004, - AlignJustify = 0x0008, - AlignHorizontal_Mask = AlignLeft | AlignRight | AlignHCenter | AlignJustify, - AlignTop = 0x0010, - AlignBottom = 0x0020, - AlignVCenter = 0x0040, - AlignVertical_Mask = AlignTop | AlignBottom | AlignVCenter, - AlignCenter = AlignVCenter | AlignHCenter - }; - - // documented in qpainter.cpp - enum TextFlags { - SingleLine = 0x0080, // misc. flags - DontClip = 0x0100, - ExpandTabs = 0x0200, - ShowPrefix = 0x0400, - WordBreak = 0x0800, - BreakAnywhere = 0x1000, -#ifndef Q_QDOC - DontPrint = 0x2000, - Underline = 0x01000000, - Overline = 0x02000000, - StrikeOut = 0x04000000, - IncludeTrailingSpaces = 0x08000000, -#endif - NoAccel = 0x4000 - }; - - // Widget flags; documented in qwidget.cpp - typedef uint WState; - - // QWidget state flags (internal, barely documented in qwidget.cpp) - enum WidgetState { - WState_Created = 0x00000001, - WState_Disabled = 0x00000002, - WState_Visible = 0x00000004, - WState_ForceHide = 0x00000008, - WState_OwnCursor = 0x00000010, - WState_MouseTracking = 0x00000020, - WState_CompressKeys = 0x00000040, - WState_BlockUpdates = 0x00000080, - WState_InPaintEvent = 0x00000100, - WState_Reparented = 0x00000200, - WState_ConfigPending = 0x00000400, - WState_Resized = 0x00000800, - WState_AutoMask = 0x00001000, - WState_Polished = 0x00002000, - WState_DND = 0x00004000, - WState_Reserved0 = 0x00008000, - WState_FullScreen = 0x00010000, - WState_OwnSizePolicy = 0x00020000, - WState_CreatedHidden = 0x00040000, - WState_Maximized = 0x00080000, - WState_Minimized = 0x00100000, - WState_ForceDisabled = 0x00200000, - WState_Exposed = 0x00400000, - WState_HasMouse = 0x00800000 - }; - - // Widget flags2; documented in qwidget.cpp - typedef uint WFlags; - - // documented in qwidget.cpp - enum WidgetFlags { - WType_TopLevel = 0x00000001, // widget type flags - WType_Dialog = 0x00000002, - WType_Popup = 0x00000004, - WType_Desktop = 0x00000008, - WType_Mask = 0x0000000f, - - WStyle_Customize = 0x00000010, // window style flags - WStyle_NormalBorder = 0x00000020, - WStyle_DialogBorder = 0x00000040, // MS-Windows only - WStyle_NoBorder = 0x00002000, - WStyle_Title = 0x00000080, - WStyle_SysMenu = 0x00000100, - WStyle_Minimize = 0x00000200, - WStyle_Maximize = 0x00000400, - WStyle_MinMax = WStyle_Minimize | WStyle_Maximize, - WStyle_Tool = 0x00000800, - WStyle_StaysOnTop = 0x00001000, - WStyle_ContextHelp = 0x00004000, - WStyle_Reserved = 0x00008000, - WStyle_Mask = 0x0000fff0, - - WDestructiveClose = 0x00010000, // misc flags - WPaintDesktop = 0x00020000, - WPaintUnclipped = 0x00040000, - WPaintClever = 0x00080000, - WResizeNoErase = 0x00100000, // OBSOLETE - WMouseNoMask = 0x00200000, - WStaticContents = 0x00400000, - WRepaintNoErase = 0x00800000, // OBSOLETE -#if defined(Q_WS_X11) - WX11BypassWM = 0x01000000, - WWinOwnDC = 0x00000000, - WMacNoSheet = 0x00000000, - WMacDrawer = 0x00000000, -#else - WX11BypassWM = 0x00000000, - WWinOwnDC = 0x01000000, - WMacNoSheet = 0x00000000, - WMacDrawer = 0x00000000, -#endif - WGroupLeader = 0x02000000, - WShowModal = 0x04000000, - WNoMousePropagation = 0x08000000, - WSubWindow = 0x10000000, -#if defined(Q_WS_X11) - WStyle_Splash = 0x20000000, -#else - WStyle_Splash = WStyle_NoBorder | WMacNoSheet | WStyle_Tool | WWinOwnDC, -#endif - WNoAutoErase = WRepaintNoErase | WResizeNoErase -#ifndef QT_NO_COMPAT - , - WNorthWestGravity = WStaticContents, - WType_Modal = WType_Dialog | WShowModal, - WStyle_Dialog = WType_Dialog, - WStyle_NoBorderEx = WStyle_NoBorder -#endif - }; - - enum WindowState { - WindowNoState = 0x00000000, - WindowMinimized = 0x00000001, - WindowMaximized = 0x00000002, - WindowFullScreen = 0x00000004, - WindowActive = 0x00000008 - }; - - - // Image conversion flags. The unusual ordering is caused by - // compatibility and default requirements. - // Documented in qimage.cpp - - enum ImageConversionFlags { - ColorMode_Mask = 0x00000003, - AutoColor = 0x00000000, - ColorOnly = 0x00000003, - MonoOnly = 0x00000002, - // Reserved = 0x00000001, - - AlphaDither_Mask = 0x0000000c, - ThresholdAlphaDither = 0x00000000, - OrderedAlphaDither = 0x00000004, - DiffuseAlphaDither = 0x00000008, - NoAlpha = 0x0000000c, // Not supported - - Dither_Mask = 0x00000030, - DiffuseDither = 0x00000000, - OrderedDither = 0x00000010, - ThresholdDither = 0x00000020, - // ReservedDither= 0x00000030, - - DitherMode_Mask = 0x000000c0, - AutoDither = 0x00000000, - PreferDither = 0x00000040, - AvoidDither = 0x00000080 - }; - - // documented in qpainter.cpp - enum BGMode { // background mode - TransparentMode, - OpaqueMode - }; - -#ifndef QT_NO_COMPAT - // documented in qpainter.cpp - enum PaintUnit { // paint unit - PixelUnit, - LoMetricUnit, // OBSOLETE - HiMetricUnit, // OBSOLETE - LoEnglishUnit, // OBSOLETE - HiEnglishUnit, // OBSOLETE - TwipsUnit // OBSOLETE - }; -#endif - - // documented in qstyle.cpp -#ifdef QT_NO_COMPAT - enum GUIStyle { - WindowsStyle = 1, // ### Qt 4.0: either remove the obsolete enums or clean up compat vs. - MotifStyle = 4 // ### QT_NO_COMPAT by reordering or combination into one enum. - }; -#else - enum GUIStyle { - MacStyle, // OBSOLETE - WindowsStyle, - Win3Style, // OBSOLETE - PMStyle, // OBSOLETE - MotifStyle - }; -#endif - - // documented in qkeysequence.cpp - enum SequenceMatch { - NoMatch, - PartialMatch, - Identical - }; - - // documented in qevent.cpp - enum Modifier { // accelerator modifiers - META = 0x00100000, - SHIFT = 0x00200000, - CTRL = 0x00400000, - ALT = 0x00800000, - MODIFIER_MASK = 0x00f00000, - UNICODE_ACCEL = 0x10000000, - - ASCII_ACCEL = UNICODE_ACCEL // 1.x compat - }; - - // documented in qevent.cpp - enum Key { - Key_Escape = 0x1000, // misc keys - Key_Tab = 0x1001, - Key_Backtab = 0x1002, Key_BackTab = Key_Backtab, - Key_Backspace = 0x1003, Key_BackSpace = Key_Backspace, - Key_Return = 0x1004, - Key_Enter = 0x1005, - Key_Insert = 0x1006, - Key_Delete = 0x1007, - Key_Pause = 0x1008, - Key_Print = 0x1009, - Key_SysReq = 0x100a, - Key_Clear = 0x100b, - Key_Home = 0x1010, // cursor movement - Key_End = 0x1011, - Key_Left = 0x1012, - Key_Up = 0x1013, - Key_Right = 0x1014, - Key_Down = 0x1015, - Key_Prior = 0x1016, Key_PageUp = Key_Prior, - Key_Next = 0x1017, Key_PageDown = Key_Next, - Key_Shift = 0x1020, // modifiers - Key_Control = 0x1021, - Key_Meta = 0x1022, - Key_Alt = 0x1023, - Key_CapsLock = 0x1024, - Key_NumLock = 0x1025, - Key_ScrollLock = 0x1026, - Key_F1 = 0x1030, // function keys - Key_F2 = 0x1031, - Key_F3 = 0x1032, - Key_F4 = 0x1033, - Key_F5 = 0x1034, - Key_F6 = 0x1035, - Key_F7 = 0x1036, - Key_F8 = 0x1037, - Key_F9 = 0x1038, - Key_F10 = 0x1039, - Key_F11 = 0x103a, - Key_F12 = 0x103b, - Key_F13 = 0x103c, - Key_F14 = 0x103d, - Key_F15 = 0x103e, - Key_F16 = 0x103f, - Key_F17 = 0x1040, - Key_F18 = 0x1041, - Key_F19 = 0x1042, - Key_F20 = 0x1043, - Key_F21 = 0x1044, - Key_F22 = 0x1045, - Key_F23 = 0x1046, - Key_F24 = 0x1047, - Key_F25 = 0x1048, // F25 .. F35 only on X11 - Key_F26 = 0x1049, - Key_F27 = 0x104a, - Key_F28 = 0x104b, - Key_F29 = 0x104c, - Key_F30 = 0x104d, - Key_F31 = 0x104e, - Key_F32 = 0x104f, - Key_F33 = 0x1050, - Key_F34 = 0x1051, - Key_F35 = 0x1052, - Key_Super_L = 0x1053, // extra keys - Key_Super_R = 0x1054, - Key_Menu = 0x1055, - Key_Hyper_L = 0x1056, - Key_Hyper_R = 0x1057, - Key_Help = 0x1058, - Key_Direction_L = 0x1059, - Key_Direction_R = 0x1060, - Key_Space = 0x20, // 7 bit printable ASCII - Key_Any = Key_Space, - Key_Exclam = 0x21, - Key_QuoteDbl = 0x22, - Key_NumberSign = 0x23, - Key_Dollar = 0x24, - Key_Percent = 0x25, - Key_Ampersand = 0x26, - Key_Apostrophe = 0x27, - Key_ParenLeft = 0x28, - Key_ParenRight = 0x29, - Key_Asterisk = 0x2a, - Key_Plus = 0x2b, - Key_Comma = 0x2c, - Key_Minus = 0x2d, - Key_Period = 0x2e, - Key_Slash = 0x2f, - Key_0 = 0x30, - Key_1 = 0x31, - Key_2 = 0x32, - Key_3 = 0x33, - Key_4 = 0x34, - Key_5 = 0x35, - Key_6 = 0x36, - Key_7 = 0x37, - Key_8 = 0x38, - Key_9 = 0x39, - Key_Colon = 0x3a, - Key_Semicolon = 0x3b, - Key_Less = 0x3c, - Key_Equal = 0x3d, - Key_Greater = 0x3e, - Key_Question = 0x3f, - Key_At = 0x40, - Key_A = 0x41, - Key_B = 0x42, - Key_C = 0x43, - Key_D = 0x44, - Key_E = 0x45, - Key_F = 0x46, - Key_G = 0x47, - Key_H = 0x48, - Key_I = 0x49, - Key_J = 0x4a, - Key_K = 0x4b, - Key_L = 0x4c, - Key_M = 0x4d, - Key_N = 0x4e, - Key_O = 0x4f, - Key_P = 0x50, - Key_Q = 0x51, - Key_R = 0x52, - Key_S = 0x53, - Key_T = 0x54, - Key_U = 0x55, - Key_V = 0x56, - Key_W = 0x57, - Key_X = 0x58, - Key_Y = 0x59, - Key_Z = 0x5a, - Key_BracketLeft = 0x5b, - Key_Backslash = 0x5c, - Key_BracketRight = 0x5d, - Key_AsciiCircum = 0x5e, - Key_Underscore = 0x5f, - Key_QuoteLeft = 0x60, - Key_BraceLeft = 0x7b, - Key_Bar = 0x7c, - Key_BraceRight = 0x7d, - Key_AsciiTilde = 0x7e, - - // Latin 1 codes adapted from X: keysymdef.h,v 1.21 94/08/28 16:17:06 - - Key_nobreakspace = 0x0a0, - Key_exclamdown = 0x0a1, - Key_cent = 0x0a2, - Key_sterling = 0x0a3, - Key_currency = 0x0a4, - Key_yen = 0x0a5, - Key_brokenbar = 0x0a6, - Key_section = 0x0a7, - Key_diaeresis = 0x0a8, - Key_copyright = 0x0a9, - Key_ordfeminine = 0x0aa, - Key_guillemotleft = 0x0ab, // left angle quotation mark - Key_notsign = 0x0ac, - Key_hyphen = 0x0ad, - Key_registered = 0x0ae, - Key_macron = 0x0af, - Key_degree = 0x0b0, - Key_plusminus = 0x0b1, - Key_twosuperior = 0x0b2, - Key_threesuperior = 0x0b3, - Key_acute = 0x0b4, - Key_mu = 0x0b5, - Key_paragraph = 0x0b6, - Key_periodcentered = 0x0b7, - Key_cedilla = 0x0b8, - Key_onesuperior = 0x0b9, - Key_masculine = 0x0ba, - Key_guillemotright = 0x0bb, // right angle quotation mark - Key_onequarter = 0x0bc, - Key_onehalf = 0x0bd, - Key_threequarters = 0x0be, - Key_questiondown = 0x0bf, - Key_Agrave = 0x0c0, - Key_Aacute = 0x0c1, - Key_Acircumflex = 0x0c2, - Key_Atilde = 0x0c3, - Key_Adiaeresis = 0x0c4, - Key_Aring = 0x0c5, - Key_AE = 0x0c6, - Key_Ccedilla = 0x0c7, - Key_Egrave = 0x0c8, - Key_Eacute = 0x0c9, - Key_Ecircumflex = 0x0ca, - Key_Ediaeresis = 0x0cb, - Key_Igrave = 0x0cc, - Key_Iacute = 0x0cd, - Key_Icircumflex = 0x0ce, - Key_Idiaeresis = 0x0cf, - Key_ETH = 0x0d0, - Key_Ntilde = 0x0d1, - Key_Ograve = 0x0d2, - Key_Oacute = 0x0d3, - Key_Ocircumflex = 0x0d4, - Key_Otilde = 0x0d5, - Key_Odiaeresis = 0x0d6, - Key_multiply = 0x0d7, - Key_Ooblique = 0x0d8, - Key_Ugrave = 0x0d9, - Key_Uacute = 0x0da, - Key_Ucircumflex = 0x0db, - Key_Udiaeresis = 0x0dc, - Key_Yacute = 0x0dd, - Key_THORN = 0x0de, - Key_ssharp = 0x0df, - Key_agrave = 0x0e0, - Key_aacute = 0x0e1, - Key_acircumflex = 0x0e2, - Key_atilde = 0x0e3, - Key_adiaeresis = 0x0e4, - Key_aring = 0x0e5, - Key_ae = 0x0e6, - Key_ccedilla = 0x0e7, - Key_egrave = 0x0e8, - Key_eacute = 0x0e9, - Key_ecircumflex = 0x0ea, - Key_ediaeresis = 0x0eb, - Key_igrave = 0x0ec, - Key_iacute = 0x0ed, - Key_icircumflex = 0x0ee, - Key_idiaeresis = 0x0ef, - Key_eth = 0x0f0, - Key_ntilde = 0x0f1, - Key_ograve = 0x0f2, - Key_oacute = 0x0f3, - Key_ocircumflex = 0x0f4, - Key_otilde = 0x0f5, - Key_odiaeresis = 0x0f6, - Key_division = 0x0f7, - Key_oslash = 0x0f8, - Key_ugrave = 0x0f9, - Key_uacute = 0x0fa, - Key_ucircumflex = 0x0fb, - Key_udiaeresis = 0x0fc, - Key_yacute = 0x0fd, - Key_thorn = 0x0fe, - Key_ydiaeresis = 0x0ff, - - // multimedia/internet keys - ignored by default - see QKeyEvent c'tor - - Key_Back = 0x1061, - Key_Forward = 0x1062, - Key_Stop = 0x1063, - Key_Refresh = 0x1064, - - Key_VolumeDown = 0x1070, - Key_VolumeMute = 0x1071, - Key_VolumeUp = 0x1072, - Key_BassBoost = 0x1073, - Key_BassUp = 0x1074, - Key_BassDown = 0x1075, - Key_TrebleUp = 0x1076, - Key_TrebleDown = 0x1077, - - Key_MediaPlay = 0x1080, - Key_MediaStop = 0x1081, - Key_MediaPrev = 0x1082, - Key_MediaNext = 0x1083, - Key_MediaRecord = 0x1084, - - Key_HomePage = 0x1090, - Key_Favorites = 0x1091, - Key_Search = 0x1092, - Key_Standby = 0x1093, - Key_OpenUrl = 0x1094, - - Key_LaunchMail = 0x10a0, - Key_LaunchMedia = 0x10a1, - Key_Launch0 = 0x10a2, - Key_Launch1 = 0x10a3, - Key_Launch2 = 0x10a4, - Key_Launch3 = 0x10a5, - Key_Launch4 = 0x10a6, - Key_Launch5 = 0x10a7, - Key_Launch6 = 0x10a8, - Key_Launch7 = 0x10a9, - Key_Launch8 = 0x10aa, - Key_Launch9 = 0x10ab, - Key_LaunchA = 0x10ac, - Key_LaunchB = 0x10ad, - Key_LaunchC = 0x10ae, - Key_LaunchD = 0x10af, - Key_LaunchE = 0x10b0, - Key_LaunchF = 0x10b1, - - Key_MediaLast = 0x1fff, - - Key_unknown = 0xffff - }; - - // documented in qcommonstyle.cpp - enum ArrowType { - UpArrow, - DownArrow, - LeftArrow, - RightArrow - }; - - // documented in qpainter.cpp - enum RasterOp { // raster op mode - CopyROP, - OrROP, - XorROP, - NotAndROP, EraseROP=NotAndROP, - NotCopyROP, - NotOrROP, - NotXorROP, - AndROP, NotEraseROP=AndROP, - NotROP, - ClearROP, - SetROP, - NopROP, - AndNotROP, - OrNotROP, - NandROP, - NorROP, LastROP=NorROP - }; - - // documented in qpainter.cpp - enum PenStyle { // pen style - NoPen, - SolidLine, - DashLine, - DotLine, - DashDotLine, - DashDotDotLine, - MPenStyle = 0x0f - }; - - // documented in qpainter.cpp - enum PenCapStyle { // line endcap style - FlatCap = 0x00, - SquareCap = 0x10, - RoundCap = 0x20, - MPenCapStyle = 0x30 - }; - - // documented in qpainter.cpp - enum PenJoinStyle { // line join style - MiterJoin = 0x00, - BevelJoin = 0x40, - RoundJoin = 0x80, - MPenJoinStyle = 0xc0 - }; - - // documented in qpainter.cpp - enum BrushStyle { // brush style - NoBrush, - SolidPattern, - Dense1Pattern, - Dense2Pattern, - Dense3Pattern, - Dense4Pattern, - Dense5Pattern, - Dense6Pattern, - Dense7Pattern, - HorPattern, - VerPattern, - CrossPattern, - BDiagPattern, - FDiagPattern, - DiagCrossPattern, - CustomPattern=24 - }; - - // documented in qapplication_mac.cpp - enum MacintoshVersion { - //Unknown - MV_Unknown = 0x0000, - - //Version numbers - MV_9 = 0x0001, - MV_10_DOT_0 = 0x0002, - MV_10_DOT_1 = 0x0003, - MV_10_DOT_2 = 0x0004, - MV_10_DOT_3 = 0x0005, - - //Code names - MV_CHEETAH = MV_10_DOT_0, - MV_PUMA = MV_10_DOT_1, - MV_JAGUAR = MV_10_DOT_2, - MV_PANTHER = MV_10_DOT_3 - }; - - // documented in qapplication_win.cpp - enum WindowsVersion { - WV_32s = 0x0001, - WV_95 = 0x0002, - WV_98 = 0x0003, - WV_Me = 0x0004, - WV_DOS_based = 0x000f, - - WV_NT = 0x0010, - WV_2000 = 0x0020, - WV_XP = 0x0030, - WV_2003 = 0x0040, - WV_NT_based = 0x00f0, - - WV_CE = 0x0100, - WV_CENET = 0x0200, - WV_CE_based = 0x0f00 - }; - - // documented in qstyle.cpp - enum UIEffect { - UI_General, - UI_AnimateMenu, - UI_FadeMenu, - UI_AnimateCombo, - UI_AnimateTooltip, - UI_FadeTooltip, - UI_AnimateToolBox - }; - - // documented in qcursor.cpp - enum CursorShape { - ArrowCursor, - UpArrowCursor, - CrossCursor, - WaitCursor, - IbeamCursor, - SizeVerCursor, - SizeHorCursor, - SizeBDiagCursor, - SizeFDiagCursor, - SizeAllCursor, - BlankCursor, - SplitVCursor, - SplitHCursor, - PointingHandCursor, - ForbiddenCursor, - WhatsThisCursor, - BusyCursor, - LastCursor = BusyCursor, - BitmapCursor = 24 - }; - - // Global cursors - - QT_STATIC_CONST QCursor & arrowCursor; // standard arrow cursor - QT_STATIC_CONST QCursor & upArrowCursor; // upwards arrow - QT_STATIC_CONST QCursor & crossCursor; // crosshair - QT_STATIC_CONST QCursor & waitCursor; // hourglass/watch - QT_STATIC_CONST QCursor & ibeamCursor; // ibeam/text entry - QT_STATIC_CONST QCursor & sizeVerCursor; // vertical resize - QT_STATIC_CONST QCursor & sizeHorCursor; // horizontal resize - QT_STATIC_CONST QCursor & sizeBDiagCursor; // diagonal resize (/) - QT_STATIC_CONST QCursor & sizeFDiagCursor; // diagonal resize (\) - QT_STATIC_CONST QCursor & sizeAllCursor; // all directions resize - QT_STATIC_CONST QCursor & blankCursor; // blank/invisible cursor - QT_STATIC_CONST QCursor & splitVCursor; // vertical bar with left-right - // arrows - QT_STATIC_CONST QCursor & splitHCursor; // horizontal bar with up-down - // arrows - QT_STATIC_CONST QCursor & pointingHandCursor; // pointing hand - QT_STATIC_CONST QCursor & forbiddenCursor; // forbidden cursor (slashed circle) - QT_STATIC_CONST QCursor & whatsThisCursor; // arrow with a question mark - QT_STATIC_CONST QCursor & busyCursor; // arrow with hourglass - - - enum TextFormat { - PlainText, - RichText, - AutoText, - LogText - }; - - // Documented in qtextedit.cpp - enum AnchorAttribute { - AnchorName, - AnchorHref - }; - - // Documented in qmainwindow.cpp - enum Dock { - DockUnmanaged, - DockTornOff, - DockTop, - DockBottom, - DockRight, - DockLeft, - DockMinimized -#ifndef QT_NO_COMPAT - , - Unmanaged = DockUnmanaged, - TornOff = DockTornOff, - Top = DockTop, - Bottom = DockBottom, - Right = DockRight, - Left = DockLeft, - Minimized = DockMinimized -#endif - }; - // compatibility - typedef Dock ToolBarDock; - - // documented in qdatetime.cpp - enum DateFormat { - TextDate, // default Qt - ISODate, // ISO 8601 - LocalDate // locale dependent - }; - - // documented in qdatetime.cpp - enum TimeSpec { - LocalTime, - UTC - }; - - // documented in qwidget.cpp - enum BackgroundMode { - FixedColor, - FixedPixmap, - NoBackground, - PaletteForeground, - PaletteButton, - PaletteLight, - PaletteMidlight, - PaletteDark, - PaletteMid, - PaletteText, - PaletteBrightText, - PaletteBase, - PaletteBackground, - PaletteShadow, - PaletteHighlight, - PaletteHighlightedText, - PaletteButtonText, - PaletteLink, - PaletteLinkVisited, - X11ParentRelative - }; - - typedef uint ComparisonFlags; - - // Documented in qstring.cpp - enum StringComparisonMode { - CaseSensitive = 0x00001, // 0 0001 - BeginsWith = 0x00002, // 0 0010 - EndsWith = 0x00004, // 0 0100 - Contains = 0x00008, // 0 1000 - ExactMatch = 0x00010 // 1 0000 - }; - - // Documented in qtabwidget.cpp - enum Corner { - TopLeft = 0x00000, - TopRight = 0x00001, - BottomLeft = 0x00002, - BottomRight = 0x00003 - }; - - // "handle" type for system objects. Documented as \internal in - // qapplication.cpp -#if defined(Q_WS_X11) - typedef unsigned long HANDLE; -#elif defined(Q_WS_QWS) - typedef void * HANDLE; -#endif -}; - - -class Q_EXPORT QInternal { -public: - enum PaintDeviceFlags { - UndefinedDevice = 0x00, - Widget = 0x01, - Pixmap = 0x02, - Printer = 0x03, - Picture = 0x04, - System = 0x05, - DeviceTypeMask = 0x0f, - ExternalDevice = 0x10, - // used to emulate some of the behaviour different between Qt2 and Qt3 (mainly for printing) - CompatibilityMode = 0x20 - }; -}; - -#endif // QNAMESPACE_H diff --git a/ksplash/ksplashx/qpngio.cpp b/ksplash/ksplashx/qpngio.cpp deleted file mode 100644 index e5786b0c..00000000 --- a/ksplash/ksplashx/qpngio.cpp +++ /dev/null @@ -1,365 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Implementation of PNG QImage IOHandler -** -** Created : 970521 -** -** Copyright (C) 1992-2003 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef QT_NO_IMAGEIO_PNG - -#include "qimage.h" -#include "qcolor.h" - -#include - - -#ifdef Q_OS_TEMP -#define CALLBACK_CALL_TYPE __cdecl -#else -#define CALLBACK_CALL_TYPE -#endif - - -/* - All PNG files load to the minimal QImage equivalent. - - All QImage formats output to reasonably efficient PNG equivalents. - Never to grayscale. -*/ - -#if defined(Q_C_CALLBACKS) -extern "C" { -#endif - -static -void CALLBACK_CALL_TYPE iod_read_fn(png_structp png_ptr, png_bytep data, png_size_t length) -{ - FILE* in = (FILE*)png_get_io_ptr(png_ptr); - - while (length) { - int nr = fread( (char*)data, 1, length, in ); - if (nr <= 0) { - png_error(png_ptr, "Read Error"); - return; - } - length -= nr; - } -} - - -#if defined(Q_C_CALLBACKS) -} -#endif - -static -void setup_qt( QImage& image, png_structp png_ptr, png_infop info_ptr, float screen_gamma=0.0 ) -{ - if ( 0.0 == screen_gamma ) - // PNG docs say this is a good guess for a PC monitor - // in a dark room - screen_gamma = 2.2; - if ( png_get_valid(png_ptr, info_ptr, PNG_INFO_gAMA) ) { - // the file has a gAMA attribute - double file_gamma; - if ( png_get_gAMA(png_ptr, info_ptr, &file_gamma)) - png_set_gamma( png_ptr, screen_gamma, file_gamma ); - } else { - // no file gamma, use a reasonable default - png_set_gamma( png_ptr, screen_gamma, 0.45455 ); - } - - png_uint_32 width; - png_uint_32 height; - int bit_depth; - int color_type; - png_bytep trans_alpha = 0; - png_color_16p trans_color_p = 0; - int num_trans; - png_colorp palette = 0; - int num_palette; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0); - - if ( color_type == PNG_COLOR_TYPE_GRAY ) { - // Black & White or 8-bit grayscale - if ( bit_depth == 1 && png_get_channels(png_ptr, info_ptr) == 1 ) { - png_set_invert_mono( png_ptr ); - png_read_update_info( png_ptr, info_ptr ); - if (!image.create( width, height, 1, 2, QImage::BigEndian )) - return; - image.setColor( 1, qRgb(0,0,0) ); - image.setColor( 0, qRgb(255,255,255) ); - } else if (bit_depth == 16 && png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { - png_set_expand(png_ptr); - png_set_strip_16(png_ptr); - png_set_gray_to_rgb(png_ptr); - - if (!image.create(width, height, 32)) - return; - image.setAlphaBuffer(true); - - if (QImage::systemByteOrder() == QImage::BigEndian) - png_set_swap_alpha(png_ptr); - - png_read_update_info(png_ptr, info_ptr); - } else { - if ( bit_depth == 16 ) - png_set_strip_16(png_ptr); - else if ( bit_depth < 8 ) - png_set_packing(png_ptr); - int ncols = bit_depth < 8 ? 1 << bit_depth : 256; - png_read_update_info(png_ptr, info_ptr); - if (!image.create(width, height, 8, ncols)) - return; - for (int i=0; igray; - if (g < ncols) { - image.setColor(g, 0); - } - } - } - } else if (color_type == PNG_COLOR_TYPE_PALETTE - && png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette) - && num_palette <= 256) - { - // 1-bit and 8-bit color - if ( bit_depth != 1 ) - png_set_packing( png_ptr ); - png_read_update_info( png_ptr, info_ptr ); - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0); - if (!image.create(width, height, bit_depth, num_palette, - QImage::BigEndian)) - return; - int i = 0; - png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette); - if (png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans, &trans_color_p) && trans_alpha) { - image.setAlphaBuffer( true ); - while ( i < num_trans ) { - image.setColor(i, qRgba( - palette[i].red, - palette[i].green, - palette[i].blue, - trans_alpha[i] - ) - ); - i++; - } - } - while ( i < num_palette ) { - image.setColor(i, qRgba( - palette[i].red, - palette[i].green, - palette[i].blue, - 0xff - ) - ); - i++; - } - } else { - // 32-bit - if ( bit_depth == 16 ) - png_set_strip_16(png_ptr); - - png_set_expand(png_ptr); - - if ( color_type == PNG_COLOR_TYPE_GRAY_ALPHA ) - png_set_gray_to_rgb(png_ptr); - - if (!image.create(width, height, 32)) - return; - - // Only add filler if no alpha, or we can get 5 channel data. - if (!(color_type & PNG_COLOR_MASK_ALPHA) - && !png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { - png_set_filler(png_ptr, 0xff, - QImage::systemByteOrder() == QImage::BigEndian ? - PNG_FILLER_BEFORE : PNG_FILLER_AFTER); - // We want 4 bytes, but it isn't an alpha channel - } else { - image.setAlphaBuffer(true); - } - - if ( QImage::systemByteOrder() == QImage::BigEndian ) { - png_set_swap_alpha(png_ptr); - } - - png_read_update_info(png_ptr, info_ptr); - } - - // Qt==ARGB==Big(ARGB)==Little(BGRA) - if ( QImage::systemByteOrder() == QImage::LittleEndian ) { - png_set_bgr(png_ptr); - } -} - - -#if defined(Q_C_CALLBACKS) -extern "C" { -#endif -static void CALLBACK_CALL_TYPE qt_png_warning(png_structp /*png_ptr*/, png_const_charp message) -{ - qWarning("libpng warning: %s", message); -} - -#if defined(Q_C_CALLBACKS) -} -#endif - - -QImage splash_read_png_image(FILE* f) -{ - png_structp png_ptr; - png_infop info_ptr; - png_infop end_info; - png_bytep* row_pointers; - - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0); - if (!png_ptr) { - return QImage(); - } - - png_set_error_fn(png_ptr, 0, 0, qt_png_warning); - - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) { - png_destroy_read_struct(&png_ptr, 0, 0); - return QImage(); - } - - end_info = png_create_info_struct(png_ptr); - if (!end_info) { - png_destroy_read_struct(&png_ptr, &info_ptr, 0); - return QImage(); - } - - if (setjmp(png_jmpbuf(png_ptr))) { - png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - return QImage(); - } - - png_set_read_fn(png_ptr, (void*)f, iod_read_fn); - png_read_info(png_ptr, info_ptr); - - QImage image; - setup_qt(image, png_ptr, info_ptr, 0); - if (image.isNull()) { - png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - return QImage(); - } - - png_uint_32 width; - png_uint_32 height; - int bit_depth; - int color_type; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, - 0, 0, 0); - - uchar** jt = image.jumpTable(); - row_pointers=new png_bytep[height]; - - for (uint y=0; ytrans_values.red << 8 >> bit_depth)&0xff, - (info_ptr->trans_values.green << 8 >> bit_depth)&0xff, - (info_ptr->trans_values.blue << 8 >> bit_depth)&0xff); - for (uint y=0; ywidth; x++) { - if (((uint**)jt)[y][x] == trans) { - ((uint**)jt)[y][x] &= 0x00FFFFFF; - } else { - } - } - } - } -#endif - - image.setDotsPerMeterX(png_get_x_pixels_per_meter(png_ptr,info_ptr)); - image.setDotsPerMeterY(png_get_y_pixels_per_meter(png_ptr,info_ptr)); - -#ifndef QT_NO_IMAGE_TEXT - png_textp text_ptr; - int num_text=0; - png_get_text(png_ptr,info_ptr,&text_ptr,&num_text); - while (num_text--) { - image.setText(text_ptr->key,0,text_ptr->text); - text_ptr++; - } -#endif - - delete [] row_pointers; - - if ( image.hasAlphaBuffer() ) { - // Many PNG files lie (eg. from PhotoShop). Fortunately this loop will - // usually be quick to find those that tell the truth. - QRgb* c; - int n; - if (image.depth()==32) { - c = (QRgb*)image.bits(); - n = image.bytesPerLine() * image.height() / 4; - } else { - c = image.colorTable(); - n = image.numColors(); - } - while ( n-- && qAlpha(*c++)==0xff ) - ; - if ( n<0 ) // LIAR! - image.setAlphaBuffer(false); - } - - png_read_end(png_ptr, end_info); - png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - - return image; -} -#endif // QT_NO_IMAGEIO_PNG diff --git a/ksplash/ksplashx/qpoint.h b/ksplash/ksplashx/qpoint.h deleted file mode 100644 index 7faafdbb..00000000 --- a/ksplash/ksplashx/qpoint.h +++ /dev/null @@ -1,221 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Definition of QPoint class -** -** Created : 931028 -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef QPOINT_H -#define QPOINT_H - -#ifndef QT_H -#include "defs.h" -#endif // QT_H - - -class Q_EXPORT QPoint -{ -public: - QPoint(); - QPoint( int xpos, int ypos ); - - bool isNull() const; - - int x() const; - int y() const; - void setX( int x ); - void setY( int y ); - - int manhattanLength() const; - - QCOORD &rx(); - QCOORD &ry(); - - QPoint &operator+=( const QPoint &p ); - QPoint &operator-=( const QPoint &p ); - QPoint &operator*=( int c ); - QPoint &operator*=( double c ); - QPoint &operator/=( int c ); - QPoint &operator/=( double c ); - - friend inline bool operator==( const QPoint &, const QPoint & ); - friend inline bool operator!=( const QPoint &, const QPoint & ); - friend inline const QPoint operator+( const QPoint &, const QPoint & ); - friend inline const QPoint operator-( const QPoint &, const QPoint & ); - friend inline const QPoint operator*( const QPoint &, int ); - friend inline const QPoint operator*( int, const QPoint & ); - friend inline const QPoint operator*( const QPoint &, double ); - friend inline const QPoint operator*( double, const QPoint & ); - friend inline const QPoint operator-( const QPoint & ); - friend inline const QPoint operator/( const QPoint &, int ); - friend inline const QPoint operator/( const QPoint &, double ); - -private: - static void warningDivByZero(); - - QCOORD xp; - QCOORD yp; -}; - - -/***************************************************************************** - QPoint stream functions - *****************************************************************************/ -#ifndef QT_NO_DATASTREAM -Q_EXPORT QDataStream &operator<<( QDataStream &, const QPoint & ); -Q_EXPORT QDataStream &operator>>( QDataStream &, QPoint & ); -#endif - -/***************************************************************************** - QPoint inline functions - *****************************************************************************/ - -inline QPoint::QPoint() -{ xp=0; yp=0; } - -inline QPoint::QPoint( int xpos, int ypos ) -{ xp=(QCOORD)xpos; yp=(QCOORD)ypos; } - -inline bool QPoint::isNull() const -{ return xp == 0 && yp == 0; } - -inline int QPoint::x() const -{ return xp; } - -inline int QPoint::y() const -{ return yp; } - -inline void QPoint::setX( int x ) -{ xp = (QCOORD)x; } - -inline void QPoint::setY( int y ) -{ yp = (QCOORD)y; } - -inline QCOORD &QPoint::rx() -{ return xp; } - -inline QCOORD &QPoint::ry() -{ return yp; } - -inline QPoint &QPoint::operator+=( const QPoint &p ) -{ xp+=p.xp; yp+=p.yp; return *this; } - -inline QPoint &QPoint::operator-=( const QPoint &p ) -{ xp-=p.xp; yp-=p.yp; return *this; } - -inline QPoint &QPoint::operator*=( int c ) -{ xp*=(QCOORD)c; yp*=(QCOORD)c; return *this; } - -inline QPoint &QPoint::operator*=( double c ) -{ xp=(QCOORD)(xp*c); yp=(QCOORD)(yp*c); return *this; } - -inline bool operator==( const QPoint &p1, const QPoint &p2 ) -{ return p1.xp == p2.xp && p1.yp == p2.yp; } - -inline bool operator!=( const QPoint &p1, const QPoint &p2 ) -{ return p1.xp != p2.xp || p1.yp != p2.yp; } - -inline const QPoint operator+( const QPoint &p1, const QPoint &p2 ) -{ return QPoint(p1.xp+p2.xp, p1.yp+p2.yp); } - -inline const QPoint operator-( const QPoint &p1, const QPoint &p2 ) -{ return QPoint(p1.xp-p2.xp, p1.yp-p2.yp); } - -inline const QPoint operator*( const QPoint &p, int c ) -{ return QPoint(p.xp*c, p.yp*c); } - -inline const QPoint operator*( int c, const QPoint &p ) -{ return QPoint(p.xp*c, p.yp*c); } - -inline const QPoint operator*( const QPoint &p, double c ) -{ return QPoint((QCOORD)(p.xp*c), (QCOORD)(p.yp*c)); } - -inline const QPoint operator*( double c, const QPoint &p ) -{ return QPoint((QCOORD)(p.xp*c), (QCOORD)(p.yp*c)); } - -inline const QPoint operator-( const QPoint &p ) -{ return QPoint(-p.xp, -p.yp); } - -inline QPoint &QPoint::operator/=( int c ) -{ -#if defined(QT_CHECK_MATH) - if ( c == 0 ) - warningDivByZero(); -#endif - xp/=(QCOORD)c; - yp/=(QCOORD)c; - return *this; -} - -inline QPoint &QPoint::operator/=( double c ) -{ -#if defined(QT_CHECK_MATH) - if ( c == 0.0 ) - warningDivByZero(); -#endif - xp=(QCOORD)(xp/c); - yp=(QCOORD)(yp/c); - return *this; -} - -inline const QPoint operator/( const QPoint &p, int c ) -{ -#if defined(QT_CHECK_MATH) - if ( c == 0 ) - QPoint::warningDivByZero(); -#endif - return QPoint(p.xp/c, p.yp/c); -} - -inline const QPoint operator/( const QPoint &p, double c ) -{ -#if defined(QT_CHECK_MATH) - if ( c == 0.0 ) - QPoint::warningDivByZero(); -#endif - return QPoint((QCOORD)(p.xp/c), (QCOORD)(p.yp/c)); -} - -#define Q_DEFINED_QPOINT -#include "defs.h" -#endif // QPOINT_H diff --git a/ksplash/ksplashx/qrect.cpp b/ksplash/ksplashx/qrect.cpp deleted file mode 100644 index f05881de..00000000 --- a/ksplash/ksplashx/qrect.cpp +++ /dev/null @@ -1,967 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Implementation of QRect class -** -** Created : 931028 -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#define QRECT_C -#include "qrect.h" -#include "qdatastream.h" - -/*! - \class QRect - \brief The QRect class defines a rectangle in the plane. - - \ingroup images - \ingroup graphics - \mainclass - - A rectangle is internally represented as an upper-left corner and - a bottom-right corner, but it is normally expressed as an - upper-left corner and a size. - - The coordinate type is QCOORD (defined in \c qwindowdefs.h as \c - int). The minimum value of QCOORD is QCOORD_MIN (-2147483648) and - the maximum value is QCOORD_MAX (2147483647). - - Note that the size (width and height) of a rectangle might be - different from what you are used to. If the top-left corner and - the bottom-right corner are the same, the height and the width of - the rectangle will both be 1. - - Generally, \e{width = right - left + 1} and \e{height = bottom - - top + 1}. We designed it this way to make it correspond to - rectangular spaces used by drawing functions in which the width - and height denote a number of pixels. For example, drawing a - rectangle with width and height 1 draws a single pixel. - - The default coordinate system has origin (0, 0) in the top-left - corner. The positive direction of the y axis is down, and the - positive x axis is from left to right. - - A QRect can be constructed with a set of left, top, width and - height integers, from two QPoints or from a QPoint and a QSize. - After creation the dimensions can be changed, e.g. with setLeft(), - setRight(), setTop() and setBottom(), or by setting sizes, e.g. - setWidth(), setHeight() and setSize(). The dimensions can also be - changed with the move functions, e.g. moveBy(), moveCenter(), - moveBottomRight(), etc. You can also add coordinates to a - rectangle with addCoords(). - - You can test to see if a QRect contains a specific point with - contains(). You can also test to see if two QRects intersect with - intersects() (see also intersect()). To get the bounding rectangle - of two QRects use unite(). - - \sa QPoint, QSize -*/ - - -/***************************************************************************** - QRect member functions - *****************************************************************************/ - -/*! - \fn QRect::QRect() - - Constructs an invalid rectangle. -*/ - -/*! - Constructs a rectangle with \a topLeft as the top-left corner and - \a bottomRight as the bottom-right corner. -*/ - -QRect::QRect( const QPoint &topLeft, const QPoint &bottomRight ) -{ - x1 = (QCOORD)topLeft.x(); - y1 = (QCOORD)topLeft.y(); - x2 = (QCOORD)bottomRight.x(); - y2 = (QCOORD)bottomRight.y(); -} - -/*! - Constructs a rectangle with \a topLeft as the top-left corner and - \a size as the rectangle size. -*/ - -QRect::QRect( const QPoint &topLeft, const QSize &size ) -{ - x1 = (QCOORD)topLeft.x(); - y1 = (QCOORD)topLeft.y(); - x2 = (QCOORD)(x1+size.width()-1); - y2 = (QCOORD)(y1+size.height()-1); -} - -/*! - \fn QRect::QRect( int left, int top, int width, int height ) - - Constructs a rectangle with the \a top, \a left corner and \a - width and \a height. - - Example (creates three identical rectangles): - \code - QRect r1( QPoint(100,200), QPoint(110,215) ); - QRect r2( QPoint(100,200), QSize(11,16) ); - QRect r3( 100, 200, 11, 16 ); - \endcode -*/ - - -/*! - \fn bool QRect::isNull() const - - Returns TRUE if the rectangle is a null rectangle; otherwise - returns FALSE. - - A null rectangle has both the width and the height set to 0, that - is right() == left() - 1 and bottom() == top() - 1. - - Note that if right() == left() and bottom() == top(), then the - rectangle has width 1 and height 1. - - A null rectangle is also empty. - - A null rectangle is not valid. - - \sa isEmpty(), isValid() -*/ - -/*! - \fn bool QRect::isEmpty() const - - Returns TRUE if the rectangle is empty; otherwise returns FALSE. - - An empty rectangle has a left() \> right() or top() \> bottom(). - - An empty rectangle is not valid. \c{isEmpty() == !isValid()} - - \sa isNull(), isValid(), normalize() -*/ - -/*! - \fn bool QRect::isValid() const - - Returns TRUE if the rectangle is valid; otherwise returns FALSE. - - A valid rectangle has a left() \<= right() and top() \<= bottom(). - - Note that non-trivial operations like intersections are not defined - for invalid rectangles. - - \c{isValid() == !isEmpty()} - - \sa isNull(), isEmpty(), normalize() -*/ - - -/*! - Returns a normalized rectangle, i.e. a rectangle that has a - non-negative width and height. - - It swaps left and right if left() \> right(), and swaps top and - bottom if top() \> bottom(). - - \sa isValid() -*/ - -QRect QRect::normalize() const -{ - QRect r; - if ( x2 < x1 ) { // swap bad x values - r.x1 = x2; - r.x2 = x1; - } else { - r.x1 = x1; - r.x2 = x2; - } - if ( y2 < y1 ) { // swap bad y values - r.y1 = y2; - r.y2 = y1; - } else { - r.y1 = y1; - r.y2 = y2; - } - return r; -} - - -/*! - \fn int QRect::left() const - - Returns the left coordinate of the rectangle. Identical to x(). - - \sa setLeft(), right(), topLeft(), bottomLeft() -*/ - -/*! - \fn int QRect::top() const - - Returns the top coordinate of the rectangle. Identical to y(). - - \sa setTop(), bottom(), topLeft(), topRight() -*/ - -/*! - \fn int QRect::right() const - - Returns the right coordinate of the rectangle. - - \sa setRight(), left(), topRight(), bottomRight() -*/ - -/*! - \fn int QRect::bottom() const - - Returns the bottom coordinate of the rectangle. - - \sa setBottom(), top(), bottomLeft(), bottomRight() -*/ - -/*! - \fn QCOORD &QRect::rLeft() - - Returns a reference to the left coordinate of the rectangle. - - \sa rTop(), rRight(), rBottom() -*/ - -/*! - \fn QCOORD &QRect::rTop() - - Returns a reference to the top coordinate of the rectangle. - - \sa rLeft(), rRight(), rBottom() -*/ - -/*! - \fn QCOORD &QRect::rRight() - - Returns a reference to the right coordinate of the rectangle. - - \sa rLeft(), rTop(), rBottom() -*/ - -/*! - \fn QCOORD &QRect::rBottom() - - Returns a reference to the bottom coordinate of the rectangle. - - \sa rLeft(), rTop(), rRight() -*/ - -/*! - \fn int QRect::x() const - - Returns the left coordinate of the rectangle. Identical to left(). - - \sa left(), y(), setX() -*/ - -/*! - \fn int QRect::y() const - - Returns the top coordinate of the rectangle. Identical to top(). - - \sa top(), x(), setY() -*/ - -/*! - \fn void QRect::setLeft( int pos ) - - Sets the left edge of the rectangle to \a pos. May change the - width, but will never change the right edge of the rectangle. - - Identical to setX(). - - \sa left(), setTop(), setWidth() -*/ - -/*! - \fn void QRect::setTop( int pos ) - - Sets the top edge of the rectangle to \a pos. May change the - height, but will never change the bottom edge of the rectangle. - - Identical to setY(). - - \sa top(), setBottom(), setHeight() -*/ - -/*! - \fn void QRect::setRight( int pos ) - - Sets the right edge of the rectangle to \a pos. May change the - width, but will never change the left edge of the rectangle. - - \sa right(), setLeft(), setWidth() -*/ - -/*! - \fn void QRect::setBottom( int pos ) - - Sets the bottom edge of the rectangle to \a pos. May change the - height, but will never change the top edge of the rectangle. - - \sa bottom(), setTop(), setHeight() -*/ - -/*! - \fn void QRect::setX( int x ) - - Sets the x position of the rectangle (its left end) to \a x. May - change the width, but will never change the right edge of the - rectangle. - - Identical to setLeft(). - - \sa x(), setY() -*/ - -/*! - \fn void QRect::setY( int y ) - - Sets the y position of the rectangle (its top) to \a y. May change - the height, but will never change the bottom edge of the - rectangle. - - Identical to setTop(). - - \sa y(), setX() -*/ - -/*! - Set the top-left corner of the rectangle to \a p. May change - the size, but will the never change the bottom-right corner of - the rectangle. - - \sa topLeft(), moveTopLeft(), setBottomRight(), setTopRight(), setBottomLeft() -*/ -void QRect::setTopLeft( const QPoint &p ) -{ - setLeft( p.x() ); - setTop( p.y() ); -} - -/*! - Set the bottom-right corner of the rectangle to \a p. May change - the size, but will the never change the top-left corner of - the rectangle. - - \sa bottomRight(), moveBottomRight(), setTopLeft(), setTopRight(), setBottomLeft() -*/ -void QRect::setBottomRight( const QPoint &p ) -{ - setRight( p.x() ); - setBottom( p.y() ); -} - -/*! - Set the top-right corner of the rectangle to \a p. May change - the size, but will the never change the bottom-left corner of - the rectangle. - - \sa topRight(), moveTopRight(), setTopLeft(), setBottomRight(), setBottomLeft() -*/ -void QRect::setTopRight( const QPoint &p ) -{ - setRight( p.x() ); - setTop( p.y() ); -} - -/*! - Set the bottom-left corner of the rectangle to \a p. May change - the size, but will the never change the top-right corner of - the rectangle. - - \sa bottomLeft(), moveBottomLeft(), setTopLeft(), setBottomRight(), setTopRight() -*/ -void QRect::setBottomLeft( const QPoint &p ) -{ - setLeft( p.x() ); - setBottom( p.y() ); -} - -/*! - \fn QPoint QRect::topLeft() const - - Returns the top-left position of the rectangle. - - \sa setTopLeft(), moveTopLeft(), bottomRight(), left(), top() -*/ - -/*! - \fn QPoint QRect::bottomRight() const - - Returns the bottom-right position of the rectangle. - - \sa setBottomRight(), moveBottomRight(), topLeft(), right(), bottom() -*/ - -/*! - \fn QPoint QRect::topRight() const - - Returns the top-right position of the rectangle. - - \sa setTopRight(), moveTopRight(), bottomLeft(), top(), right() -*/ - -/*! - \fn QPoint QRect::bottomLeft() const - - Returns the bottom-left position of the rectangle. - - \sa setBottomLeft(), moveBottomLeft(), topRight(), bottom(), left() -*/ - -/*! - \fn QPoint QRect::center() const - - Returns the center point of the rectangle. - - \sa moveCenter(), topLeft(), bottomRight(), topRight(), bottomLeft() -*/ - - -/*! - Extracts the rectangle parameters as the position \a *x, \a *y and - width \a *w and height \a *h. - - \sa setRect(), coords() -*/ - -void QRect::rect( int *x, int *y, int *w, int *h ) const -{ - *x = x1; - *y = y1; - *w = x2-x1+1; - *h = y2-y1+1; -} - -/*! - Extracts the rectangle parameters as the top-left point \a *xp1, - \a *yp1 and the bottom-right point \a *xp2, \a *yp2. - - \sa setCoords(), rect() -*/ - -void QRect::coords( int *xp1, int *yp1, int *xp2, int *yp2 ) const -{ - *xp1 = x1; - *yp1 = y1; - *xp2 = x2; - *yp2 = y2; -} - - -/*! - Sets the left position of the rectangle to \a pos, leaving the - size unchanged. - - \sa left(), setLeft(), moveTop(), moveRight(), moveBottom() -*/ -void QRect::moveLeft( int pos ) -{ - x2 += (QCOORD)(pos - x1); - x1 = (QCOORD)pos; -} - -/*! - Sets the top position of the rectangle to \a pos, leaving the - size unchanged. - - \sa top(), setTop(), moveLeft(), moveRight(), moveBottom() -*/ - -void QRect::moveTop( int pos ) -{ - y2 += (QCOORD)(pos - y1); - y1 = (QCOORD)pos; -} - -/*! - Sets the right position of the rectangle to \a pos, leaving the - size unchanged. - - \sa right(), setRight(), moveLeft(), moveTop(), moveBottom() -*/ - -void QRect::moveRight( int pos ) -{ - x1 += (QCOORD)(pos - x2); - x2 = (QCOORD)pos; -} - -/*! - Sets the bottom position of the rectangle to \a pos, leaving the - size unchanged. - - \sa bottom(), setBottom(), moveLeft(), moveTop(), moveRight() -*/ - -void QRect::moveBottom( int pos ) -{ - y1 += (QCOORD)(pos - y2); - y2 = (QCOORD)pos; -} - -/*! - Sets the top-left position of the rectangle to \a p, leaving the - size unchanged. - - \sa topLeft(), setTopLeft(), moveBottomRight(), moveTopRight(), moveBottomLeft() -*/ - -void QRect::moveTopLeft( const QPoint &p ) -{ - moveLeft( p.x() ); - moveTop( p.y() ); -} - -/*! - Sets the bottom-right position of the rectangle to \a p, leaving - the size unchanged. - - \sa bottomRight(), setBottomRight(), moveTopLeft(), moveTopRight(), moveBottomLeft() -*/ - -void QRect::moveBottomRight( const QPoint &p ) -{ - moveRight( p.x() ); - moveBottom( p.y() ); -} - -/*! - Sets the top-right position of the rectangle to \a p, leaving the - size unchanged. - - \sa topRight(), setTopRight(), moveTopLeft(), moveBottomRight(), moveBottomLeft() -*/ - -void QRect::moveTopRight( const QPoint &p ) -{ - moveRight( p.x() ); - moveTop( p.y() ); -} - -/*! - Sets the bottom-left position of the rectangle to \a p, leaving - the size unchanged. - - \sa bottomLeft(), setBottomLeft(), moveTopLeft(), moveBottomRight(), moveTopRight() -*/ - -void QRect::moveBottomLeft( const QPoint &p ) -{ - moveLeft( p.x() ); - moveBottom( p.y() ); -} - - -/*! - Sets the center point of the rectangle to \a p, leaving the size - unchanged. - - \sa center(), moveTopLeft(), moveBottomRight(), moveTopRight(), moveBottomLeft() -*/ - -void QRect::moveCenter( const QPoint &p ) -{ - QCOORD w = x2 - x1; - QCOORD h = y2 - y1; - x1 = (QCOORD)(p.x() - w/2); - y1 = (QCOORD)(p.y() - h/2); - x2 = x1 + w; - y2 = y1 + h; -} - - -/*! - Moves the rectangle \a dx along the x axis and \a dy along the y - axis, relative to the current position. Positive values move the - rectangle to the right and down. - - \sa moveTopLeft() -*/ - -void QRect::moveBy( int dx, int dy ) -{ - x1 += (QCOORD)dx; - y1 += (QCOORD)dy; - x2 += (QCOORD)dx; - y2 += (QCOORD)dy; -} - -/*! - Sets the coordinates of the rectangle's top-left corner to \a (x, - y), and its size to \a (w, h). - - \sa rect(), setCoords() -*/ - -void QRect::setRect( int x, int y, int w, int h ) -{ - x1 = (QCOORD)x; - y1 = (QCOORD)y; - x2 = (QCOORD)(x+w-1); - y2 = (QCOORD)(y+h-1); -} - -/*! - Sets the coordinates of the rectangle's top-left corner to \a - (xp1, yp1), and the coordinates of its bottom-right corner to \a - (xp2, yp2). - - \sa coords(), setRect() -*/ - -void QRect::setCoords( int xp1, int yp1, int xp2, int yp2 ) -{ - x1 = (QCOORD)xp1; - y1 = (QCOORD)yp1; - x2 = (QCOORD)xp2; - y2 = (QCOORD)yp2; -} - -/*! - Adds \a xp1, \a yp1, \a xp2 and \a yp2 respectively to the - existing coordinates of the rectangle. -*/ - -void QRect::addCoords( int xp1, int yp1, int xp2, int yp2 ) -{ - x1 += (QCOORD)xp1; - y1 += (QCOORD)yp1; - x2 += (QCOORD)xp2; - y2 += (QCOORD)yp2; -} - -/*! - \fn QSize QRect::size() const - - Returns the size of the rectangle. - - \sa width(), height() -*/ - -/*! - \fn int QRect::width() const - - Returns the width of the rectangle. The width includes both the - left and right edges, i.e. width = right - left + 1. - - \sa height(), size(), setHeight() -*/ - -/*! - \fn int QRect::height() const - - Returns the height of the rectangle. The height includes both the - top and bottom edges, i.e. height = bottom - top + 1. - - \sa width(), size(), setHeight() -*/ - -/*! - Sets the width of the rectangle to \a w. The right edge is - changed, but not the left edge. - - \sa width(), setLeft(), setRight(), setSize() -*/ - -void QRect::setWidth( int w ) -{ - x2 = (QCOORD)(x1 + w - 1); -} - -/*! - Sets the height of the rectangle to \a h. The top edge is not - moved, but the bottom edge may be moved. - - \sa height(), setTop(), setBottom(), setSize() -*/ - -void QRect::setHeight( int h ) -{ - y2 = (QCOORD)(y1 + h - 1); -} - -/*! - Sets the size of the rectangle to \a s. The top-left corner is not - moved. - - \sa size(), setWidth(), setHeight() -*/ - -void QRect::setSize( const QSize &s ) -{ - x2 = (QCOORD)(s.width() +x1-1); - y2 = (QCOORD)(s.height()+y1-1); -} - -/*! - Returns TRUE if the point \a p is inside or on the edge of the - rectangle; otherwise returns FALSE. - - If \a proper is TRUE, this function returns TRUE only if \a p is - inside (not on the edge). -*/ - -bool QRect::contains( const QPoint &p, bool proper ) const -{ - if ( proper ) - return p.x() > x1 && p.x() < x2 && - p.y() > y1 && p.y() < y2; - else - return p.x() >= x1 && p.x() <= x2 && - p.y() >= y1 && p.y() <= y2; -} - -/*! - \overload bool QRect::contains( int x, int y, bool proper ) const - - Returns TRUE if the point \a x, \a y is inside this rectangle; - otherwise returns FALSE. - - If \a proper is TRUE, this function returns TRUE only if the point - is entirely inside (not on the edge). -*/ - -/*! - \overload bool QRect::contains( int x, int y ) const - - Returns TRUE if the point \a x, \a y is inside this rectangle; - otherwise returns FALSE. -*/ - -/*! - \overload - - Returns TRUE if the rectangle \a r is inside this rectangle; - otherwise returns FALSE. - - If \a proper is TRUE, this function returns TRUE only if \a r is - entirely inside (not on the edge). - - \sa unite(), intersect(), intersects() -*/ - -bool QRect::contains( const QRect &r, bool proper ) const -{ - if ( proper ) - return r.x1 > x1 && r.x2 < x2 && r.y1 > y1 && r.y2 < y2; - else - return r.x1 >= x1 && r.x2 <= x2 && r.y1 >= y1 && r.y2 <= y2; -} - -/*! - Unites this rectangle with rectangle \a r. -*/ -QRect& QRect::operator|=(const QRect &r) -{ - *this = *this | r; - return *this; -} - -/*! - Intersects this rectangle with rectangle \a r. -*/ -QRect& QRect::operator&=(const QRect &r) -{ - *this = *this & r; - return *this; -} - - -/*! - Returns the bounding rectangle of this rectangle and rectangle \a - r. - - The bounding rectangle of a nonempty rectangle and an empty or - invalid rectangle is defined to be the nonempty rectangle. - - \sa operator|=(), operator&(), intersects(), contains() -*/ - -QRect QRect::operator|(const QRect &r) const -{ - if ( isValid() ) { - if ( r.isValid() ) { - QRect tmp; - tmp.setLeft( qMin( x1, r.x1 ) ); - tmp.setRight( qMax( x2, r.x2 ) ); - tmp.setTop( qMin( y1, r.y1 ) ); - tmp.setBottom( qMax( y2, r.y2 ) ); - return tmp; - } else { - return *this; - } - } else { - return r; - } -} - -/*! - Returns the bounding rectangle of this rectangle and rectangle \a - r. \c{r.unite(s)} is equivalent to \c{r|s}. -*/ -QRect QRect::unite( const QRect &r ) const -{ - return *this | r; -} - - -/*! - Returns the intersection of this rectangle and rectangle \a r. - - Returns an empty rectangle if there is no intersection. - - \sa operator&=(), operator|(), isEmpty(), intersects(), contains() -*/ - -QRect QRect::operator&( const QRect &r ) const -{ - QRect tmp; - tmp.x1 = qMax( x1, r.x1 ); - tmp.x2 = qMin( x2, r.x2 ); - tmp.y1 = qMax( y1, r.y1 ); - tmp.y2 = qMin( y2, r.y2 ); - return tmp; -} - -/*! - Returns the intersection of this rectangle and rectangle \a r. - \c{r.intersect(s)} is equivalent to \c{r&s}. -*/ -QRect QRect::intersect( const QRect &r ) const -{ - return *this & r; -} - -/*! - Returns TRUE if this rectangle intersects with rectangle \a r - (there is at least one pixel that is within both rectangles); - otherwise returns FALSE. - - \sa intersect(), contains() -*/ - -bool QRect::intersects( const QRect &r ) const -{ - return ( qMax( x1, r.x1 ) <= qMin( x2, r.x2 ) && - qMax( y1, r.y1 ) <= qMin( y2, r.y2 ) ); -} - - -/*! - \relates QRect - - Returns TRUE if \a r1 and \a r2 are equal; otherwise returns FALSE. -*/ - -bool operator==( const QRect &r1, const QRect &r2 ) -{ - return r1.x1==r2.x1 && r1.x2==r2.x2 && r1.y1==r2.y1 && r1.y2==r2.y2; -} - -/*! - \relates QRect - - Returns TRUE if \a r1 and \a r2 are different; otherwise returns FALSE. -*/ - -bool operator!=( const QRect &r1, const QRect &r2 ) -{ - return r1.x1!=r2.x1 || r1.x2!=r2.x2 || r1.y1!=r2.y1 || r1.y2!=r2.y2; -} - - -/***************************************************************************** - QRect stream functions - *****************************************************************************/ -#ifndef QT_NO_DATASTREAM -/*! - \relates QRect - - Writes the QRect, \a r, to the stream \a s, and returns a - reference to the stream. - - \sa \link datastreamformat.html Format of the QDataStream operators \endlink -*/ - -QDataStream &operator<<( QDataStream &s, const QRect &r ) -{ - if ( s.version() == 1 ) - s << (Q_INT16)r.left() << (Q_INT16)r.top() - << (Q_INT16)r.right() << (Q_INT16)r.bottom(); - else - s << (Q_INT32)r.left() << (Q_INT32)r.top() - << (Q_INT32)r.right() << (Q_INT32)r.bottom(); - return s; -} - -/*! - \relates QRect - - Reads a QRect from the stream \a s into rect \a r and returns a - reference to the stream. - - \sa \link datastreamformat.html Format of the QDataStream operators \endlink -*/ - -QDataStream &operator>>( QDataStream &s, QRect &r ) -{ - if ( s.version() == 1 ) { - Q_INT16 x1, y1, x2, y2; - s >> x1; s >> y1; s >> x2; s >> y2; - r.setCoords( x1, y1, x2, y2 ); - } - else { - Q_INT32 x1, y1, x2, y2; - s >> x1; s >> y1; s >> x2; s >> y2; - r.setCoords( x1, y1, x2, y2 ); - } - return s; -} -#endif // QT_NO_DATASTREAM diff --git a/ksplash/ksplashx/qrect.h b/ksplash/ksplashx/qrect.h deleted file mode 100644 index 35dd1791..00000000 --- a/ksplash/ksplashx/qrect.h +++ /dev/null @@ -1,276 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Definition of QRect class -** -** Created : 931028 -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef QRECT_H -#define QRECT_H - -#ifndef QT_H -#include "qsize.h" -#endif // QT_H - -#if defined(topLeft) -#error "Macro definition of topLeft conflicts with QRect" -// don't just silently undo people's defines: #undef topLeft -#endif - -class Q_EXPORT QRect // rectangle class -{ -public: - QRect() { x1 = y1 = 0; x2 = y2 = -1; } - QRect( const QPoint &topleft, const QPoint &bottomright ); - QRect( const QPoint &topleft, const QSize &size ); - QRect( int left, int top, int width, int height ); - - bool isNull() const; - bool isEmpty() const; - bool isValid() const; - QRect normalize() const; - - int left() const; - int top() const; - int right() const; - int bottom() const; - - QCOORD &rLeft(); - QCOORD &rTop(); - QCOORD &rRight(); - QCOORD &rBottom(); - - int x() const; - int y() const; - void setLeft( int pos ); - void setTop( int pos ); - void setRight( int pos ); - void setBottom( int pos ); - void setX( int x ); - void setY( int y ); - - void setTopLeft( const QPoint &p ); - void setBottomRight( const QPoint &p ); - void setTopRight( const QPoint &p ); - void setBottomLeft( const QPoint &p ); - - QPoint topLeft() const; - QPoint bottomRight() const; - QPoint topRight() const; - QPoint bottomLeft() const; - QPoint center() const; - - void rect( int *x, int *y, int *w, int *h ) const; - void coords( int *x1, int *y1, int *x2, int *y2 ) const; - - void moveLeft( int pos ); - void moveTop( int pos ); - void moveRight( int pos ); - void moveBottom( int pos ); - void moveTopLeft( const QPoint &p ); - void moveBottomRight( const QPoint &p ); - void moveTopRight( const QPoint &p ); - void moveBottomLeft( const QPoint &p ); - void moveCenter( const QPoint &p ); - void moveBy( int dx, int dy ); - - void setRect( int x, int y, int w, int h ); - void setCoords( int x1, int y1, int x2, int y2 ); - void addCoords( int x1, int y1, int x2, int y2 ); - - QSize size() const; - int width() const; - int height() const; - void setWidth( int w ); - void setHeight( int h ); - void setSize( const QSize &s ); - - QRect operator|(const QRect &r) const; - QRect operator&(const QRect &r) const; - QRect& operator|=(const QRect &r); - QRect& operator&=(const QRect &r); - - bool contains( const QPoint &p, bool proper=false ) const; - bool contains( int x, int y ) const; // inline methods, _don't_ merge these - bool contains( int x, int y, bool proper ) const; - bool contains( const QRect &r, bool proper=false ) const; - QRect unite( const QRect &r ) const; - QRect intersect( const QRect &r ) const; - bool intersects( const QRect &r ) const; - - friend Q_EXPORT bool operator==( const QRect &, const QRect & ); - friend Q_EXPORT bool operator!=( const QRect &, const QRect & ); - -private: -#if defined(Q_WS_X11) || defined(Q_OS_TEMP) - friend void qt_setCoords( QRect *r, int xp1, int yp1, int xp2, int yp2 ); -#endif - QCOORD x1; - QCOORD y1; - QCOORD x2; - QCOORD y2; -}; - -Q_EXPORT bool operator==( const QRect &, const QRect & ); -Q_EXPORT bool operator!=( const QRect &, const QRect & ); - - -/***************************************************************************** - QRect stream functions - *****************************************************************************/ -#ifndef QT_NO_DATASTREAM -Q_EXPORT QDataStream &operator<<( QDataStream &, const QRect & ); -Q_EXPORT QDataStream &operator>>( QDataStream &, QRect & ); -#endif - -/***************************************************************************** - QRect inline member functions - *****************************************************************************/ - -inline QRect::QRect( int left, int top, int width, int height ) -{ - x1 = (QCOORD)left; - y1 = (QCOORD)top; - x2 = (QCOORD)(left+width-1); - y2 = (QCOORD)(top+height-1); -} - -inline bool QRect::isNull() const -{ return x2 == x1-1 && y2 == y1-1; } - -inline bool QRect::isEmpty() const -{ return x1 > x2 || y1 > y2; } - -inline bool QRect::isValid() const -{ return x1 <= x2 && y1 <= y2; } - -inline int QRect::left() const -{ return x1; } - -inline int QRect::top() const -{ return y1; } - -inline int QRect::right() const -{ return x2; } - -inline int QRect::bottom() const -{ return y2; } - -inline QCOORD &QRect::rLeft() -{ return x1; } - -inline QCOORD & QRect::rTop() -{ return y1; } - -inline QCOORD & QRect::rRight() -{ return x2; } - -inline QCOORD & QRect::rBottom() -{ return y2; } - -inline int QRect::x() const -{ return x1; } - -inline int QRect::y() const -{ return y1; } - -inline void QRect::setLeft( int pos ) -{ x1 = (QCOORD)pos; } - -inline void QRect::setTop( int pos ) -{ y1 = (QCOORD)pos; } - -inline void QRect::setRight( int pos ) -{ x2 = (QCOORD)pos; } - -inline void QRect::setBottom( int pos ) -{ y2 = (QCOORD)pos; } - -inline void QRect::setX( int x ) -{ x1 = (QCOORD)x; } - -inline void QRect::setY( int y ) -{ y1 = (QCOORD)y; } - -inline QPoint QRect::topLeft() const -{ return QPoint(x1, y1); } - -inline QPoint QRect::bottomRight() const -{ return QPoint(x2, y2); } - -inline QPoint QRect::topRight() const -{ return QPoint(x2, y1); } - -inline QPoint QRect::bottomLeft() const -{ return QPoint(x1, y2); } - -inline QPoint QRect::center() const -{ return QPoint((x1+x2)/2, (y1+y2)/2); } - -inline int QRect::width() const -{ return x2 - x1 + 1; } - -inline int QRect::height() const -{ return y2 - y1 + 1; } - -inline QSize QRect::size() const -{ return QSize(x2-x1+1, y2-y1+1); } - -inline bool QRect::contains( int x, int y, bool proper ) const -{ - if ( proper ) - return x > x1 && x < x2 && - y > y1 && y < y2; - else - return x >= x1 && x <= x2 && - y >= y1 && y <= y2; -} - -inline bool QRect::contains( int x, int y ) const -{ - return x >= x1 && x <= x2 && - y >= y1 && y <= y2; -} -#define Q_DEFINED_QRECT -#include "defs.h" -#endif // QRECT_H diff --git a/ksplash/ksplashx/qshared.h b/ksplash/ksplashx/qshared.h deleted file mode 100644 index 23826267..00000000 --- a/ksplash/ksplashx/qshared.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Definition of QShared struct -** -** Created : 940112 -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of the tools module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef QSHARED_H -#define QSHARED_H - -#ifndef QT_H -#include "qglobal.h" -#endif // QT_H - - -struct Q_EXPORT QShared -{ - QShared() : count( 1 ) { } - void ref() { count++; } - bool deref() { return !--count; } - uint count; -}; - - -#endif // QSHARED_H diff --git a/ksplash/ksplashx/qsize.cpp b/ksplash/ksplashx/qsize.cpp deleted file mode 100644 index 350fb1be..00000000 --- a/ksplash/ksplashx/qsize.cpp +++ /dev/null @@ -1,439 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Implementation of QSize class -** -** Created : 931028 -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "qsize.h" -#include "qdatastream.h" - - -/*! - \class QSize - \brief The QSize class defines the size of a two-dimensional object. - - \ingroup images - \ingroup graphics - - A size is specified by a width and a height. - - The coordinate type is QCOORD (defined in \c as \c int). - The minimum value of QCOORD is QCOORD_MIN (-2147483648) and the maximum - value is QCOORD_MAX (2147483647). - - The size can be set in the constructor and changed with setWidth() - and setHeight(), or using operator+=(), operator-=(), operator*=() - and operator/=(), etc. You can swap the width and height with - transpose(). You can get a size which holds the maximum height and - width of two sizes using expandedTo(), and the minimum height and - width of two sizes using boundedTo(). - - - \sa QPoint, QRect -*/ - - -/***************************************************************************** - QSize member functions - *****************************************************************************/ - -/*! - \fn QSize::QSize() - Constructs a size with invalid (negative) width and height. -*/ - -/*! - \fn QSize::QSize( int w, int h ) - Constructs a size with width \a w and height \a h. -*/ - -/*! - \fn bool QSize::isNull() const - Returns TRUE if the width is 0 and the height is 0; otherwise - returns FALSE. -*/ - -/*! - \fn bool QSize::isEmpty() const - Returns TRUE if the width is less than or equal to 0, or the height is - less than or equal to 0; otherwise returns FALSE. -*/ - -/*! - \fn bool QSize::isValid() const - Returns TRUE if the width is equal to or greater than 0 and the height is - equal to or greater than 0; otherwise returns FALSE. -*/ - -/*! - \fn int QSize::width() const - Returns the width. - \sa height() -*/ - -/*! - \fn int QSize::height() const - Returns the height. - \sa width() -*/ - -/*! - \fn void QSize::setWidth( int w ) - Sets the width to \a w. - \sa width(), setHeight() -*/ - -/*! - \fn void QSize::setHeight( int h ) - Sets the height to \a h. - \sa height(), setWidth() -*/ - -/*! - Swaps the values of width and height. -*/ - -void QSize::transpose() -{ - QCOORD tmp = wd; - wd = ht; - ht = tmp; -} - -/*! \enum QSize::ScaleMode - - This enum type defines the different ways of scaling a size. - - \img scaling.png - - \value ScaleFree The size is scaled freely. The ratio is not preserved. - \value ScaleMin The size is scaled to a rectangle as large as possible - inside a given rectangle, preserving the aspect ratio. - \value ScaleMax The size is scaled to a rectangle as small as possible - outside a given rectangle, preserving the aspect ratio. - - \sa QSize::scale(), QImage::scale(), QImage::smoothScale() -*/ - -/*! - Scales the size to a rectangle of width \a w and height \a h according - to the ScaleMode \a mode. - - \list - \i If \a mode is \c ScaleFree, the size is set to (\a w, \a h). - \i If \a mode is \c ScaleMin, the current size is scaled to a rectangle - as large as possible inside (\a w, \a h), preserving the aspect ratio. - \i If \a mode is \c ScaleMax, the current size is scaled to a rectangle - as small as possible outside (\a w, \a h), preserving the aspect ratio. - \endlist - - Example: - \code - QSize t1( 10, 12 ); - t1.scale( 60, 60, QSize::ScaleFree ); - // t1 is (60, 60) - - QSize t2( 10, 12 ); - t2.scale( 60, 60, QSize::ScaleMin ); - // t2 is (50, 60) - - QSize t3( 10, 12 ); - t3.scale( 60, 60, QSize::ScaleMax ); - // t3 is (60, 72) - \endcode -*/ -void QSize::scale( int w, int h, ScaleMode mode ) -{ - if ( mode == ScaleFree ) { - wd = (QCOORD)w; - ht = (QCOORD)h; - } else { - bool useHeight = true; - int w0 = width(); - int h0 = height(); - int rw = h * w0 / h0; - - if ( mode == ScaleMin ) { - useHeight = ( rw <= w ); - } else { // mode == ScaleMax - useHeight = ( rw >= w ); - } - - if ( useHeight ) { - wd = (QCOORD)rw; - ht = (QCOORD)h; - } else { - wd = (QCOORD)w; - ht = (QCOORD)( w * h0 / w0 ); - } - } -} - -/*! - \overload - - Equivalent to scale(\a{s}.width(), \a{s}.height(), \a mode). -*/ -void QSize::scale( const QSize &s, ScaleMode mode ) -{ - scale( s.width(), s.height(), mode ); -} - -/*! - \fn QCOORD &QSize::rwidth() - Returns a reference to the width. - - Using a reference makes it possible to directly manipulate the width. - - Example: - \code - QSize s( 100, 10 ); - s.rwidth() += 20; // s becomes (120,10) - \endcode - - \sa rheight() -*/ - -/*! - \fn QCOORD &QSize::rheight() - Returns a reference to the height. - - Using a reference makes it possible to directly manipulate the height. - - Example: - \code - QSize s( 100, 10 ); - s.rheight() += 5; // s becomes (100,15) - \endcode - - \sa rwidth() -*/ - -/*! - \fn QSize &QSize::operator+=( const QSize &s ) - - Adds \a s to the size and returns a reference to this size. - - Example: - \code - QSize s( 3, 7 ); - QSize r( -1, 4 ); - s += r; // s becomes (2,11) -\endcode -*/ - -/*! - \fn QSize &QSize::operator-=( const QSize &s ) - - Subtracts \a s from the size and returns a reference to this size. - - Example: - \code - QSize s( 3, 7 ); - QSize r( -1, 4 ); - s -= r; // s becomes (4,3) - \endcode -*/ - -/*! - \fn QSize &QSize::operator*=( int c ) - Multiplies both the width and height by \a c and returns a reference to - the size. -*/ - -/*! - \overload QSize &QSize::operator*=( double c ) - - Multiplies both the width and height by \a c and returns a reference to - the size. - - Note that the result is truncated. -*/ - -/*! - \fn bool operator==( const QSize &s1, const QSize &s2 ) - \relates QSize - Returns TRUE if \a s1 and \a s2 are equal; otherwise returns FALSE. -*/ - -/*! - \fn bool operator!=( const QSize &s1, const QSize &s2 ) - \relates QSize - Returns TRUE if \a s1 and \a s2 are different; otherwise returns FALSE. -*/ - -/*! - \fn const QSize operator+( const QSize &s1, const QSize &s2 ) - \relates QSize - Returns the sum of \a s1 and \a s2; each component is added separately. -*/ - -/*! - \fn const QSize operator-( const QSize &s1, const QSize &s2 ) - \relates QSize - Returns \a s2 subtracted from \a s1; each component is - subtracted separately. -*/ - -/*! - \fn const QSize operator*( const QSize &s, int c ) - \relates QSize - Multiplies \a s by \a c and returns the result. -*/ - -/*! - \overload const QSize operator*( int c, const QSize &s ) - \relates QSize - Multiplies \a s by \a c and returns the result. -*/ - -/*! - \overload const QSize operator*( const QSize &s, double c ) - \relates QSize - Multiplies \a s by \a c and returns the result. -*/ - -/*! - \overload const QSize operator*( double c, const QSize &s ) - \relates QSize - Multiplies \a s by \a c and returns the result. -*/ - -/*! - \fn QSize &QSize::operator/=( int c ) - Divides both the width and height by \a c and returns a reference to the - size. -*/ - -/*! - \fn QSize &QSize::operator/=( double c ) - \overload - Divides both the width and height by \a c and returns a reference to the - size. - - Note that the result is truncated. -*/ - -/*! - \fn const QSize operator/( const QSize &s, int c ) - \relates QSize - Divides \a s by \a c and returns the result. -*/ - -/*! - \fn const QSize operator/( const QSize &s, double c ) - \relates QSize - \overload - Divides \a s by \a c and returns the result. - - Note that the result is truncated. -*/ - -/*! - \fn QSize QSize::expandedTo( const QSize & otherSize ) const - - Returns a size with the maximum width and height of this size and - \a otherSize. -*/ - -/*! - \fn QSize QSize::boundedTo( const QSize & otherSize ) const - - Returns a size with the minimum width and height of this size and - \a otherSize. -*/ - - -void QSize::warningDivByZero() -{ -#if defined(QT_CHECK_MATH) - qWarning( "QSize: Division by zero error" ); -#endif -} - - -/***************************************************************************** - QSize stream functions - *****************************************************************************/ -#ifndef QT_NO_DATASTREAM -/*! - \relates QSize - Writes the size \a sz to the stream \a s and returns a reference to - the stream. - - \sa \link datastreamformat.html Format of the QDataStream operators \endlink -*/ - -QDataStream &operator<<( QDataStream &s, const QSize &sz ) -{ - if ( s.version() == 1 ) - s << (Q_INT16)sz.width() << (Q_INT16)sz.height(); - else - s << (Q_INT32)sz.width() << (Q_INT32)sz.height(); - return s; -} - -/*! - \relates QSize - Reads the size from the stream \a s into size \a sz and returns a - reference to the stream. - - \sa \link datastreamformat.html Format of the QDataStream operators \endlink -*/ - -QDataStream &operator>>( QDataStream &s, QSize &sz ) -{ - if ( s.version() == 1 ) { - Q_INT16 w, h; - s >> w; sz.rwidth() = w; - s >> h; sz.rheight() = h; - } - else { - Q_INT32 w, h; - s >> w; sz.rwidth() = w; - s >> h; sz.rheight() = h; - } - return s; -} -#endif // QT_NO_DATASTREAM diff --git a/ksplash/ksplashx/qsize.h b/ksplash/ksplashx/qsize.h deleted file mode 100644 index ea38bfc4..00000000 --- a/ksplash/ksplashx/qsize.h +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Definition of QSize class -** -** Created : 931028 -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef QSIZE_H -#define QSIZE_H - -#ifndef QT_H -#include "qpoint.h" // ### change to qwindowdefs.h? -#endif // QT_H - -class Q_EXPORT QSize -// ### Make QSize inherit Qt in Qt 4.0 -{ -public: - // ### Move this enum to qnamespace.h in Qt 4.0 - enum ScaleMode { - ScaleFree, - ScaleMin, - ScaleMax - }; - - QSize(); - QSize( int w, int h ); - - bool isNull() const; - bool isEmpty() const; - bool isValid() const; - - int width() const; - int height() const; - void setWidth( int w ); - void setHeight( int h ); - void transpose(); - - void scale( int w, int h, ScaleMode mode ); - void scale( const QSize &s, ScaleMode mode ); - - QSize expandedTo( const QSize & ) const; - QSize boundedTo( const QSize & ) const; - - QCOORD &rwidth(); - QCOORD &rheight(); - - QSize &operator+=( const QSize & ); - QSize &operator-=( const QSize & ); - QSize &operator*=( int c ); - QSize &operator*=( double c ); - QSize &operator/=( int c ); - QSize &operator/=( double c ); - - friend inline bool operator==( const QSize &, const QSize & ); - friend inline bool operator!=( const QSize &, const QSize & ); - friend inline const QSize operator+( const QSize &, const QSize & ); - friend inline const QSize operator-( const QSize &, const QSize & ); - friend inline const QSize operator*( const QSize &, int ); - friend inline const QSize operator*( int, const QSize & ); - friend inline const QSize operator*( const QSize &, double ); - friend inline const QSize operator*( double, const QSize & ); - friend inline const QSize operator/( const QSize &, int ); - friend inline const QSize operator/( const QSize &, double ); - -private: - static void warningDivByZero(); - - QCOORD wd; - QCOORD ht; -}; - - -/***************************************************************************** - QSize stream functions - *****************************************************************************/ - -#ifndef QT_NO_DATASTREAM -Q_EXPORT QDataStream &operator<<( QDataStream &, const QSize & ); -Q_EXPORT QDataStream &operator>>( QDataStream &, QSize & ); -#endif - -/***************************************************************************** - QSize inline functions - *****************************************************************************/ - -inline QSize::QSize() -{ wd = ht = -1; } - -inline QSize::QSize( int w, int h ) -{ wd=(QCOORD)w; ht=(QCOORD)h; } - -inline bool QSize::isNull() const -{ return wd==0 && ht==0; } - -inline bool QSize::isEmpty() const -{ return wd<1 || ht<1; } - -inline bool QSize::isValid() const -{ return wd>=0 && ht>=0; } - -inline int QSize::width() const -{ return wd; } - -inline int QSize::height() const -{ return ht; } - -inline void QSize::setWidth( int w ) -{ wd=(QCOORD)w; } - -inline void QSize::setHeight( int h ) -{ ht=(QCOORD)h; } - -inline QCOORD &QSize::rwidth() -{ return wd; } - -inline QCOORD &QSize::rheight() -{ return ht; } - -inline QSize &QSize::operator+=( const QSize &s ) -{ wd+=s.wd; ht+=s.ht; return *this; } - -inline QSize &QSize::operator-=( const QSize &s ) -{ wd-=s.wd; ht-=s.ht; return *this; } - -inline QSize &QSize::operator*=( int c ) -{ wd*=(QCOORD)c; ht*=(QCOORD)c; return *this; } - -inline QSize &QSize::operator*=( double c ) -{ wd=(QCOORD)(wd*c); ht=(QCOORD)(ht*c); return *this; } - -inline bool operator==( const QSize &s1, const QSize &s2 ) -{ return s1.wd == s2.wd && s1.ht == s2.ht; } - -inline bool operator!=( const QSize &s1, const QSize &s2 ) -{ return s1.wd != s2.wd || s1.ht != s2.ht; } - -inline const QSize operator+( const QSize & s1, const QSize & s2 ) -{ return QSize(s1.wd+s2.wd, s1.ht+s2.ht); } - -inline const QSize operator-( const QSize &s1, const QSize &s2 ) -{ return QSize(s1.wd-s2.wd, s1.ht-s2.ht); } - -inline const QSize operator*( const QSize &s, int c ) -{ return QSize(s.wd*c, s.ht*c); } - -inline const QSize operator*( int c, const QSize &s ) -{ return QSize(s.wd*c, s.ht*c); } - -inline const QSize operator*( const QSize &s, double c ) -{ return QSize((QCOORD)(s.wd*c), (QCOORD)(s.ht*c)); } - -inline const QSize operator*( double c, const QSize &s ) -{ return QSize((QCOORD)(s.wd*c), (QCOORD)(s.ht*c)); } - -inline QSize &QSize::operator/=( int c ) -{ -#if defined(QT_CHECK_MATH) - if ( c == 0 ) - warningDivByZero(); -#endif - wd/=(QCOORD)c; ht/=(QCOORD)c; - return *this; -} - -inline QSize &QSize::operator/=( double c ) -{ -#if defined(QT_CHECK_MATH) - if ( c == 0.0 ) - warningDivByZero(); -#endif - wd=(QCOORD)(wd/c); ht=(QCOORD)(ht/c); - return *this; -} - -inline const QSize operator/( const QSize &s, int c ) -{ -#if defined(QT_CHECK_MATH) - if ( c == 0 ) - QSize::warningDivByZero(); -#endif - return QSize(s.wd/c, s.ht/c); -} - -inline const QSize operator/( const QSize &s, double c ) -{ -#if defined(QT_CHECK_MATH) - if ( c == 0.0 ) - QSize::warningDivByZero(); -#endif - return QSize((QCOORD)(s.wd/c), (QCOORD)(s.ht/c)); -} - -inline QSize QSize::expandedTo( const QSize & otherSize ) const -{ - return QSize( qMax(wd,otherSize.wd), qMax(ht,otherSize.ht) ); -} - -inline QSize QSize::boundedTo( const QSize & otherSize ) const -{ - return QSize( qMin(wd,otherSize.wd), qMin(ht,otherSize.ht) ); -} - - -#endif // QSIZE_H diff --git a/ksplash/ksplashx/qwindowdefs.h b/ksplash/ksplashx/qwindowdefs.h deleted file mode 100644 index 94bb5caa..00000000 --- a/ksplash/ksplashx/qwindowdefs.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "defs.h" diff --git a/ksplash/ksplashx/scale.cpp b/ksplash/ksplashx/scale.cpp deleted file mode 100644 index 69392ad4..00000000 --- a/ksplash/ksplashx/scale.cpp +++ /dev/null @@ -1,1054 +0,0 @@ -// This code is Imlib2 code, additionally modified by Mosfet, and with few small -// modifications for Gwenview. The MMX scaling code also belongs to it. - -// The original license texts follow. - -/** - * This is the normal smoothscale method, based on Imlib2's smoothscale. - * - * Originally I took the algorithm used in NetPBM and Qt and added MMX/3dnow - * optimizations. It ran in about 1/2 the time as Qt. Then I ported Imlib's - * C algorithm and it ran at about the same speed as my MMX optimized one... - * Finally I ported Imlib's MMX version and it ran in less than half the - * time as my MMX algorithm, (taking only a quarter of the time Qt does). - * - * Changes include formatting, namespaces and other C++'ings, removal of old - * #ifdef'ed code, and removal of unneeded border calculation code. - * - * Imlib2 is (C) Carsten Haitzler and various contributors. The MMX code - * is by Willem Monsuwe . All other modifications are - * (C) Daniel M. Duley. - */ - -/* - Copyright (C) 2004 Daniel M. Duley - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -/* -Copyright (C) 2000 Carsten Haitzler and various contributors (see AUTHORS) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies of the Software and its Copyright notices. In addition publicly -documented acknowledgment must be given that this software has been used if no -source code of this software is made available publicly. This includes -acknowledgments in either Copyright notices, Manuals, Publicity and Marketing -documents or any documentation provided with any product containing this -software. This License does not apply to any software that links to the -libraries provided by this software (statically or dynamically), but only to -the software provided. - -Please see the COPYING.PLAIN for a plain-english explanation of this notice -and it's intent. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include - -#include "scale.h" - -#include - -#include "kcpuinfo.h" -#include "qcolor.h" - -namespace MImageScale{ - typedef struct __mimage_scale_info - { - int *xpoints; - unsigned int **ypoints; - int *xapoints, *yapoints; - int xup_yup; - } MImageScaleInfo; - - unsigned int** mimageCalcYPoints(unsigned int *src, int sw, int sh, - int dh); - int* mimageCalcXPoints(int sw, int dw); - int* mimageCalcApoints(int s, int d, int up); - MImageScaleInfo* mimageFreeScaleInfo(MImageScaleInfo *isi); - MImageScaleInfo *mimageCalcScaleInfo(QImage &img, int sw, int sh, - int dw, int dh, char aa); - void mimageSampleRGBA(MImageScaleInfo *isi, unsigned int *dest, int dxx, - int dyy, int dx, int dy, int dw, int dh, int dow); - void mimageScaleAARGBA(MImageScaleInfo *isi, unsigned int *dest, int dxx, - int dyy, int dx, int dy, int dw, int dh, int dow, - int sow); - void mimageScaleAARGB(MImageScaleInfo *isi, unsigned int *dest, int dxx, - int dyy, int dx, int dy, int dw, int dh, int dow, int - sow); - QImage smoothScale(const QImage& img, int dw, int dh); -} - -#ifdef HAVE_X86_MMX -extern "C" { - void __mimageScale_mmx_AARGBA(MImageScale::MImageScaleInfo *isi, - unsigned int *dest, int dxx, int dyy, - int dx, int dy, int dw, int dh, - int dow, int sow); -}; -#endif - -using namespace MImageScale; - -QImage MImageScale::smoothScale(const QImage& image, int dw, int dh) -{ - QImage img = image.depth() < 32 ? image.convertDepth( 32 ) : image; - int w = img.width(); - int h = img.height(); - - MImageScaleInfo *scaleinfo = - mimageCalcScaleInfo(img, w, h, dw, dh, true); - if(!scaleinfo) - return QImage(); - - QImage buffer(dw, dh, 32); - buffer.setAlphaBuffer(img.hasAlphaBuffer()); - -#ifdef HAVE_X86_MMX -//#warning Using MMX Smoothscale - bool haveMMX = KCPUInfo::haveExtension( KCPUInfo::IntelMMX ); - if(haveMMX){ - __mimageScale_mmx_AARGBA(scaleinfo, (unsigned int *)buffer.scanLine(0), - 0, 0, 0, 0, dw, dh, dw, w); - } - else -#endif - { - if(img.hasAlphaBuffer()) - mimageScaleAARGBA(scaleinfo, (unsigned int *)buffer.scanLine(0), 0, 0, - 0, 0, dw, dh, dw, w); - else - mimageScaleAARGB(scaleinfo, (unsigned int *)buffer.scanLine(0), 0, 0, - 0, 0, dw, dh, dw, w); - } - mimageFreeScaleInfo(scaleinfo); - return(buffer); -} - -// -// Code ported from Imlib... -// - -// FIXME: replace with mRed, etc... These work on pointers to pixels, not -// pixel values -#if BYTE_ORDER == BIG_ENDIAN -#define A_VAL(p) ((unsigned char *)(p))[0] -#define R_VAL(p) ((unsigned char *)(p))[1] -#define G_VAL(p) ((unsigned char *)(p))[2] -#define B_VAL(p) ((unsigned char *)(p))[3] -#elif BYTE_ORDER == LITTLE_ENDIAN -#define A_VAL(p) ((unsigned char *)(p))[3] -#define R_VAL(p) ((unsigned char *)(p))[2] -#define G_VAL(p) ((unsigned char *)(p))[1] -#define B_VAL(p) ((unsigned char *)(p))[0] -#else -#error "BYTE_ORDER is not defined" -#endif - -#define INV_XAP (256 - xapoints[x]) -#define XAP (xapoints[x]) -#define INV_YAP (256 - yapoints[dyy + y]) -#define YAP (yapoints[dyy + y]) - -unsigned int** MImageScale::mimageCalcYPoints(unsigned int *src, - int sw, int sh, int dh) -{ - unsigned int **p; - int i, j = 0; - int val, inc, rv = 0; - - if(dh < 0){ - dh = -dh; - rv = 1; - } - p = new unsigned int* [dh+1]; - - val = 0; - inc = (sh << 16) / dh; - for(i = 0; i < dh; i++){ - p[j++] = src + ((val >> 16) * sw); - val += inc; - } - if(rv){ - for(i = dh / 2; --i >= 0; ){ - unsigned int *tmp = p[i]; - p[i] = p[dh - i - 1]; - p[dh - i - 1] = tmp; - } - } - return(p); -} - -int* MImageScale::mimageCalcXPoints(int sw, int dw) -{ - int *p, i, j = 0; - int val, inc, rv = 0; - - if(dw < 0){ - dw = -dw; - rv = 1; - } - p = new int[dw+1]; - - val = 0; - inc = (sw << 16) / dw; - for(i = 0; i < dw; i++){ - p[j++] = (val >> 16); - val += inc; - } - - if(rv){ - for(i = dw / 2; --i >= 0; ){ - int tmp = p[i]; - p[i] = p[dw - i - 1]; - p[dw - i - 1] = tmp; - } - } - return(p); -} - -int* MImageScale::mimageCalcApoints(int s, int d, int up) -{ - int *p, i, j = 0, rv = 0; - - if(d < 0){ - rv = 1; - d = -d; - } - p = new int[d]; - - /* scaling up */ - if(up){ - int val, inc; - - val = 0; - inc = (s << 16) / d; - for(i = 0; i < d; i++){ - p[j++] = (val >> 8) - ((val >> 8) & 0xffffff00); - if((val >> 16) >= (s - 1)) - p[j - 1] = 0; - val += inc; - } - } - /* scaling down */ - else{ - int val, inc, ap, Cp; - val = 0; - inc = (s << 16) / d; - Cp = ((d << 14) / s) + 1; - for(i = 0; i < d; i++){ - ap = ((0x100 - ((val >> 8) & 0xff)) * Cp) >> 8; - p[j] = ap | (Cp << 16); - j++; - val += inc; - } - } - if(rv){ - int tmp; - for(i = d / 2; --i >= 0; ){ - tmp = p[i]; - p[i] = p[d - i - 1]; - p[d - i - 1] = tmp; - } - } - return(p); -} - -MImageScaleInfo* MImageScale::mimageFreeScaleInfo(MImageScaleInfo *isi) -{ - if(isi){ - delete[] isi->xpoints; - delete[] isi->ypoints; - delete[] isi->xapoints; - delete[] isi->yapoints; - delete isi; - } - return(NULL); -} - -MImageScaleInfo* MImageScale::mimageCalcScaleInfo(QImage &img, int sw, int sh, - int dw, int dh, char aa) -{ - MImageScaleInfo *isi; - int scw, sch; - - scw = dw * img.width() / sw; - sch = dh * img.height() / sh; - - isi = new MImageScaleInfo; - if(!isi) - return(NULL); - memset(isi, 0, sizeof(MImageScaleInfo)); - - isi->xup_yup = (abs(dw) >= sw) + ((abs(dh) >= sh) << 1); - - isi->xpoints = mimageCalcXPoints(img.width(), scw); - if(!isi->xpoints) - return(mimageFreeScaleInfo(isi)); - isi->ypoints = mimageCalcYPoints((unsigned int *)img.scanLine(0), - img.width(), img.height(), sch); - if (!isi->ypoints) - return(mimageFreeScaleInfo(isi)); - if(aa){ - isi->xapoints = mimageCalcApoints(img.width(), scw, isi->xup_yup & 1); - if(!isi->xapoints) - return(mimageFreeScaleInfo(isi)); - isi->yapoints = mimageCalcApoints(img.height(), sch, isi->xup_yup & 2); - if(!isi->yapoints) - return(mimageFreeScaleInfo(isi)); - } - return(isi); -} - -/* scale by pixel sampling only */ -void MImageScale::mimageSampleRGBA(MImageScaleInfo *isi, unsigned int *dest, - int dxx, int dyy, int dx, int dy, int dw, - int dh, int dow) -{ - unsigned int *sptr, *dptr; - int x, y, end; - unsigned int **ypoints = isi->ypoints; - int *xpoints = isi->xpoints; - - /* whats the last pixel ont he line so we stop there */ - end = dxx + dw; - /* go through every scanline in the output buffer */ - for(y = 0; y < dh; y++){ - /* get the pointer to the start of the destination scanline */ - dptr = dest + dx + ((y + dy) * dow); - /* calculate the source line we'll scan from */ - sptr = ypoints[dyy + y]; - /* go thru the scanline and copy across */ - for(x = dxx; x < end; x++) - *dptr++ = sptr[xpoints[x]]; - } -} - -/* FIXME: NEED to optimise ScaleAARGBA - currently it is "ok" but needs work*/ - -/* scale by area sampling */ -void MImageScale::mimageScaleAARGBA(MImageScaleInfo *isi, unsigned int *dest, - int dxx, int dyy, int dx, int dy, int dw, - int dh, int dow, int sow) -{ - unsigned int *sptr, *dptr; - int x, y, end; - unsigned int **ypoints = isi->ypoints; - int *xpoints = isi->xpoints; - int *xapoints = isi->xapoints; - int *yapoints = isi->yapoints; - - end = dxx + dw; - /* scaling up both ways */ - if(isi->xup_yup == 3){ - /* go through every scanline in the output buffer */ - for(y = 0; y < dh; y++){ - /* calculate the source line we'll scan from */ - dptr = dest + dx + ((y + dy) * dow); - sptr = ypoints[dyy + y]; - if(YAP > 0){ - for(x = dxx; x < end; x++){ - int r, g, b, a; - int rr, gg, bb, aa; - unsigned int *pix; - - if(XAP > 0){ - pix = ypoints[dyy + y] + xpoints[x]; - r = R_VAL(pix) * INV_XAP; - g = G_VAL(pix) * INV_XAP; - b = B_VAL(pix) * INV_XAP; - a = A_VAL(pix) * INV_XAP; - pix++; - r += R_VAL(pix) * XAP; - g += G_VAL(pix) * XAP; - b += B_VAL(pix) * XAP; - a += A_VAL(pix) * XAP; - pix += sow; - rr = R_VAL(pix) * XAP; - gg = G_VAL(pix) * XAP; - bb = B_VAL(pix) * XAP; - aa = A_VAL(pix) * XAP; - pix--; - rr += R_VAL(pix) * INV_XAP; - gg += G_VAL(pix) * INV_XAP; - bb += B_VAL(pix) * INV_XAP; - aa += A_VAL(pix) * INV_XAP; - r = ((rr * YAP) + (r * INV_YAP)) >> 16; - g = ((gg * YAP) + (g * INV_YAP)) >> 16; - b = ((bb * YAP) + (b * INV_YAP)) >> 16; - a = ((aa * YAP) + (a * INV_YAP)) >> 16; - *dptr++ = qRgba(r, g, b, a); - } - else{ - pix = ypoints[dyy + y] + xpoints[x]; - r = R_VAL(pix) * INV_YAP; - g = G_VAL(pix) * INV_YAP; - b = B_VAL(pix) * INV_YAP; - a = A_VAL(pix) * INV_YAP; - pix += sow; - r += R_VAL(pix) * YAP; - g += G_VAL(pix) * YAP; - b += B_VAL(pix) * YAP; - a += A_VAL(pix) * YAP; - r >>= 8; - g >>= 8; - b >>= 8; - a >>= 8; - *dptr++ = qRgba(r, g, b, a); - } - } - } - else{ - for(x = dxx; x < end; x++){ - int r, g, b, a; - unsigned int *pix; - - if(XAP > 0){ - pix = ypoints[dyy + y] + xpoints[x]; - r = R_VAL(pix) * INV_XAP; - g = G_VAL(pix) * INV_XAP; - b = B_VAL(pix) * INV_XAP; - a = A_VAL(pix) * INV_XAP; - pix++; - r += R_VAL(pix) * XAP; - g += G_VAL(pix) * XAP; - b += B_VAL(pix) * XAP; - a += A_VAL(pix) * XAP; - r >>= 8; - g >>= 8; - b >>= 8; - a >>= 8; - *dptr++ = qRgba(r, g, b, a); - } - else - *dptr++ = sptr[xpoints[x] ]; - } - } - } - } - /* if we're scaling down vertically */ - else if(isi->xup_yup == 1){ - /*\ 'Correct' version, with math units prepared for MMXification \*/ - int Cy, j; - unsigned int *pix; - int r, g, b, a, rr, gg, bb, aa; - int yap; - - /* go through every scanline in the output buffer */ - for(y = 0; y < dh; y++){ - Cy = YAP >> 16; - yap = YAP & 0xffff; - - dptr = dest + dx + ((y + dy) * dow); - for(x = dxx; x < end; x++){ - pix = ypoints[dyy + y] + xpoints[x]; - r = (R_VAL(pix) * yap) >> 10; - g = (G_VAL(pix) * yap) >> 10; - b = (B_VAL(pix) * yap) >> 10; - a = (A_VAL(pix) * yap) >> 10; - for(j = (1 << 14) - yap; j > Cy; j -= Cy){ - pix += sow; - r += (R_VAL(pix) * Cy) >> 10; - g += (G_VAL(pix) * Cy) >> 10; - b += (B_VAL(pix) * Cy) >> 10; - a += (A_VAL(pix) * Cy) >> 10; - } - if(j > 0){ - pix += sow; - r += (R_VAL(pix) * j) >> 10; - g += (G_VAL(pix) * j) >> 10; - b += (B_VAL(pix) * j) >> 10; - a += (A_VAL(pix) * j) >> 10; - } - if(XAP > 0){ - pix = ypoints[dyy + y] + xpoints[x] + 1; - rr = (R_VAL(pix) * yap) >> 10; - gg = (G_VAL(pix) * yap) >> 10; - bb = (B_VAL(pix) * yap) >> 10; - aa = (A_VAL(pix) * yap) >> 10; - for(j = (1 << 14) - yap; j > Cy; j -= Cy){ - pix += sow; - rr += (R_VAL(pix) * Cy) >> 10; - gg += (G_VAL(pix) * Cy) >> 10; - bb += (B_VAL(pix) * Cy) >> 10; - aa += (A_VAL(pix) * Cy) >> 10; - } - if(j > 0){ - pix += sow; - rr += (R_VAL(pix) * j) >> 10; - gg += (G_VAL(pix) * j) >> 10; - bb += (B_VAL(pix) * j) >> 10; - aa += (A_VAL(pix) * j) >> 10; - } - r = r * INV_XAP; - g = g * INV_XAP; - b = b * INV_XAP; - a = a * INV_XAP; - r = (r + ((rr * XAP))) >> 12; - g = (g + ((gg * XAP))) >> 12; - b = (b + ((bb * XAP))) >> 12; - a = (a + ((aa * XAP))) >> 12; - } - else{ - r >>= 4; - g >>= 4; - b >>= 4; - a >>= 4; - } - *dptr = qRgba(r, g, b, a); - dptr++; - } - } - } - /* if we're scaling down horizontally */ - else if(isi->xup_yup == 2){ - /*\ 'Correct' version, with math units prepared for MMXification \*/ - int Cx, j; - unsigned int *pix; - int r, g, b, a, rr, gg, bb, aa; - int xap; - - /* go through every scanline in the output buffer */ - for(y = 0; y < dh; y++){ - dptr = dest + dx + ((y + dy) * dow); - for(x = dxx; x < end; x++){ - Cx = XAP >> 16; - xap = XAP & 0xffff; - - pix = ypoints[dyy + y] + xpoints[x]; - r = (R_VAL(pix) * xap) >> 10; - g = (G_VAL(pix) * xap) >> 10; - b = (B_VAL(pix) * xap) >> 10; - a = (A_VAL(pix) * xap) >> 10; - for(j = (1 << 14) - xap; j > Cx; j -= Cx){ - pix++; - r += (R_VAL(pix) * Cx) >> 10; - g += (G_VAL(pix) * Cx) >> 10; - b += (B_VAL(pix) * Cx) >> 10; - a += (A_VAL(pix) * Cx) >> 10; - } - if(j > 0){ - pix++; - r += (R_VAL(pix) * j) >> 10; - g += (G_VAL(pix) * j) >> 10; - b += (B_VAL(pix) * j) >> 10; - a += (A_VAL(pix) * j) >> 10; - } - if(YAP > 0){ - pix = ypoints[dyy + y] + xpoints[x] + sow; - rr = (R_VAL(pix) * xap) >> 10; - gg = (G_VAL(pix) * xap) >> 10; - bb = (B_VAL(pix) * xap) >> 10; - aa = (A_VAL(pix) * xap) >> 10; - for(j = (1 << 14) - xap; j > Cx; j -= Cx){ - pix++; - rr += (R_VAL(pix) * Cx) >> 10; - gg += (G_VAL(pix) * Cx) >> 10; - bb += (B_VAL(pix) * Cx) >> 10; - aa += (A_VAL(pix) * Cx) >> 10; - } - if(j > 0){ - pix++; - rr += (R_VAL(pix) * j) >> 10; - gg += (G_VAL(pix) * j) >> 10; - bb += (B_VAL(pix) * j) >> 10; - aa += (A_VAL(pix) * j) >> 10; - } - r = r * INV_YAP; - g = g * INV_YAP; - b = b * INV_YAP; - a = a * INV_YAP; - r = (r + ((rr * YAP))) >> 12; - g = (g + ((gg * YAP))) >> 12; - b = (b + ((bb * YAP))) >> 12; - a = (a + ((aa * YAP))) >> 12; - } - else{ - r >>= 4; - g >>= 4; - b >>= 4; - a >>= 4; - } - *dptr = qRgba(r, g, b, a); - dptr++; - } - } - } - /* if we're scaling down horizontally & vertically */ - else{ - /*\ 'Correct' version, with math units prepared for MMXification: - |*| The operation 'b = (b * c) >> 16' translates to pmulhw, - |*| so the operation 'b = (b * c) >> d' would translate to - |*| psllw (16 - d), %mmb; pmulh %mmc, %mmb - \*/ - int Cx, Cy, i, j; - unsigned int *pix; - int a, r, g, b, ax, rx, gx, bx; - int xap, yap; - - for(y = 0; y < dh; y++){ - Cy = YAP >> 16; - yap = YAP & 0xffff; - - dptr = dest + dx + ((y + dy) * dow); - for(x = dxx; x < end; x++){ - Cx = XAP >> 16; - xap = XAP & 0xffff; - - sptr = ypoints[dyy + y] + xpoints[x]; - pix = sptr; - sptr += sow; - rx = (R_VAL(pix) * xap) >> 9; - gx = (G_VAL(pix) * xap) >> 9; - bx = (B_VAL(pix) * xap) >> 9; - ax = (A_VAL(pix) * xap) >> 9; - pix++; - for(i = (1 << 14) - xap; i > Cx; i -= Cx){ - rx += (R_VAL(pix) * Cx) >> 9; - gx += (G_VAL(pix) * Cx) >> 9; - bx += (B_VAL(pix) * Cx) >> 9; - ax += (A_VAL(pix) * Cx) >> 9; - pix++; - } - if(i > 0){ - rx += (R_VAL(pix) * i) >> 9; - gx += (G_VAL(pix) * i) >> 9; - bx += (B_VAL(pix) * i) >> 9; - ax += (A_VAL(pix) * i) >> 9; - } - - r = (rx * yap) >> 14; - g = (gx * yap) >> 14; - b = (bx * yap) >> 14; - a = (ax * yap) >> 14; - - for(j = (1 << 14) - yap; j > Cy; j -= Cy){ - pix = sptr; - sptr += sow; - rx = (R_VAL(pix) * xap) >> 9; - gx = (G_VAL(pix) * xap) >> 9; - bx = (B_VAL(pix) * xap) >> 9; - ax = (A_VAL(pix) * xap) >> 9; - pix++; - for(i = (1 << 14) - xap; i > Cx; i -= Cx){ - rx += (R_VAL(pix) * Cx) >> 9; - gx += (G_VAL(pix) * Cx) >> 9; - bx += (B_VAL(pix) * Cx) >> 9; - ax += (A_VAL(pix) * Cx) >> 9; - pix++; - } - if(i > 0){ - rx += (R_VAL(pix) * i) >> 9; - gx += (G_VAL(pix) * i) >> 9; - bx += (B_VAL(pix) * i) >> 9; - ax += (A_VAL(pix) * i) >> 9; - } - - r += (rx * Cy) >> 14; - g += (gx * Cy) >> 14; - b += (bx * Cy) >> 14; - a += (ax * Cy) >> 14; - } - if(j > 0){ - pix = sptr; - sptr += sow; - rx = (R_VAL(pix) * xap) >> 9; - gx = (G_VAL(pix) * xap) >> 9; - bx = (B_VAL(pix) * xap) >> 9; - ax = (A_VAL(pix) * xap) >> 9; - pix++; - for(i = (1 << 14) - xap; i > Cx; i -= Cx){ - rx += (R_VAL(pix) * Cx) >> 9; - gx += (G_VAL(pix) * Cx) >> 9; - bx += (B_VAL(pix) * Cx) >> 9; - ax += (A_VAL(pix) * Cx) >> 9; - pix++; - } - if(i > 0){ - rx += (R_VAL(pix) * i) >> 9; - gx += (G_VAL(pix) * i) >> 9; - bx += (B_VAL(pix) * i) >> 9; - ax += (A_VAL(pix) * i) >> 9; - } - - r += (rx * j) >> 14; - g += (gx * j) >> 14; - b += (bx * j) >> 14; - a += (ax * j) >> 14; - } - - R_VAL(dptr) = r >> 5; - G_VAL(dptr) = g >> 5; - B_VAL(dptr) = b >> 5; - A_VAL(dptr) = a >> 5; - dptr++; - } - } - } -} - -/* scale by area sampling - IGNORE the ALPHA byte*/ -void MImageScale::mimageScaleAARGB(MImageScaleInfo *isi, unsigned int *dest, - int dxx, int dyy, int dx, int dy, int dw, - int dh, int dow, int sow) -{ - unsigned int *sptr, *dptr; - int x, y, end; - unsigned int **ypoints = isi->ypoints; - int *xpoints = isi->xpoints; - int *xapoints = isi->xapoints; - int *yapoints = isi->yapoints; - - end = dxx + dw; - /* scaling up both ways */ - if(isi->xup_yup == 3){ - /* go through every scanline in the output buffer */ - for(y = 0; y < dh; y++){ - /* calculate the source line we'll scan from */ - dptr = dest + dx + ((y + dy) * dow); - sptr = ypoints[dyy + y]; - if(YAP > 0){ - for(x = dxx; x < end; x++){ - int r = 0, g = 0, b = 0; - int rr = 0, gg = 0, bb = 0; - unsigned int *pix; - - if(XAP > 0){ - pix = ypoints[dyy + y] + xpoints[x]; - r = R_VAL(pix) * INV_XAP; - g = G_VAL(pix) * INV_XAP; - b = B_VAL(pix) * INV_XAP; - pix++; - r += R_VAL(pix) * XAP; - g += G_VAL(pix) * XAP; - b += B_VAL(pix) * XAP; - pix += sow; - rr = R_VAL(pix) * XAP; - gg = G_VAL(pix) * XAP; - bb = B_VAL(pix) * XAP; - pix --; - rr += R_VAL(pix) * INV_XAP; - gg += G_VAL(pix) * INV_XAP; - bb += B_VAL(pix) * INV_XAP; - r = ((rr * YAP) + (r * INV_YAP)) >> 16; - g = ((gg * YAP) + (g * INV_YAP)) >> 16; - b = ((bb * YAP) + (b * INV_YAP)) >> 16; - *dptr++ = qRgba(r, g, b, 0xff); - } - else{ - pix = ypoints[dyy + y] + xpoints[x]; - r = R_VAL(pix) * INV_YAP; - g = G_VAL(pix) * INV_YAP; - b = B_VAL(pix) * INV_YAP; - pix += sow; - r += R_VAL(pix) * YAP; - g += G_VAL(pix) * YAP; - b += B_VAL(pix) * YAP; - r >>= 8; - g >>= 8; - b >>= 8; - *dptr++ = qRgba(r, g, b, 0xff); - } - } - } - else{ - for(x = dxx; x < end; x++){ - int r = 0, g = 0, b = 0; - unsigned int *pix; - - if(XAP > 0){ - pix = ypoints[dyy + y] + xpoints[x]; - r = R_VAL(pix) * INV_XAP; - g = G_VAL(pix) * INV_XAP; - b = B_VAL(pix) * INV_XAP; - pix++; - r += R_VAL(pix) * XAP; - g += G_VAL(pix) * XAP; - b += B_VAL(pix) * XAP; - r >>= 8; - g >>= 8; - b >>= 8; - *dptr++ = qRgba(r, g, b, 0xff); - } - else - *dptr++ = sptr[xpoints[x] ]; - } - } - } - } - /* if we're scaling down vertically */ - else if(isi->xup_yup == 1){ - /*\ 'Correct' version, with math units prepared for MMXification \*/ - int Cy, j; - unsigned int *pix; - int r, g, b, rr, gg, bb; - int yap; - - /* go through every scanline in the output buffer */ - for(y = 0; y < dh; y++){ - Cy = YAP >> 16; - yap = YAP & 0xffff; - - dptr = dest + dx + ((y + dy) * dow); - for(x = dxx; x < end; x++){ - pix = ypoints[dyy + y] + xpoints[x]; - r = (R_VAL(pix) * yap) >> 10; - g = (G_VAL(pix) * yap) >> 10; - b = (B_VAL(pix) * yap) >> 10; - pix += sow; - for(j = (1 << 14) - yap; j > Cy; j -= Cy){ - r += (R_VAL(pix) * Cy) >> 10; - g += (G_VAL(pix) * Cy) >> 10; - b += (B_VAL(pix) * Cy) >> 10; - pix += sow; - } - if(j > 0){ - r += (R_VAL(pix) * j) >> 10; - g += (G_VAL(pix) * j) >> 10; - b += (B_VAL(pix) * j) >> 10; - } - if(XAP > 0){ - pix = ypoints[dyy + y] + xpoints[x] + 1; - rr = (R_VAL(pix) * yap) >> 10; - gg = (G_VAL(pix) * yap) >> 10; - bb = (B_VAL(pix) * yap) >> 10; - pix += sow; - for(j = (1 << 14) - yap; j > Cy; j -= Cy){ - rr += (R_VAL(pix) * Cy) >> 10; - gg += (G_VAL(pix) * Cy) >> 10; - bb += (B_VAL(pix) * Cy) >> 10; - pix += sow; - } - if(j > 0){ - rr += (R_VAL(pix) * j) >> 10; - gg += (G_VAL(pix) * j) >> 10; - bb += (B_VAL(pix) * j) >> 10; - } - r = r * INV_XAP; - g = g * INV_XAP; - b = b * INV_XAP; - r = (r + ((rr * XAP))) >> 12; - g = (g + ((gg * XAP))) >> 12; - b = (b + ((bb * XAP))) >> 12; - } - else{ - r >>= 4; - g >>= 4; - b >>= 4; - } - *dptr = qRgba(r, g, b, 0xff); - dptr++; - } - } - } - /* if we're scaling down horizontally */ - else if(isi->xup_yup == 2){ - /*\ 'Correct' version, with math units prepared for MMXification \*/ - int Cx, j; - unsigned int *pix; - int r, g, b, rr, gg, bb; - int xap; - - /* go through every scanline in the output buffer */ - for(y = 0; y < dh; y++){ - dptr = dest + dx + ((y + dy) * dow); - for(x = dxx; x < end; x++){ - Cx = XAP >> 16; - xap = XAP & 0xffff; - - pix = ypoints[dyy + y] + xpoints[x]; - r = (R_VAL(pix) * xap) >> 10; - g = (G_VAL(pix) * xap) >> 10; - b = (B_VAL(pix) * xap) >> 10; - pix++; - for(j = (1 << 14) - xap; j > Cx; j -= Cx){ - r += (R_VAL(pix) * Cx) >> 10; - g += (G_VAL(pix) * Cx) >> 10; - b += (B_VAL(pix) * Cx) >> 10; - pix++; - } - if(j > 0){ - r += (R_VAL(pix) * j) >> 10; - g += (G_VAL(pix) * j) >> 10; - b += (B_VAL(pix) * j) >> 10; - } - if(YAP > 0){ - pix = ypoints[dyy + y] + xpoints[x] + sow; - rr = (R_VAL(pix) * xap) >> 10; - gg = (G_VAL(pix) * xap) >> 10; - bb = (B_VAL(pix) * xap) >> 10; - pix++; - for(j = (1 << 14) - xap; j > Cx; j -= Cx){ - rr += (R_VAL(pix) * Cx) >> 10; - gg += (G_VAL(pix) * Cx) >> 10; - bb += (B_VAL(pix) * Cx) >> 10; - pix++; - } - if(j > 0){ - rr += (R_VAL(pix) * j) >> 10; - gg += (G_VAL(pix) * j) >> 10; - bb += (B_VAL(pix) * j) >> 10; - } - r = r * INV_YAP; - g = g * INV_YAP; - b = b * INV_YAP; - r = (r + ((rr * YAP))) >> 12; - g = (g + ((gg * YAP))) >> 12; - b = (b + ((bb * YAP))) >> 12; - } - else{ - r >>= 4; - g >>= 4; - b >>= 4; - } - *dptr = qRgba(r, g, b, 0xff); - dptr++; - } - } - } - /* fully optimized (i think) - onyl change of algorithm can help */ - /* if we're scaling down horizontally & vertically */ - else{ - /*\ 'Correct' version, with math units prepared for MMXification \*/ - int Cx, Cy, i, j; - unsigned int *pix; - int r, g, b, rx, gx, bx; - int xap, yap; - - for(y = 0; y < dh; y++){ - Cy = YAP >> 16; - yap = YAP & 0xffff; - - dptr = dest + dx + ((y + dy) * dow); - for(x = dxx; x < end; x++){ - Cx = XAP >> 16; - xap = XAP & 0xffff; - - sptr = ypoints[dyy + y] + xpoints[x]; - pix = sptr; - sptr += sow; - rx = (R_VAL(pix) * xap) >> 9; - gx = (G_VAL(pix) * xap) >> 9; - bx = (B_VAL(pix) * xap) >> 9; - pix++; - for(i = (1 << 14) - xap; i > Cx; i -= Cx){ - rx += (R_VAL(pix) * Cx) >> 9; - gx += (G_VAL(pix) * Cx) >> 9; - bx += (B_VAL(pix) * Cx) >> 9; - pix++; - } - if(i > 0){ - rx += (R_VAL(pix) * i) >> 9; - gx += (G_VAL(pix) * i) >> 9; - bx += (B_VAL(pix) * i) >> 9; - } - - r = (rx * yap) >> 14; - g = (gx * yap) >> 14; - b = (bx * yap) >> 14; - - for(j = (1 << 14) - yap; j > Cy; j -= Cy){ - pix = sptr; - sptr += sow; - rx = (R_VAL(pix) * xap) >> 9; - gx = (G_VAL(pix) * xap) >> 9; - bx = (B_VAL(pix) * xap) >> 9; - pix++; - for(i = (1 << 14) - xap; i > Cx; i -= Cx){ - rx += (R_VAL(pix) * Cx) >> 9; - gx += (G_VAL(pix) * Cx) >> 9; - bx += (B_VAL(pix) * Cx) >> 9; - pix++; - } - if(i > 0){ - rx += (R_VAL(pix) * i) >> 9; - gx += (G_VAL(pix) * i) >> 9; - bx += (B_VAL(pix) * i) >> 9; - } - - r += (rx * Cy) >> 14; - g += (gx * Cy) >> 14; - b += (bx * Cy) >> 14; - } - if(j > 0){ - pix = sptr; - sptr += sow; - rx = (R_VAL(pix) * xap) >> 9; - gx = (G_VAL(pix) * xap) >> 9; - bx = (B_VAL(pix) * xap) >> 9; - pix++; - for(i = (1 << 14) - xap; i > Cx; i -= Cx){ - rx += (R_VAL(pix) * Cx) >> 9; - gx += (G_VAL(pix) * Cx) >> 9; - bx += (B_VAL(pix) * Cx) >> 9; - pix++; - } - if(i > 0){ - rx += (R_VAL(pix) * i) >> 9; - gx += (G_VAL(pix) * i) >> 9; - bx += (B_VAL(pix) * i) >> 9; - } - - r += (rx * j) >> 14; - g += (gx * j) >> 14; - b += (bx * j) >> 14; - } - - R_VAL(dptr) = r >> 5; - G_VAL(dptr) = g >> 5; - B_VAL(dptr) = b >> 5; - dptr++; - } - } - } -} - - -QImage scale(const QImage& image, int width, int height) -{ - if( image.isNull()) return image.copy(); - - QSize newSize( width, height ); - newSize = newSize.expandedTo( QSize( 1, 1 )); // make sure it doesn't become null - - if ( newSize == image.size() ) return image.copy(); - - width = newSize.width(); - height = newSize.height(); -// return image.smoothScale( width, height ); - return MImageScale::smoothScale( image, width, height ); -} diff --git a/ksplash/ksplashx/scale.h b/ksplash/ksplashx/scale.h deleted file mode 100644 index bca73680..00000000 --- a/ksplash/ksplashx/scale.h +++ /dev/null @@ -1,87 +0,0 @@ -// This code is Imlib2 code, additionally modified by Mosfet, and with few small -// modifications for Gwenview. The MMX scaling code also belongs to it. - -// The original license texts follow. - -/** - * This is the normal smoothscale method, based on Imlib2's smoothscale. - * - * Originally I took the algorithm used in NetPBM and Qt and added MMX/3dnow - * optimizations. It ran in about 1/2 the time as Qt. Then I ported Imlib's - * C algorithm and it ran at about the same speed as my MMX optimized one... - * Finally I ported Imlib's MMX version and it ran in less than half the - * time as my MMX algorithm, (taking only a quarter of the time Qt does). - * - * Changes include formatting, namespaces and other C++'ings, removal of old - * #ifdef'ed code, and removal of unneeded border calculation code. - * - * Imlib2 is (C) Carsten Haitzler and various contributors. The MMX code - * is by Willem Monsuwe . All other modifications are - * (C) Daniel M. Duley. - */ - -/* - Copyright (C) 2004 Daniel M. Duley - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -/* -Copyright (C) 2000 Carsten Haitzler and various contributors (see AUTHORS) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies of the Software and its Copyright notices. In addition publicly -documented acknowledgment must be given that this software has been used if no -source code of this software is made available publicly. This includes -acknowledgments in either Copyright notices, Manuals, Publicity and Marketing -documents or any documentation provided with any product containing this -software. This License does not apply to any software that links to the -libraries provided by this software (statically or dynamically), but only to -the software provided. - -Please see the COPYING.PLAIN for a plain-english explanation of this notice -and it's intent. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#ifndef SCALE_H -#define SCALE_H - -#include - -QImage scale(const QImage& image, int width, int height); - -#endif diff --git a/ksplash/ksplashx/scale/CMakeLists.txt b/ksplash/ksplashx/scale/CMakeLists.txt deleted file mode 100644 index 8f47c0d0..00000000 --- a/ksplash/ksplashx/scale/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -########### next target ############### - -set( ksplashx_scale_SRCS - main.cpp ) - -add_executable( ksplashx_scale ${ksplashx_scale_SRCS}) -target_link_libraries( ksplashx_scale ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY}) -install( TARGETS ksplashx_scale ${INSTALL_TARGETS_DEFAULT_ARGS} ) diff --git a/ksplash/ksplashx/scale/main.cpp b/ksplash/ksplashx/scale/main.cpp deleted file mode 100644 index 167d4844..00000000 --- a/ksplash/ksplashx/scale/main.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -int main( int argc, char* argv[] ) - { - if( argc != 10 ) - return 1; - QString theme = argv[ 1 ]; - QString file = argv[ 2 ]; - QString real_file = argv[ 3 ]; - int width = atoi( argv[ 4 ] ); - int height = atoi( argv[ 5 ] ); - int res_w = atoi( argv[ 6 ] ); - int res_h = atoi( argv[ 7 ] ); - time_t timestamp = atol( argv[ 8 ] ); - bool locolor = strcmp( argv[ 9 ], "locolor" ) == 0; - KComponentData k( "ksplashx_scale" ); - QString outfile = QString( "ksplashx/%1-%2x%3%4-%5" ).arg( theme ).arg( res_w ).arg( res_h ) - .arg( locolor ? "-locolor" : "" ).arg( file ); - outfile = KStandardDirs::locateLocal( "cache", outfile ); - QImage img( real_file ); - if( img.isNull()) - return 2; - QImage img2 = img.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - if( img2.save( outfile + ".tmp", "PNG" )) - { - rename( QFile::encodeName( outfile + ".tmp" ), QFile::encodeName( outfile )); - utimbuf tm; - tm.actime = tm.modtime = timestamp; - utime( QFile::encodeName( outfile ), &tm ); - } - else - { - unlink( QFile::encodeName( outfile )); - unlink( QFile::encodeName( outfile + ".tmp" )); - return 3; - } - return 0; - } diff --git a/ksplash/ksplashx/splash.cpp b/ksplash/ksplashx/splash.cpp deleted file mode 100644 index 07b3cef2..00000000 --- a/ksplash/ksplashx/splash.cpp +++ /dev/null @@ -1,1277 +0,0 @@ -/******************************************************************** - -Copyright (C) 2007 Lubos Lunak - -Please see file LICENSE for the licensing terms of ksplashx as a whole. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*********************************************************************/ - -//#define DEBUG - -const int MAX_ITEMS = 100; -const int ANIM_IMAGES_ROW = 10; - -// for converting from startup states to (internal) numbers -// these are also in the simple splash and in krunner -const char states[][ 11 ] = - { "initial", "kded", "kcminit", "ksmserver", "wm", "desktop", "ready" }; -// State "ready" isn't used, make splash go away as soon as desktop is ready. -const int LAST_STATE = 5; - -extern int screen_number; - -#include "config-unix.h" -#include "config-workspace.h" - -#include "splash.h" -#include "qcolor.h" -#include "qimage.h" -#include "pixmap.h" -#include "scale.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -struct AnimData - { - AnimData( int x, int y, PixmapData* frames, int num_frames, int delay, int repeat ); - ~AnimData(); - bool updateFrame( int change ); - int x, y; - PixmapData* frames; - int num_frames; - int current_frame; - int delay; - int remaining_delay; - int repeat; - int remaining_repeat; - }; - -AnimData::AnimData( int x, int y, PixmapData* frames, int num_frames, int delay, int repeat ) - : x( x ) - , y( y ) - , frames( frames ) - , num_frames( num_frames ) - , current_frame( 0 ) - , delay( delay ) - , remaining_delay( delay ) - , repeat( repeat ) - , remaining_repeat( repeat ) - { - } - -AnimData::~AnimData() - { - for( int i = 0; - i < num_frames; - ++i ) - { - if( frames[ i ].hd != None ) - XFreePixmap( qt_xdisplay(), frames[ i ].hd ); - } - delete[] frames; - } - -bool AnimData::updateFrame( int change ) - { - remaining_delay -= change; - bool ret = false; - while( remaining_delay <= 0 ) - { - if( ++current_frame == num_frames ) - { - if( repeat > 0 && --remaining_repeat <= 0 ) // non-infinite and finished - { // stay at the last frame - --current_frame; - remaining_delay = 100000000; - return false; - } - current_frame = 0; - } - remaining_delay += delay; - ret = true; - } - return ret; - } - -static QImage splash_image; // contents of the splash window (needed for alphablending) -static Pixmap splash_pixmap; // the pixmap with window contents -static AnimData* animations[ MAX_ITEMS ]; -static int anim_count; -static Window window = None; -static QRect geometry; -static bool scalex = true; -static bool scaley = true; -static Atom kde_splash_progress; -static char kdehome[ 1024 ]; -static char theme_name[ 1024 ]; -static char theme_dir[ 1024 ]; -static bool test; -static int parent_pipe; -static time_t final_time; -static int state; -static time_t timestamp; // timestamp of the description.txt file, used for caching - -// returns a pointer to a static ! -static const char* findFileHelper( const char* name, int* w, int* h, bool locolor, bool lame, QRect geom ) - { - static char tmp[ 1024 ]; - char best[ 1024 ]; - int best_w = -1; - int best_h = -1; - float best_distance = 10E30; - DIR* dir = opendir( theme_dir ); - if( dir != NULL ) - { - while( dirent* file = readdir( dir )) - { - int w, h; - if( locolor - ? sscanf( file->d_name, "%dx%d-locolor", &w, &h ) == 2 - : sscanf( file->d_name, "%dx%d", &w, &h ) == 2 ) - { - // compute difference of areas - float delta = w * h - geom.width() * geom.height(); - // scale down to about 1.0 - delta /= ((geom.width() * geom.height())+(w * h))/2; - // Consider first the difference in aspect ratio, - // then in areas. Prefer scaling down. - float deltaRatio = 1.0; - if (h > 0 && geom.height() > 0) { - deltaRatio = float(w) / float(h) - - float(geom.width()) / float(geom.height()); - } - float distance = fabs(deltaRatio) * 3.0 + (delta >= 0.0 ? delta : -delta + 5.0); - if( distance < best_distance - // only derive from themes with the same ratio if lame resolutions are not allowed, damn 1280x1024 - && ( lame || w * geom.height() == h * geom.width()) - ) - { - snprintf( tmp, 1024, "%s/%dx%d%s/%s", theme_dir, w, h, locolor ? "-locolor" : "", name ); -#ifdef DEBUG - fprintf( stderr, "FINDFILE3: %s %s\n", name, tmp ); -#endif - if( access( tmp, R_OK ) == 0 ) - { - best_w = w; - best_h = h; - best_distance = distance; - strcpy( best, tmp ); - } - } - } - } - closedir( dir ); - } - if( best_w > 0 ) - { - if( w != NULL ) - *w = best_w; - if( h != NULL ) - *h = best_h; - strcpy( tmp, best ); - return tmp; - } - return ""; - } - -// returns a pointer to a static ! -static const char* findFileWithDepth( const char* name, int* w, int* h, bool locolor, QRect geom ) - { - static char tmp[ 1024 ]; - snprintf( tmp, 1024, "%s/%dx%d%s/%s", theme_dir, geom.width(), geom.height(), - locolor ? "-locolor" : "", name ); -#ifdef DEBUG - fprintf( stderr, "FINDFILE1: %s %s\n", name, tmp ); -#endif - if( access( tmp, R_OK ) != 0 ) - { - // ksplash/-- in 'kde-config --path cache' - static char hostname[ 1024 ]; - if( getenv("XAUTHLOCALHOSTNAME")) - strncpy( hostname, getenv("XAUTHLOCALHOSTNAME"), 1023 ); - else - gethostname( hostname, 1023 ); - hostname[ 1023 ] = '\0'; - snprintf( tmp, 1024, "%s/cache-%s/ksplashx/%s-%dx%d%s-%s", kdehome, hostname, theme_name, - geom.width(), geom.height(), locolor ? "-locolor" : "", name ); -#ifdef DEBUG - fprintf( stderr, "FINDFILE2: %s %s\n", name, tmp ); -#endif - struct stat stat_buf; - if( stat( tmp, &stat_buf ) != 0 || stat_buf.st_mtime != timestamp ) - { - tmp[ 0 ] = '\0'; -#ifdef DEBUG - fprintf( stderr, "FINDFILE2 TIMESTAMP FAILURE\n" ); -#endif - } - } - if( access( tmp, R_OK ) == 0 ) - { - if( w != NULL ) - *w = geom.width(); - if( h != NULL ) - *h = geom.height(); - return tmp; - } - if( w == NULL || h == NULL ) // no scaling possible - return ""; -#if 0 // disable for now in order to match plasma's selection mechanism - const char* ret = findFileHelper( name, w, h, locolor, false, geom ); - if( ret == NULL || *ret == '\0' ) - ret = findFileHelper( name, w, h, locolor, true, geom ); - return ret; -#else - return findFileHelper( name, w, h, locolor, true, geom ); -#endif - } - -// returns a pointer to a static ! -static const char* findLocalizedFileWithDepth( const char* name, int* w, int* h, bool locolor, QRect geom ) - { - const int bufsz = 1024; - - // Split name into dirname and basename. - char name2[ bufsz ]; - strncpy( name2, name, bufsz ); - name2[ bufsz - 1 ] = '\0'; - char* basn = basename( name2 ); // must preceed dirname - char* dirn = dirname( name2 ); // modifies name2 - - // Check for localized file by parsing languages from KLOCALE_LANGUAGES, - // as provided by startkde via kstartupconfig4. It contains list of - // language codes, colon-separated and ordered by decreasing priority. - const char* lvarname = "KLOCALE_LANGUAGES"; - if( getenv( lvarname ) && getenv( lvarname )[ 0 ] ) - { - char lvar[ bufsz ]; - strncpy( lvar, getenv( lvarname ), bufsz ); - lvar[ bufsz - 1 ] = '\0'; - - // Go through colon-separated list of languages. - char* lang = strtok( lvar, ":" ); - while( 1 ) - { - char locname[ bufsz ]; - snprintf( locname, bufsz, "%s/l10n/%s/%s", dirn, lang, basn ); - locname[ bufsz - 1 ] = '\0'; - - // Check if this path exists. - const char* path = findFileWithDepth( locname, w, h, locolor, geom ); - if( path[ 0 ] ) - return path; - - if( ( lang = strtok( 0, ":" ) ) == 0 ) - break; - } - } - - // Fall back to unlocalized file. - return findFileWithDepth( name, w, h, locolor, geom ); - } - -// returns a pointer to a static ! -static const char* findFile( const char* name, int* w = NULL, int* h = NULL, bool* locolor = NULL, QRect geom = screenGeometry(0) ) - { - if( x11Depth() <= 8 ) - { - if( const char* ret = findLocalizedFileWithDepth( name, w, h, true, geom )) // try locolor - { - if( locolor != NULL ) - *locolor = true; - return ret; - } - } - if( locolor != NULL ) - *locolor = false; - return findLocalizedFileWithDepth( name, w, h, false, geom); // no locolor - } - -// If a properly sized image doesn't exist save it in the cache location -// for the next use, because that means no scaling and a smaller png image -// to load. -static void pregeneratePixmap( const char* file, const char* real_file, int width, int height, bool locolor, QRect geom ) - { -#ifdef DEBUG - static char cmd[ 1024 ]; - snprintf( cmd, 1024, "ksplashx_scale \"%s\" \"%s\" \"%s\" %d %d %d %d %ld %s", theme_name, - file, real_file, width, height, geom.width(), geom.height(), timestamp, - locolor ? "locolor" : "no-locolor" ); - fprintf( stderr, "PREGENERATE PIXMAP CMD:%s\n", cmd ); -#endif - char w[ 20 ], h[ 20 ], sw[ 20 ], sh[ 20 ], t[ 40 ]; - sprintf( w, "%d", width ); - sprintf( h, "%d", height ); - sprintf( sw, "%d", geom.width()); - sprintf( sh, "%d", geom.height()); - sprintf( t, "%ld", timestamp ); - if( fork() == 0 ) - { - int maxf = sysconf( _SC_OPEN_MAX ); - for( int f = 0; - f < maxf; - ++f ) - close( f ); - nice( 10 ); - sleep( 30 ); - char* args[ 20 ]; - args[ 0 ] = const_cast< char* >( "ksplashx_scale" ); - args[ 1 ] = theme_name; - args[ 2 ] = ( char* ) file; - args[ 3 ] = ( char* ) real_file; - args[ 4 ] = w; - args[ 5 ] = h; - args[ 6 ] = sw; - args[ 7 ] = sh; - args[ 8 ] = t; - args[ 9 ] = ( char* )( locolor ? "locolor" : "no-locolor" ); - args[ 10 ] = NULL; - execvp( args[ 0 ], args ); - _exit( 0 ); - } - } - -static QImage readImage( FILE* f ) - { - char buf[ 3 ] = ""; - fread( buf, 1, 3, f ); - rewind( f ); - return splash_read_png_image( f ); - } - -static QImage loadImage( const char* file, QRect geom ) - { - int w, h; - bool locolor; - const char* real_file = findFile( file, &w, &h, &locolor, geom ); // points to a static ! - FILE* f = fopen( real_file, "r" ); - if( f == NULL ) - return QImage(); - QImage img = readImage( f ); - if( img.depth() != 32 ) - img = img.convertDepth( 32 ); - fclose( f ); - if( img.isNull()) - { - fprintf( stderr, "Failed to load: %s\n", file ); - exit( 3 ); - } - if( img.depth() != 32 ) - { - fprintf( stderr, "Not 32bpp: %s\n", file ); - exit( 3 ); - } - if(( scalex && w != geom.width()) || ( scaley && h != geom.height())) - { - double ratiox = scalex ? double( w ) / geom.width() : 1; - double ratioy = scaley ? double( h ) / geom.height() : 1; -#ifdef DEBUG - fprintf( stderr, "PIXMAP SCALING: %f %f\n", ratiox, ratioy ); -#endif - img = scale( img, round( img.width() / ratiox ), round( img.height() / ratioy )); - if( ratiox * ratioy > 1 ) // only downscale - pregeneratePixmap( file, real_file, img.width(), img.height(), locolor, geom ); - } - return img; - } - -static void frameSize( const QImage& img, int frames, int& framew, int& frameh ) - { - if( frames < ANIM_IMAGES_ROW ) - { - framew = img.width() / frames; - frameh = img.height(); - } - else - { - framew = img.width() / ANIM_IMAGES_ROW; - frameh = img.height() / (( frames + ANIM_IMAGES_ROW - 1 ) / ANIM_IMAGES_ROW ); - } - } - -static QImage loadAnimImage( const char* file, int frames ) - { - int w, h; - bool locolor; - const char* real_file = findFile( file, &w, &h, &locolor ); // points to a static ! - FILE* f = fopen( real_file, "r" ); - if( f == NULL ) - { - fprintf( stderr, "Bad anim file: %s\n", file ); - exit( 3 ); - } - QImage img = readImage( f ); - if( img.depth() != 32 ) - img = img.convertDepth( 32 ); - fclose( f ); - int framew, frameh; - if( frames < ANIM_IMAGES_ROW ) - { - if( img.width() % frames != 0 ) - { - fprintf( stderr, "Bad anim size: %s\n", file ); - exit( 3 ); - } - } - else - { - if( img.width() % ANIM_IMAGES_ROW != 0 - || img.height() % (( frames + ANIM_IMAGES_ROW - 1 ) / ANIM_IMAGES_ROW ) != 0 ) - { - fprintf( stderr, "Bad anim size: %s\n", file ); - exit( 3 ); - } - } - frameSize( img, frames, framew, frameh ); - if(( scalex && w != screenGeometry(0).width()) || ( scaley && h != screenGeometry(0).height())) - { - double ratiox = scalex ? double( w ) / screenGeometry(0).width() : 1; - double ratioy = scaley ? double( h ) / screenGeometry(0).height() : 1; -#ifdef DEBUG - fprintf( stderr, "ANIM SCALING: %f %f\n", ratiox, ratioy ); -#endif - int framewnew = round( framew / ratiox ); - int framehnew = round( frameh / ratioy ); - QImage imgnew( framewnew * qMin( frames, ANIM_IMAGES_ROW ), - framehnew * (( frames + ANIM_IMAGES_ROW - 1 ) / ANIM_IMAGES_ROW ), img.depth()); - if( img.hasAlphaBuffer()) - imgnew.setAlphaBuffer( true ); - for( int frame = 0; - frame < frames; - ++frame ) - { - QImage im2 = img.copy( ( frame % ANIM_IMAGES_ROW ) * framew, ( frame / ANIM_IMAGES_ROW ) * frameh, framew, frameh ); - im2 = scale( im2, framewnew, framehnew ); - // don't use bitBlt(), it'd apply also alpha - for( int y = 0; - y < im2.height(); - ++y ) - { - QRgb* s = ( QRgb* ) im2.scanLine( y ); - QRgb* d = (( QRgb* ) imgnew.scanLine( y + ( frame / ANIM_IMAGES_ROW ) * framehnew )) - + ( frame % ANIM_IMAGES_ROW ) * framewnew; - memcpy( d, s, im2.width() * sizeof( QRgb )); - } - } - framew = framewnew; - frameh = framehnew; - img = imgnew; - if( ratiox * ratioy > 1 ) // only downscale - pregeneratePixmap( file, real_file, img.width(), img.height(), locolor, screenGeometry(0) ); - } - return img; - } - -static PixmapData* imageAnimToPixmaps( const QImage& img, int frames ) - { - if( img.isNull()) - return NULL; - int framew, frameh; - frameSize( img, frames, framew, frameh ); - PixmapData pix = imageToPixmap( img ); - PixmapData* ret = new PixmapData[ MAX_ITEMS ]; - GC gc = qt_xget_temp_gc( x11Screen(), false ); - for( int frame = 0; - frame < frames; - ++frame ) - { - Pixmap p = XCreatePixmap( qt_xdisplay(), DefaultRootWindow( qt_xdisplay()), framew, frameh, x11Depth()); - XCopyArea( qt_xdisplay(), pix.hd, p, gc, - ( frame % ANIM_IMAGES_ROW ) * framew, ( frame / ANIM_IMAGES_ROW ) * frameh, framew, frameh, 0, 0 ); - ret[ frame ].hd = p; - ret[ frame ].w = framew; - ret[ frame ].h = frameh; - ret[ frame ].d = x11Depth(); - } - if( pix.hd != None ) - XFreePixmap( qt_xdisplay(), pix.hd ); - return ret; - } - -static void doPaint( const QRect& area ) - { -#if 0 - fprintf( stderr, "PAINT: %d,%d-%dx%d\n", area.x(), area.y(), area.width(), area.height()); -#endif - if( window == None ) - return; // delayed - // double-buffer - Pixmap pixmap = XCreatePixmap( qt_xdisplay(), DefaultRootWindow( qt_xdisplay()), - area.width(), area.height(), x11Depth()); - GC gc = qt_xget_temp_gc( x11Screen(), false ); - // copy splash pixmap - XCopyArea( qt_xdisplay(), splash_pixmap, pixmap, gc, - area.x(), area.y(), area.width(), area.height(), 0, 0 ); - // add animations - for( int i = 0; - i < MAX_ITEMS; - ++i ) - { - AnimData* anim = animations[ i ]; - PixmapData* frame = anim != NULL ? &anim->frames[ anim->current_frame ] : NULL; - if( anim != NULL - && area.intersects( QRect( anim->x, anim->y, frame->w, frame->h ))) - { - XCopyArea( qt_xdisplay(), frame->hd, pixmap, gc, - qMax( 0, area.x() - anim->x ), qMax( 0, area.y() - anim->y ), - area.x() - anim->x + area.width(), area.y() - anim->y + area.height(), - qMax( 0, anim->x - area.x()), qMax( 0, anim->y - area.y())); - } - } - XCopyArea( qt_xdisplay(), pixmap, window, gc, 0, 0, area.width(), area.height(), area.x(), area.y()); - XFreePixmap( qt_xdisplay(), pixmap ); - } - -static void createWindow() - { - assert( window == None ); -#ifdef DEBUG - fprintf( stderr, "GEOMETRY: %d %d %d %d\n", geometry.x(), geometry.y(), geometry.width(), geometry.height()); -#endif - XSetWindowAttributes attrs; - QRect geom = totalScreenGeometry(); - attrs.override_redirect = True; - attrs.background_pixmap = None; -// attrs.override_redirect = False; - window = XCreateWindow( qt_xdisplay(), DefaultRootWindow( qt_xdisplay()), - geom.x(), geom.y(), geom.width(), geom.height(), - 0, CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect | CWBackPixmap, &attrs ); -#ifndef NDEBUG - XSelectInput( qt_xdisplay(), window, ButtonPressMask | ExposureMask ); -#else - XSelectInput( qt_xdisplay(), window, ExposureMask ); -#endif - XClassHint class_hint; - class_hint.res_name = const_cast< char* >( "ksplashx" ); - class_hint.res_class = const_cast< char* >( "ksplashx" ); - XSetWMProperties( qt_xdisplay(), window, NULL, NULL, NULL, 0, NULL, NULL, &class_hint ); - XMapRaised( qt_xdisplay(), window ); - } - -static void createSplashImage() - { - QRect geom = totalScreenGeometry(); - assert( splash_image.isNull()); - assert( splash_pixmap == None ); - splash_image = QImage( geom.size(), 32 ); - splash_pixmap = XCreatePixmap( qt_xdisplay(), DefaultRootWindow( qt_xdisplay()), - geom.width(), geom.height(), x11Depth()); - } - -static bool waitState( int expected_state ) - { - if( expected_state <= state ) - return false; - if( window == None ) - createWindow(); - if( splash_image.isNull()) - { - fprintf( stderr, "No window contents\n" ); - exit( 3 ); - } - time_t test_time = time( NULL ) + 2; -#ifdef DEBUG - fprintf( stderr,"AWATING STATE: %d (%s)\n", expected_state, states[ expected_state ] ); -#endif - if( parent_pipe >= 0 && screen_number == 0) - { // wait for paint being finished, and tell parent to exit - XSync( qt_xdisplay(), False ); - char buf = '\0'; - write( parent_pipe, &buf, 1 ); - close( parent_pipe ); - parent_pipe = -1; - } -#ifndef NDEBUG - const int doubleclick_delay = 200; // mouse doubleclick delay - in ms - struct timeval button_press_time, current_time; // we need timeval to deal with milliseconds - button_press_time.tv_sec = 0; - button_press_time.tv_usec = 0; - long click_delay, click_delay_seconds, click_delay_useconds; -#endif - for(;;) - { - while( XPending( qt_xdisplay())) - { - XEvent ev; - XNextEvent( qt_xdisplay(), &ev ); -#ifndef NDEBUG - if( ev.type == ButtonPress && ev.xbutton.window == window && ev.xbutton.button == Button1 ) - { - gettimeofday( ¤t_time, NULL ); - - // find difference in milliseconds with current and previous mouse presses times - click_delay_seconds = current_time.tv_sec - button_press_time.tv_sec; - click_delay_useconds = current_time.tv_usec - button_press_time.tv_usec; - click_delay = ( click_delay_seconds * 1000 + click_delay_useconds / 1000.0 ) + 0.5; - - if( click_delay <= doubleclick_delay ) - { - // close splash on doubleclick - final_time = time( NULL ); - break; - } - gettimeofday( &button_press_time, NULL ); - } -#endif - if( ev.type == Expose && ev.xexpose.window == window ) - doPaint( QRect( ev.xexpose.x, ev.xexpose.y, ev.xexpose.width, ev.xexpose.height )); - if( ev.type == ConfigureNotify && ev.xconfigure.event == DefaultRootWindow( qt_xdisplay())) - XRaiseWindow( qt_xdisplay(), window ); - if( ev.type == ClientMessage && ev.xclient.window == DefaultRootWindow( qt_xdisplay()) - && ev.xclient.message_type == kde_splash_progress ) - { - // based on ksplash - const char* s = ev.xclient.data.b; -#ifdef DEBUG - fprintf( stderr,"MESSAGE: %s\n", s ); -#endif - int new_state = -1; - for( int i = 0; - i < int( sizeof( states ) / sizeof( states[ 0 ] )); - ++i ) - { - if( strcmp( s, states[ i ] ) == 0 ) - { - new_state = i; - break; - } - } - if( new_state == -1 ) - { -#ifdef DEBUG - fprintf( stderr, "UNKNOWN SPLASH STATE: %s\n", s ); -#endif - } - else if( new_state > state ) - { - state = new_state; - if( state >= LAST_STATE ) - final_time = time( NULL ) + 1; // quit after short time - } - } - } - if( test && time( NULL ) >= test_time ) - { - ++state; - test_time = time( NULL ) + 2; - } - if( expected_state <= state ) - return false; - struct timeval tm_start, tm_end; - gettimeofday( &tm_start, NULL ); - fd_set set; - FD_ZERO( &set ); - FD_SET( XConnectionNumber( qt_xdisplay()), &set ); - int delay = 1000; - for( int i = 0; - i < MAX_ITEMS; - ++i ) - if( animations[ i ] != NULL && animations[ i ]->delay < delay * 2 ) - delay = animations[ i ]->delay / 2; - struct timeval tv; - tv.tv_sec = 0; - tv.tv_usec = delay * 1000; - select( XConnectionNumber( qt_xdisplay()) + 1, &set, NULL, NULL, &tv ); - if( time( NULL ) >= final_time ) - { -#ifdef DEBUG - fprintf( stderr, "EXITING\n" ); -#endif - return true; // ---> - } - gettimeofday( &tm_end, NULL ); - int real_delay = (( tm_end.tv_sec - tm_start.tv_sec ) * 1000000 + tm_end.tv_usec - tm_start.tv_usec ) / 1000; - for( int i = 0; - i < MAX_ITEMS; - ++i ) - { - AnimData* anim = animations[ i ]; - if( anim != NULL && anim->updateFrame( real_delay )) - doPaint( QRect( anim->x, anim->y, anim->frames[ anim->current_frame ].w, anim->frames[ anim->current_frame ].h )); - } - } - } - -static bool checkRelative( const char* ref ) - { - if( ref[ 0 ] == '\0' || ref[ 1 ] == '\0' || ref[ 2 ] != '\0' ) - return false; - if( strchr( "LRC", ref[ 0 ] ) == NULL ) - return false; - if( strchr( "TBC", ref[ 1 ] ) == NULL ) - return false; - return true; - } - -static int makeAbsolute( char screen, int val, char image, int size, int screen_size ) - { - int pos; - switch( screen ) - { - case 'L': - case 'T': - pos = 0; - break; - case 'R': - case 'B': - pos = screen_size; - break; - case 'C': - pos = screen_size / 2; - break; - default: - exit( 3 ); - } - pos += val; - switch( image ) - { - case 'L': - case 'T': - pos -= 0; - break; - case 'R': - case 'B': - pos -= size; - break; - case 'C': - pos -= size / 2; - break; - default: - exit( 3 ); - } - return pos; - } - -static int makeAbsoluteX( const char* screen_ref, int x_rel, const char* image_ref, int width ) - { - return makeAbsolute( screen_ref[ 0 ], x_rel, image_ref[ 0 ], width, geometry.width()) + geometry.x(); - } - -static int makeAbsoluteY( const char* screen_ref, int y_rel, const char* image_ref, int height ) - { - return makeAbsolute( screen_ref[ 1 ], y_rel, image_ref[ 1 ], height, geometry.height()) + geometry.y(); - } - -static inline QRgb blend( QRgb c, QRgb background ) - { - if( qAlpha( c ) == 255 ) - return c; - return qRgb( ( qRed( background ) * ( 255 - qAlpha( c ) ) + qRed( c ) * qAlpha( c ) ) / 255, - ( qGreen( background ) * ( 255 - qAlpha( c ) ) + qGreen( c ) * qAlpha( c ) ) / 255, - ( qBlue( background ) * ( 255 - qAlpha( c ) ) + qBlue( c ) * qAlpha( c ) ) / 255 ); - } - -static void blend( QImage& img, int x_pos, int y_pos, int x_img, int y_img, int w_img, int h_img ) - { - if( !img.hasAlphaBuffer()) - return; // it doesn't have alpha, so it is the blended result - for( int y = 0; - y < h_img; - ++y ) - { - QRgb* s = (( QRgb* )( splash_image.scanLine( y + y_pos ))) + x_pos; - QRgb* d = (( QRgb* )( img.scanLine( y + y_img ))) + x_img; - for( int x = 0; - x < w_img; - ++x, ++d, ++s ) - { - *d = blend( *d, *s ); - } - } - } - -static void blend( QImage& img, int x_pos, int y_pos ) - { - blend( img, x_pos, y_pos, 0, 0, img.width(), img.height()); - img.setAlphaBuffer( false ); - } - -static void blendAnim( QImage& img, int x_pos, int y_pos, int frames ) - { - int framew, frameh; - frameSize( img, frames, framew, frameh ); - for( int frame = 0; - frame < frames; - ++frame ) - { - blend( img, x_pos, y_pos, - ( frame % ANIM_IMAGES_ROW ) * framew, ( frame / ANIM_IMAGES_ROW ) * frameh, framew, frameh ); - } - img.setAlphaBuffer( false ); - } - -static void updateSplashImage( const QImage& img, int x_pos, int y_pos ) - { - for( int y = 0; - y < img.height(); - ++y ) - { - QRgb* s = (( QRgb* )( img.scanLine( y ))); - QRgb* d = (( QRgb* )( splash_image.scanLine( y + y_pos ))) + x_pos; - for( int x = 0; - x < img.width(); - ++x, ++d, ++s ) - { - *d = *s; - } - } - PixmapData pix = imageToPixmap( img ); - GC gc = qt_xget_temp_gc( x11Screen(), false ); - XCopyArea( qt_xdisplay(), pix.hd, splash_pixmap, gc, 0, 0, img.width(), img.height(), x_pos, y_pos ); - XFreePixmap( qt_xdisplay(), pix.hd ); - } - -void runSplash( const char* them, bool t, int p ) - { - geometry = screenGeometry(0); - // fetch the $KDEHOME environment variable that may point to e.g. "~/.kde4" - if( getenv( "KDEHOME" ) && getenv( "KDEHOME" )[ 0 ] ) - snprintf( kdehome, 1024, "%s", getenv( "KDEHOME" )); - else - snprintf( kdehome, 1024, "%s/" KDE_DEFAULT_HOME, getenv( "HOME" ) ? getenv( "HOME" ) : "" ); - - // fetch the name of the theme which is also used as directory name. - snprintf( theme_name, 1024, "%s", them ); - // fetch the theme-directory,e.g. "/opt/kde4/share/apps/ksplash/Themes/MyKSplashXThemeName" - snprintf( theme_dir, 1024, "%s/ksplash/Themes/%s", KDE_DATADIR, them ); - - test = t; - parent_pipe = p; - anim_count = 0; - state = 0; - window = None; - splash_image = QImage(); - splash_pixmap = None; - final_time = time( NULL ) + 300; - int desc_w, desc_h; - - // try to load the themes description.txt file from within the theme_dir - FILE* datafile = fopen( findFile( "description.txt", &desc_w, &desc_h ), "r" ); - if( datafile == NULL ) - { - // if we failed to read it, try it with $KDEHOME as theme_dir. This - // is needed to be able to load local (aka by the user in his local - // home-directory) installed themes. - snprintf( theme_dir, 1024, "%s/share/apps/ksplash/Themes/%s", kdehome, them ); - datafile = fopen( findFile( "description.txt", &desc_w, &desc_h ), "r" ); - if( datafile == NULL ) - { - fprintf( stderr, "Cannot find description.txt file.\n" ); - exit( 2 ); - } - } - - struct stat stat_buf; - if( fstat( fileno( datafile ), &stat_buf ) != 0 ) - { - fprintf( stderr, "Cannot read description.txt file.\n" ); - exit( 2 ); - } - timestamp = stat_buf.st_mtime; - // check also Theme.rc, as artists are likely to just ignore updating description.txt - // when updating the theme but will touch info in Theme.rc - char tmp[ 1024 ]; - snprintf( tmp, 1024, "%s/Theme.rc", theme_dir ); - if( stat( tmp, &stat_buf ) == 0 && stat_buf.st_mtime > timestamp ) - timestamp = stat_buf.st_mtime; - double ratiox = double( desc_w ) / screenGeometry(0).width(); // only for coordinates in the description file - double ratioy = double( desc_h ) / screenGeometry(0).height(); // only for coordinates in the description file - XSelectInput( qt_xdisplay(), DefaultRootWindow( qt_xdisplay()), SubstructureNotifyMask ); - kde_splash_progress = XInternAtom( qt_xdisplay(), "_KDE_SPLASH_PROGRESS", False ); - for( int i = 0; - i < MAX_ITEMS; - ++i ) - animations[ i ] = NULL; - while( !feof( datafile )) - { - char line[ 1024 ]; - if( !freadline( line, 1024, datafile )) - break; - strip_whitespace( line ); - char buf[ 1024 ]; - int number, x, y, w, h, x_rel, y_rel, frames, delay, repeat, items; - char screen_ref[ 3 ]; - char window_ref[ 3 ]; - char image_ref[ 3 ]; - bool handled = false; - if( line[ 0 ] == '#' || line[ 0 ] == '\0' ) - continue; - else if( sscanf( line, "SCALEX %1023s", buf ) == 1 ) - { - handled = true; - if( strcmp( buf, "ON" ) == 0 ) - scalex = true; - else if( strcmp( buf, "OFF" ) == 0 ) - scalex = false; - else - { - fprintf( stderr, "Bad scale x: %s\n", line ); - exit( 3 ); - } - } - else if( sscanf( line, "SCALEY %1023s", buf ) == 1 ) - { - handled = true; - if( strcmp( buf, "ON" ) == 0 ) - scaley = true; - else if( strcmp( buf, "OFF" ) == 0 ) - scaley = false; - else - { - fprintf( stderr, "Bad scale y: %s\n", line ); - exit( 3 ); - } - } - else if( sscanf( line, "SCALE %1023s", buf ) == 1 ) - { - handled = true; - if( strcmp( buf, "ON" ) == 0 ) - scalex = scaley = true; - else if( strcmp( buf, "OFF" ) == 0 ) - scalex = scaley = false; - else - { - fprintf( stderr, "Bad scale: %s\n", line ); - exit( 3 ); - } - } - else if( sscanf( line, "GEOMETRY %d %d %d %d", &x, &y, &w, &h ) == 4 ) - { - handled = true; - if( scalex || scaley ) - { - x = scalex ? round( x / ratiox ) : x; - y = scaley ? round( y / ratioy ) : y; - w = scalex ? round( w / ratiox ) : w; - h = scaley ? round( h / ratioy ) : h; - } - if( x < 0 ) - x += screenGeometry(0).width(); - if( y < 0 ) - y += screenGeometry(0).height(); - QRect r( x, y, w, h ); - if( screenGeometry(0).contains( r )) - { - geometry = r; - if( window != None ) - XMoveResizeWindow( qt_xdisplay(), window, x, y, w, h ); - if( !splash_image.isNull()) - { // destroy and then recreate - splash_image = QImage(); - XFreePixmap( qt_xdisplay(), splash_pixmap ); - splash_pixmap = None; - } - createSplashImage(); - } - else - { - fprintf( stderr, "Wrong geometry: %s\n", line ); - exit( 3 ); - } - } - else if( sscanf( line, "GEOMETRY_REL %2s %d %d %2s %d %d", - screen_ref, &x_rel, &y_rel, window_ref, &w, &h ) == 6 ) - { - handled = true; - if( scalex || scaley ) - { - x_rel = scalex ? round( x_rel / ratiox ) : x_rel; - y_rel = scaley ? round( y_rel / ratioy ) : y_rel; - w = scalex ? round( w / ratiox ) : w; - h = scaley ? round( h / ratioy ) : h; - } - if( !checkRelative( screen_ref ) - || !checkRelative( window_ref )) - { - fprintf( stderr,"Bad reference point: %s\n", line ); - exit( 3 ); - } - x = makeAbsoluteX( screen_ref, x_rel, window_ref, w ); - y = makeAbsoluteY( screen_ref, y_rel, window_ref, h ); - QRect r( x, y, w, h ); - if( screenGeometry(0).contains( r )) - { - geometry = r; - if( window != None ) - XMoveResizeWindow( qt_xdisplay(), window, x, y, w, h ); - if( !splash_image.isNull()) - { // destroy and then recreate - splash_image = QImage(); - XFreePixmap( qt_xdisplay(), splash_pixmap ); - splash_pixmap = None; - } - createSplashImage(); - } - else - { - fprintf( stderr, "Wrong geometry: %s\n", line ); - exit( 3 ); - } - } - else if( sscanf( line, "BACKGROUND_IMAGE %d %d %1023s", &x, &y, buf ) == 3 ) - { - int screens = screenCount(); - handled = true; - if( scalex || scaley ) - { - x = scalex ? round( x / ratiox ) : x; - y = scaley ? round( y / ratioy ) : y; - } - if( splash_image.isNull()) - createSplashImage(); - for (int i = 0; i < screens; ++i) { - QRect geom = screenGeometry(i); - QImage img = loadImage( buf, geom ); - if( !img.isNull()) - { - blend( img, geom.x() + x, geom.y() + y ); - updateSplashImage( img, geom.x() + x, geom.y() + y ); - doPaint( QRect( geom.x() + x, geom.y() + y, img.width(), img.height())); - } - else - { - fprintf( stderr, "Bad image: %s\n", line ); - exit( 3 ); - } - } - } - else if( sscanf( line, "BACKGROUND %1023s", buf ) == 1 ) - { - handled = true; - QColor background = QColor( buf ); - QRect geom = totalScreenGeometry(); - if( !background.isValid()) - { - fprintf( stderr, "Bad color: %s\n", line ); - exit( 3 ); - } - if( splash_image.isNull()) - createSplashImage(); - splash_image.fill( background.rgb()); - XGCValues xgc; - xgc.foreground = background.pixel(); - GC gc = XCreateGC( qt_xdisplay(), splash_pixmap, GCForeground, &xgc ); - XFillRectangle( qt_xdisplay(), splash_pixmap, gc, 0, 0, geom.width(), geom.height()); - XFreeGC( qt_xdisplay(), gc ); - doPaint( QRect( 0, 0, geom.width(), geom.height())); - } - else if( sscanf( line, "IMAGE %d %d %1023s", &x, &y, buf ) == 3 ) - { - handled = true; - if( scalex || scaley ) - { - x = scalex ? round( x / ratiox ) : x; - y = scaley ? round( y / ratioy ) : y; - } - if( splash_image.isNull()) - createSplashImage(); - QImage img = loadImage( buf, screenGeometry(0) ); - if( !img.isNull()) - { -#if 0 - if( !QRect( 0, 0, geometry.width(), geometry.height()) - .contains( QRect( x, y, img.width(), img.height()))) - { - fprintf( stderr, "Image outside of geometry: %s\n", line ); - exit( 3 ); - } -#endif - blend( img, x, y ); - updateSplashImage( img, x, y ); - doPaint( QRect( x, y, img.width(), img.height())); - } - else - { - fprintf( stderr, "Bad image: %s\n", line ); - exit( 3 ); - } - } - else if( sscanf( line, "IMAGE_REL %2s %d %d %2s %1023s", - window_ref, &x_rel, &y_rel, image_ref, buf ) == 5 ) - { - handled = true; - if( scalex || scaley ) - { - x_rel = scalex ? round( x_rel / ratiox ) : x_rel; - y_rel = scaley ? round( y_rel / ratioy ) : y_rel; - } - if( !checkRelative( window_ref ) - || !checkRelative( window_ref )) - { - fprintf( stderr,"Bad reference point: %s\n", line ); - exit( 3 ); - } - if( splash_image.isNull()) - createSplashImage(); - QImage img = loadImage( buf, screenGeometry(0) ); - if( !img.isNull()) - { - x = makeAbsoluteX( window_ref, x_rel, image_ref, img.width()); - y = makeAbsoluteY( window_ref, y_rel, image_ref, img.height()); -#if 0 - if( !QRect( 0, 0, geometry.width(), geometry.height()) - .contains( QRect( x, y, img.width(), img.height()))) - { - fprintf( stderr, "Image outside of geometry: %s\n", line ); - exit( 3 ); - } -#endif - blend( img, x, y ); - updateSplashImage( img, x, y ); - doPaint( QRect( x, y, img.width(), img.height())); - } - else - { - fprintf( stderr, "Bad image: %s\n", line ); - exit( 3 ); - } - } - items = sscanf( line, "ANIM %d %d %d %d %1023s %d %d", &number, &x, &y, &frames, buf, &delay, &repeat ); - if( items == 6 ) - repeat = 0; // default - if( items == 6 || items == 7 ) - { - handled = true; - if( scalex || scaley ) - { - x = scalex ? round( x / ratiox ) : x; - y = scaley ? round( y / ratioy ) : y; - } - if( number <= 0 || number >= MAX_ITEMS ) - { - fprintf( stderr,"Bad number: %s\n", line ); - exit( 3 ); - } - if( frames <= 0 || frames > MAX_ITEMS ) - { - fprintf( stderr, "Frames limit reached: %s\n", line ); - exit( 3 ); - } - if( splash_image.isNull()) - createSplashImage(); - QImage imgs = loadAnimImage( buf, frames ); - if( !imgs.isNull()) - { - blendAnim( imgs, x, y, frames ); - PixmapData* pixs = imageAnimToPixmaps( imgs, frames ); - delete animations[ number ]; - animations[ number ] = new AnimData( x, y, pixs, frames, delay, repeat ); - } - } - items = sscanf( line, "ANIM_REL %d %2s %d %d %2s %d %1023s %d %d", - &number, window_ref, &x_rel, &y_rel, image_ref, &frames, buf, &delay, &repeat ); - if( items == 8 ) - repeat = 0; // default - if( items == 8 || items == 9 ) - { - handled = true; - if( scalex || scaley ) - { - x_rel = scalex ? round( x_rel / ratiox ) : x_rel; - y_rel = scaley ? round( y_rel / ratioy ) : y_rel; - } - if( number <= 0 || number >= MAX_ITEMS ) - { - fprintf( stderr,"Bad number: %s\n", line ); - exit( 3 ); - } - if( !checkRelative( window_ref ) - || !checkRelative( window_ref )) - { - fprintf( stderr,"Bad reference point: %s\n", line ); - exit( 3 ); - } - if( frames <= 0 || frames > MAX_ITEMS ) - { - fprintf( stderr, "Frames limit reached: %s\n", line ); - exit( 3 ); - } - if( splash_image.isNull()) - createSplashImage(); - QImage imgs = loadAnimImage( buf, frames ); - if( !imgs.isNull()) - { - int framew, frameh; - frameSize( imgs, frames, framew, frameh ); - x = makeAbsoluteX( window_ref, x_rel, image_ref, framew ); - y = makeAbsoluteY( window_ref, y_rel, image_ref, frameh ); - blendAnim( imgs, x, y, frames ); - PixmapData* pixs = imageAnimToPixmaps( imgs, frames ); - delete animations[ number ]; - animations[ number ] = new AnimData( x, y, pixs, frames, delay, repeat ); - } - } - else if( sscanf( line, "STOP_ANIM %d", &number ) == 1 ) - { - handled = true; - if( number <= 0 || number >= MAX_ITEMS || animations[ number ] == NULL ) - { - fprintf( stderr,"Bad number: %s\n", line ); - exit( 3 ); - } - AnimData* anim = animations[ number ]; - doPaint( QRect( anim->x, anim->y, anim->frames[ 0 ].w, anim->frames[ 0 ].h )); - delete animations[ number ]; - animations[ number ] = NULL; - } - else if( sscanf( line, "WAIT_STATE %s", buf ) == 1 ) - { - handled = true; - int new_state = -1; - for( int i = 0; - i < int( sizeof( states ) / sizeof( states[ 0 ] )); - ++i ) - { - if( strcmp( buf, states[ i ] ) == 0 ) - { - new_state = i; - break; - } - } - if( new_state == -1 ) - { - fprintf( stderr, "Unknown splash state: %s\n", buf ); - // don't make fatal, may be a theme for a newer version - } - else - { - if( waitState( new_state )) - break; // exiting - } - } - if( !handled ) - { - fprintf( stderr, "Unknown line: %s\n", line ); - exit( 3 ); - } - } - fclose( datafile ); - XDestroyWindow( qt_xdisplay(), window ); - window = None; - XFreePixmap( qt_xdisplay(), splash_pixmap ); - splash_pixmap = None; - splash_image = QImage(); - } diff --git a/ksplash/ksplashx/splash.h b/ksplash/ksplashx/splash.h deleted file mode 100644 index 88a555e6..00000000 --- a/ksplash/ksplashx/splash.h +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************** - -Copyright (C) 2007 Lubos Lunak - -Please see file LICENSE for the licensing terms of ksplashx as a whole. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*********************************************************************/ - -#ifndef SPLASH_H -#define SPLASH_H - -#include - -void runSplash( const char* theme, bool test, int pipe ); - -#endif diff --git a/ksplash/ksplashx/utils/CMakeLists.txt b/ksplash/ksplashx/utils/CMakeLists.txt deleted file mode 100644 index 20949019..00000000 --- a/ksplash/ksplashx/utils/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -########### next target ############### - -set( prepareanim_SRCS - prepareanim.cpp ) - -add_executable( prepareanim ${prepareanim_SRCS}) -target_link_libraries( prepareanim ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY}) - -########### next target ############### - -set( shade_SRCS - shade.cpp ) - -add_executable( shade ${shade_SRCS}) -target_link_libraries( shade ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY}) diff --git a/ksplash/ksplashx/utils/blend.py b/ksplash/ksplashx/utils/blend.py deleted file mode 100755 index d6ade7b1..00000000 --- a/ksplash/ksplashx/utils/blend.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python - -# -# This python helper script does blend 2 images together and produces -# a by KSplashX usuable PNG animation file. -# -# Use: -# blend.py img1.png img2.png output.png -# - -import sys, os, getopt, Image, ImageFile - -def generate(srcfile1,srcfile2,destfile): - srcimg1 = Image.open(srcfile1) - srcimg2 = Image.open(srcfile2) - - (width1,height1) = srcimg1.size - (width2,height2) = srcimg2.size - - maxwidth = width1>width2 and width1 or width2 - maxheight = height1>height2 and height1 or height2 - - if width1 != maxwidth or height1 != maxheight: - srcimg1.resize( (maxwidth,maxheight) ) - if width2 != maxwidth or height2 != maxheight: - srcimg2.resize( (maxwidth,maxheight) ) - - destimg = Image.new( "RGBA", (maxwidth*10,maxheight*2) ) - for row in range(1,3): - for col in range(1,11): - if row==1: - alpha = col*row/10.0 - else: - alpha = 1.0 - (col*row/20.0) - img = Image.blend(srcimg1, srcimg2, alpha) - x = maxwidth * col - maxwidth - y = maxheight * row - maxheight - destimg.paste(img,(x,y)) - destimg.save(destfile) - -def main(argv): - def usage(): - print "Syntax: %s " % os.path.basename(argv[0]) - - try: - opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help"]) - except getopt.GetoptError, err: - print str(err) # will print something like "option -a not recognized" - usage() - sys.exit(1) - - for o, a in opts: - if o in ("-h", "--help"): - usage() - sys.exit() - else: - assert False, "unhandled option" - - if len(args) < 3: - usage() - sys.exit(2) - - generate(args[0],args[1],args[2]) - -if __name__ == "__main__": - main(sys.argv) diff --git a/ksplash/ksplashx/utils/fromksplashmldefault.sh b/ksplash/ksplashx/utils/fromksplashmldefault.sh deleted file mode 100755 index 4a532612..00000000 --- a/ksplash/ksplashx/utils/fromksplashmldefault.sh +++ /dev/null @@ -1,104 +0,0 @@ -#! /bin/sh - -# This script creates a KSplashX theme from KSplashML's theme using the Default engine. -# Just run in the theme's directory with theme name as argument and it'll create a new subdirectory "theme". -# Note that the positions in the icon bar may be a bit off, as KSplashML itself has them off; -# if it doesn't work for you, fiddle with the positions below (two places, also the description.txt file) -# You should also afterwards check Theme.rc (only Engine= and descriptive fields like Name= should matter) - -# the -depth 8 is there to produce smaller png's (it doesn't seem to affect anything else *shrug*) - -if test $# -ne 1; then - echo Theme name missing. - exit 1 -fi -theme="$1" - -# check -grep "Engine = Default" Theme.rc >/dev/null 2>&1 || ( echo "No Theme.rc or Engine is not Default"; exit 1 ) - -# create the subdir -rm -r "$theme" 2>/dev/null -mkdir "$theme" -mkdir "$theme"/1600x1200 - -# create background image from top, bar and bottom -montage splash_top.png splash_inactive_bar.png splash_bottom.png -geometry +0+0 -tile 1x3 -depth 8 "$theme"/1600x1200/background.png - -# cut the icons from the icon bar -# numbers are x position, width and icon number -for i in 0-58-1 58-58-2 116-58-3 174-58-4 232-58-5 290-50-6 340-60-7; do - x=`echo $i | sed 's/\(.*\)-.*-.*/\1/'` - w=`echo $i | sed 's/.*-\(.*\)-.*/\1/'` - n=`echo $i | sed 's/.*-.*-\(.*\)/\1/'` - convert splash_inactive_bar.png -crop ${w}x58+${x}+0 -depth 8 iconin.png - convert splash_active_bar.png -crop ${w}x58+${x}+0 -depth 8 iconac.png - montage iconac.png iconin.png -tile 2x1 -geometry +0+0 -depth 8 "$theme"/1600x1200/icon${n}_anim.png - cp iconac.png "$theme"/1600x1200/icon${n}.png - rm iconin.png iconac.png -done - -# preview file -cp Preview.png "$theme"/Preview.png - -# Theme.rc file -cat Theme.rc \ - | sed 's/Engine = Default/Engine = KSplashX/' \ - | sed "s/\[KSplash Theme: .*\]/\[KSplash Theme: $theme\]/" \ - > "$theme"/Theme.rc - -# CMakeLists.txt - -cat >"$theme"/CMakeLists.txt <"$theme"/1600x1200/description.txt < -#include - -#include -#include -#include - -const int ANIM_IMAGES_ROW = 10; // must match splash - -int main( int argc, char* argv[] ) - { - // - if( argc < 2 ) - return 1; - const int ARGC_DIFF = 1; - int frames = argc - ARGC_DIFF; - QImage result; - for( int frame = 0; - frame < frames; - ++frame ) - { - QImage fr( argv[ ARGC_DIFF + frame ] ); - if( fr.isNull()) - return 2; - int w = fr.width(); - int h = fr.height(); - if( result.isNull()) - { // initialize - if( frames < ANIM_IMAGES_ROW ) - result = QImage( frames * w, h, QImage::Format_ARGB32 ); - else - result = QImage( ANIM_IMAGES_ROW * w, ( frames + ANIM_IMAGES_ROW - 1 ) / ANIM_IMAGES_ROW * h, QImage::Format_ARGB32 ); - } - int basex = ( frame % ANIM_IMAGES_ROW ) * w; - int basey = frame / ANIM_IMAGES_ROW * h; - for( int y = 0; - y < h; - ++y ) - for( int x = 0; - x < w; - ++x ) - result.setPixel( basex + x, basey + y, fr.pixel( x, y )); - } - result.save( "result.png", "PNG" ); - } diff --git a/ksplash/ksplashx/utils/shade.cpp b/ksplash/ksplashx/utils/shade.cpp deleted file mode 100644 index a6693002..00000000 --- a/ksplash/ksplashx/utils/shade.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// This tool makes the image grayscale and transparent. - -#include - -#include -#include -#include - -int main( int argc, char* argv[] ) - { - if( argc != 2 ) - return 1; - QImage im( argv[ 1 ] ); - if( im.isNull()) - return 2; - for( int x = 0; - x < im.width(); - ++x ) - for( int y = 0; - y < im.height(); - ++y ) - { - QRgb c = im.pixel( x, y ); - QRgb c2 = qRgba( qGray( c ), qGray( c ), qGray( c ), qAlpha( c ) / 2 ); - im.setPixel( x, y, c2 ); - } - im.save( "result.png", "PNG" ); - } diff --git a/ksplash/ksplashx/x11_defs.cpp b/ksplash/ksplashx/x11_defs.cpp deleted file mode 100644 index d39c5cc8..00000000 --- a/ksplash/ksplashx/x11_defs.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include -#include - -#include "qnamespace.h" -#include "qcolor.h" -#include "x11_defs.h" -#include -#include - -#ifdef HAVE_XINERAMA -extern "C" { // for older XFree86 versions -#include -} -#endif - -using namespace std; - -Display* spl_dpy; -int spl_screen; -void* spl_visual; -int spl_depth; -Colormap spl_colormap; -int spl_cells; - -static Display* appDpy; -static int appScreenCount; - -static QRect totalScreenRect; -static vector screenRects; -static int screens; - -int screenCount() - { - return screens; - } - -QRect totalScreenGeometry() - { - return totalScreenRect; - } - -QRect screenGeometry(int screen) - { - if (screen < 0 || screen > screens - 1) - { - abort(); - } - return screenRects[screen]; - } - -void detectScreenGeometry() - { - Display* dpy = x11Display(); - totalScreenRect = QRect(0, - 0, - WidthOfScreen( ScreenOfDisplay( dpy, DefaultScreen( dpy ))), - HeightOfScreen( ScreenOfDisplay( dpy, DefaultScreen( dpy )))); -#ifdef HAVE_XINERAMA - // Xinerama code from Qt - XineramaScreenInfo *xinerama_screeninfo = 0; - int unused; - bool use_xinerama = XineramaQueryExtension( dpy, &unused, &unused ) - && XineramaIsActive( dpy ); - if (use_xinerama) - { - xinerama_screeninfo = XineramaQueryScreens( dpy, &screens ); - QRect sg; - QRect total; - - for (int s = 0; s < screens; ++s) - { - QRect cs(xinerama_screeninfo[s].x_org, - xinerama_screeninfo[s].y_org, - xinerama_screeninfo[s].width, - xinerama_screeninfo[s].height); - screenRects.push_back(cs); - } - } - else -#endif - { - screens = 1; - screenRects.push_back(totalScreenRect); - } - } - -void createColormap() - { - // use default colormap - XStandardColormap *stdcmap; - VisualID vid = - XVisualIDFromVisual((Visual *) spl_visual ); - int i, count; - - spl_colormap = 0; - Display* appDpy = spl_dpy; - int screen = spl_screen; - - if ( true /*|| ! serverVendor.contains( "Hewlett-Packard" )*/ ) { - // on HPUX 10.20 local displays, the RGB_DEFAULT_MAP colormap - // doesn't give us correct colors. Why this happens, I have - // no clue, so we disable this for HPUX - if (XGetRGBColormaps(appDpy, - RootWindow(spl_dpy,spl_screen)/*QPaintDevice::x11AppRootWindow( screen )*/, - &stdcmap, &count, XA_RGB_DEFAULT_MAP)) { - i = 0; - while (i < count && - spl_colormap == 0) { - if (stdcmap[i].visualid == vid) { - spl_colormap = - stdcmap[i].colormap; - } - i++; - } - - XFree( (char *)stdcmap ); - } - } - - if (spl_colormap == 0) { - spl_colormap = - DefaultColormap(appDpy, screen); - } - } - -static -int x11ErrorHandler(Display *d, XErrorEvent *e) - { - char msg[80], req[80], number[80]; - XGetErrorText(d, e->error_code, msg, sizeof(msg)); - sprintf(number, "%d", e->request_code); - XGetErrorDatabaseText(d, "XRequest", number, "", req, sizeof(req)); - - fprintf(stderr, "%s(0x%lx): %s\n", req, e->resourceid, msg); - return 0; - } - -bool openDisplay() - { - spl_dpy = XOpenDisplay( NULL ); - if( spl_dpy == NULL ) - return false; - XSetErrorHandler( x11ErrorHandler ); - spl_screen = DefaultScreen( spl_dpy ); - spl_depth = DefaultDepth( spl_dpy, spl_screen ); - spl_visual = DefaultVisual( spl_dpy, spl_screen ); - spl_cells = DisplayCells( spl_dpy, spl_screen ); - appScreenCount = ScreenCount( spl_dpy ); - appDpy = spl_dpy; - createColormap(); - detectScreenGeometry(); - QColor::initialize(); - return true; - } - -void closeDisplay() - { - XCloseDisplay( spl_dpy ); - } - -static GC* app_gc_ro = 0; // read-only GC -static GC* app_gc_tmp = 0; // temporary GC -static GC* app_gc_ro_m = 0; // read-only GC (monochrome) -static GC* app_gc_tmp_m = 0; // temporary GC (monochrome) - -static GC create_gc( int scrn, bool monochrome ) -{ - GC gc; - if ( monochrome ) { - Pixmap pm = XCreatePixmap( appDpy, RootWindow( appDpy, scrn ), 8, 8, 1 ); - gc = XCreateGC( appDpy, pm, 0, 0 ); - XFreePixmap( appDpy, pm ); - } else { - if ( QPaintDevice::x11AppDefaultVisual( scrn ) ) { - gc = XCreateGC( appDpy, RootWindow( appDpy, scrn ), 0, 0 ); - } else { - Window w; - XSetWindowAttributes a; - a.background_pixel = Qt::black.pixel( scrn ); - a.border_pixel = Qt::black.pixel( scrn ); - a.colormap = QPaintDevice::x11AppColormap( scrn ); - w = XCreateWindow( appDpy, RootWindow( appDpy, scrn ), 0, 0, 100, 100, - 0, QPaintDevice::x11AppDepth( scrn ), InputOutput, - (Visual*)QPaintDevice::x11AppVisual( scrn ), - CWBackPixel|CWBorderPixel|CWColormap, &a ); - gc = XCreateGC( appDpy, w, 0, 0 ); - XDestroyWindow( appDpy, w ); - } - } - XSetGraphicsExposures( appDpy, gc, False ); - return gc; -} - -GC qt_xget_readonly_gc( int scrn, bool monochrome ) // get read-only GC -{ - if ( scrn < 0 || scrn >= appScreenCount ) { -#if 0 - qDebug("invalid screen %d %d", scrn, appScreenCount ); - QWidget* bla = 0; - bla->setName("hello"); -#endif - } - GC gc; - if ( monochrome ) { - if ( !app_gc_ro_m ) // create GC for bitmap - memset( (app_gc_ro_m = new GC[appScreenCount]), 0, appScreenCount * sizeof( GC ) ); - if ( !app_gc_ro_m[scrn] ) - app_gc_ro_m[scrn] = create_gc( scrn, true ); - gc = app_gc_ro_m[scrn]; - } else { // create standard GC - if ( !app_gc_ro ) - memset( (app_gc_ro = new GC[appScreenCount]), 0, appScreenCount * sizeof( GC ) ); - if ( !app_gc_ro[scrn] ) - app_gc_ro[scrn] = create_gc( scrn, false ); - gc = app_gc_ro[scrn]; - } - return gc; -} - -GC qt_xget_temp_gc( int scrn, bool monochrome ) // get temporary GC -{ - if ( scrn < 0 || scrn >= appScreenCount ) { -#if 0 - qDebug("invalid screen (tmp) %d %d", scrn, appScreenCount ); - QWidget* bla = 0; - bla->setName("hello"); -#endif - } - GC gc; - if ( monochrome ) { - if ( !app_gc_tmp_m ) // create GC for bitmap - memset( (app_gc_tmp_m = new GC[appScreenCount]), 0, appScreenCount * sizeof( GC ) ); - if ( !app_gc_tmp_m[scrn] ) - app_gc_tmp_m[scrn] = create_gc( scrn, true ); - gc = app_gc_tmp_m[scrn]; - } else { // create standard GC - if ( !app_gc_tmp ) - memset( (app_gc_tmp = new GC[appScreenCount]), 0, appScreenCount * sizeof( GC ) ); - if ( !app_gc_tmp[scrn] ) - app_gc_tmp[scrn] = create_gc( scrn, false ); - gc = app_gc_tmp[scrn]; - } - return gc; -} diff --git a/ksplash/ksplashx/x11_defs.h b/ksplash/ksplashx/x11_defs.h deleted file mode 100644 index d32c1a1d..00000000 --- a/ksplash/ksplashx/x11_defs.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** This file is based on sources of the Qt GUI Toolkit, used under the terms -** of the GNU General Public License version 2 (see the original copyright -** notice below). -** All further contributions to this file are (and are required to be) -** licensed under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** The original Qt license header follows: -** -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of the kernel module of the Qt GUI Toolkit. -** -** This file may be distributed under the terms of the Q Public License -** as defined by Trolltech AS of Norway and appearing in the file -** LICENSE.QPL included in the packaging of this file. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition -** licenses may use this file in accordance with the Qt Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for -** information about Qt Commercial License Agreements. -** See http://www.trolltech.com/qpl/ for QPL licensing information. -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef X11_DEFS_H -#define X11_DEFS_H - -#include "qrect.h" - -#include -#include -#include - -extern Display* spl_dpy; -extern int spl_screen; -extern void* spl_visual; -extern int spl_depth; -extern Colormap spl_colormap; -extern int spl_cells; - -inline int x11Depth() { return spl_depth; } -inline Display *x11Display() { return spl_dpy; } -inline Display * qt_xdisplay() { return spl_dpy; } -inline void *x11Visual() { return spl_visual; } -inline int x11Screen() { return spl_screen; } -inline int x11Cells() { return spl_cells; } -GC qt_xget_readonly_gc( int scrn, bool monochrome ); // get read-only GC -GC qt_xget_temp_gc( int scrn, bool monochrome ); // get temporary GC -inline Colormap x11AppColormap() { return spl_colormap; } - -int screenCount(); -QRect screenGeometry(int screen); -QRect totalScreenGeometry(); - -bool openDisplay(); -void closeDisplay(); - -class QPaintDevice - { - public: - static Display* x11AppDisplay() { return ::x11Display(); } - static int x11AppScreen() { return ::x11Screen(); } - static void *x11AppVisual( int = -1 ) { return ::x11Visual(); } - static void *x11AppDefaultVisual( int = -1 ) { return ::x11Visual(); } - static int x11AppDepth( int = -1 ) { return ::x11Depth(); } - static int x11AppCells( int = -1 ) { return ::x11Cells(); } - static Colormap x11AppColormap( int = -1 ) { return ::x11AppColormap(); } - static Colormap x11AppDefaultColormap( int = -1 ) { return ::x11AppColormap(); } - }; - -class QApplication - { - public: - enum ColorSpec { NormalColor=0, CustomColor=1, ManyColor=2 }; - static int colorSpec() { return NormalColor; } - }; - -#endif diff --git a/ksplash/none/CMakeLists.txt b/ksplash/none/CMakeLists.txt deleted file mode 100644 index bbf5bee5..00000000 --- a/ksplash/none/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -install( FILES Theme.rc DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksplash/Themes/None ) diff --git a/ksplash/none/Theme.rc b/ksplash/none/Theme.rc deleted file mode 100644 index d4b33709..00000000 --- a/ksplash/none/Theme.rc +++ /dev/null @@ -1,7 +0,0 @@ -[KSplash Theme: None] -Name = No Splash Screen -Description = Splash Screen Turned Off -Version = 1.0 -Engine = None -License = MIT -Homepage = http://www.kde.org diff --git a/kstartupconfig/CMakeLists.txt b/kstartupconfig/CMakeLists.txt deleted file mode 100644 index d16ddb89..00000000 --- a/kstartupconfig/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -########### kstartupconfig ############### - -set(kstartupconfig_SRCS kstartupconfig.cpp ) - -add_executable(kstartupconfig4 ${kstartupconfig_SRCS}) - -target_link_libraries(kstartupconfig4 ${KDE4_KDECORE_LIBS} ) - -install(TARGETS kstartupconfig4 ${INSTALL_TARGETS_DEFAULT_ARGS} ) - diff --git a/kstartupconfig/kstartupconfig.cpp b/kstartupconfig/kstartupconfig.cpp deleted file mode 100644 index f266000a..00000000 --- a/kstartupconfig/kstartupconfig.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************** - - Copyright (C) 2005 Lubos Lunak - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - -****************************************************************************/ - -#undef QT_NO_CAST_ASCII - -// See description in kstartupconfig.cpp . -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#define KPATH_SEPARATOR ':' - -static QString get_entry( QString* ll ) -{ - QString& l = *ll; - l = l.trimmed(); - if( l.isEmpty()) - return QString(); - QString ret; - if( l[ 0 ] == '\'' ) { - int pos = 1; - while( pos < l.length() && l[ pos ] != '\'' ) - ret += l[ pos++ ]; - if( pos >= l.length()) { - *ll = QString(); - return QString(); - } - *ll = l.mid( pos + 1 ); - return ret; - } - int pos = 0; - while( pos < l.length() && l[ pos ] != ' ' ) - ret += l[ pos++ ]; - *ll = l.mid( pos ); - return ret; -} - -#define I18N_NOEXTRACT( x ) ki18n( x ) - -int main( int argc, char **argv ) -{ - // Set catalog to "kdelibs4" for KLocale to initialize languages properly. - KAboutData about( "kdostartupconfig4", "kdelibs4", - I18N_NOEXTRACT( "kdostartupconfig4" ), "1.0" ); - KComponentData inst( &about ); - kDebug() << "Running kdostartupconfig."; - KCmdLineArgs::init( argc, argv, &about ); // for KLocale not to complain about encoding - QString keysname = KStandardDirs::locateLocal( "config", "startupconfigkeys" ); - QFile keys( keysname ); - if( !keys.open( QIODevice::ReadOnly )) - return 3; - QFile f1( KStandardDirs::locateLocal( "config", "startupconfig" )); - if( !f1.open( QIODevice::WriteOnly )) - return 4; - QFile f2( KStandardDirs::locateLocal( "config", "startupconfigfiles" )); - if( !f2.open( QIODevice::WriteOnly )) - return 5; - QTextStream startupconfig( &f1 ); - QTextStream startupconfigfiles( &f2 ); - startupconfig << "#! /bin/sh\n"; - for(;;) { - QString line; - { - QByteArray buf(1024, Qt::Uninitialized); - if( keys.readLine( buf.data(), buf.length() ) < 0 ) - break; - line = QString::fromLocal8Bit(buf); - } - line = line.trimmed(); - if( line.isEmpty()) - break; - QString tmp = line; - QString file, group, key, def; - file = get_entry( &tmp ); - group = get_entry( &tmp ); - key = get_entry( &tmp ); - def = get_entry( &tmp ); - if( file.isEmpty() || group.isEmpty()) - return 6; - if( group.startsWith( '[' ) && group.endsWith( ']' ) ) { // whole config group - KConfig cfg( file ); - group = group.mid( 1, group.length() - 2 ); - KConfigGroup cg(&cfg, group); - QMap< QString, QString > entries = cg.entryMap( ); - startupconfig << "# " << line << "\n"; - for( QMap< QString, QString >::ConstIterator it = entries.constBegin(); - it != entries.constEnd(); ++it ) { - QString key = it.key(); - QString value = *it; - startupconfig << file.replace( ' ', '_' ).toLower() - << "_" << group.replace( ' ', '_' ).toLower() - << "_" << key.replace( ' ', '_' ).toLower() - << "=" << KShell::quoteArg( value ) << "\n"; - } - } else { // a single key - if( key.isEmpty()) - return 7; - KConfig cfg( file ); - KConfigGroup cg(&cfg, group ); - QString value = cg.readEntry( key, def ); - startupconfig << "# " << line << "\n"; - startupconfig << file.replace( ' ', '_' ).toLower() - << "_" << group.replace( ' ', '_' ).toLower() - << "_" << key.replace( ' ', '_' ).toLower() - << "=" << KShell::quoteArg( value ) << "\n"; - } - startupconfigfiles << line << endl; - // use even currently non-existing paths in $KDEDIRS - const QStringList dirs = KGlobal::dirs()->kfsstnd_prefixes().split( KPATH_SEPARATOR, QString::SkipEmptyParts); - foreach(const QString &it, dirs) { - QString cfg = it + "share/config/" + file; - if( KGlobal::dirs()->exists( cfg )) { - startupconfigfiles << cfg << "\n"; - } else { - startupconfigfiles << "!" << cfg << "\n"; - } - startupconfigfiles << "*\n"; - } - } - - // Get languages by priority from KLocale. - const QStringList langs = KGlobal::locale()->languageList(); - startupconfig << "klocale_languages=" << langs.join( ":" ) << "\n"; - return 0; -} diff --git a/kwin/composite.cpp b/kwin/composite.cpp index 74e3eb12..318cd723 100644 --- a/kwin/composite.cpp +++ b/kwin/composite.cpp @@ -1048,14 +1048,7 @@ bool Client::shouldUnredirect() const bool Unmanaged::shouldUnredirect() const { - // the pixmap is needed for the login effect, a nicer solution would be the login effect increasing - // refcount for the window pixmap (which would prevent unredirect), avoiding this hack - if (resourceClass() == "ksplashx" - || resourceClass() == "ksplashsimple" - || resourceClass() == "ksplashqml" - ) - return false; -// it must cover whole display or one xinerama screen, and be the topmost there + // it must cover whole display or one xinerama screen, and be the topmost there const int desktop = VirtualDesktopManager::self()->current(); if (geometry() == workspace()->clientArea(FullArea, geometry().center(), desktop) || geometry() == workspace()->clientArea(ScreenArea, geometry().center(), desktop)) { diff --git a/kwin/main.cpp b/kwin/main.cpp index c83308dd..8cd5548f 100644 --- a/kwin/main.cpp +++ b/kwin/main.cpp @@ -377,15 +377,6 @@ Application::Application() syncX(); // Trigger possible errors, there's still a chance to abort initting = false; // Startup done, we are up and running now. - - XEvent e; - e.xclient.type = ClientMessage; - e.xclient.message_type = XInternAtom(display(), "_KDE_SPLASH_PROGRESS", False); - e.xclient.display = display(); - e.xclient.window = rootWindow(); - e.xclient.format = 8; - strcpy(e.xclient.data.b, "wm"); - XSendEvent(display(), rootWindow(), False, SubstructureNotifyMask, &e); } Application::~Application() diff --git a/startkde.cmake b/startkde.cmake index 71011635..87333e48 100644 --- a/startkde.cmake +++ b/startkde.cmake @@ -59,32 +59,8 @@ export XDG_DATA_DIRS kdehome=$HOME/@KDE_DEFAULT_HOME@ test -n "$KDEHOME" && kdehome=`echo "$KDEHOME"|sed "s,^~/,$HOME/,"` -# see kstartupconfig source for usage -mkdir -m 700 -p $kdehome -mkdir -m 700 -p $kdehome/share -mkdir -m 700 -p $kdehome/share/config -cat >$kdehome/share/config/startupconfigkeys </dev/null 2>/dev/null; then : # ok else echo 'startkde: Could not start D-Bus. Can you call qdbus?' 1>&2 - test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev/null xmessage -geometry 500x100 "Could not start D-Bus. Can you call qdbus?" exit 1 fi @@ -205,7 +153,6 @@ kdeinit4 if test $? -ne 0; then # Startup error echo 'startkde: Could not start kdeinit4. Check your installation.' 1>&2 - test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev/null xmessage -geometry 500x100 "Could not start kdeinit4. Check your installation." exit 1 fi @@ -214,7 +161,6 @@ kcminit_startup if test $? -ne 0; then # Startup error echo 'startkde: Could not start kcminit_startup. Check your installation.' 1>&2 - test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev/null xmessage -geometry 500x100 "Could not start kcminit_startup. Check your installation." exit 1 fi @@ -229,7 +175,6 @@ ksmserver $KDEWM if test $? -ne 0; then # Startup error echo 'startkde: Could not start ksmserver. Check your installation.' 1>&2 - test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev/null xmessage -geometry 500x100 "Could not start ksmserver. Check your installation." fi @@ -253,8 +198,6 @@ if test x"$wait_drkonqi"x = x"true"x ; then fi echo 'startkde: Shutting down...' 1>&2 -# just in case -test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev/null # Clean up kdeinit4 --shutdown