00001 /* 00002 This file is part of the Opie Project 00003 00004 Copyright (C) 2005 Dan Williams <drw@handhelds.org> 00005 Copyright (C) 2003 Patrick S. Vogt <tille@handhelds.org> 00006 =. 00007 .=l. 00008 .>+-= 00009 _;:, .> :=|. This program is free software; you can 00010 .> <`_, > . <= redistribute it and/or modify it under 00011 :`=1 )Y*s>-.-- : the terms of the GNU Library General Public 00012 .="- .-=="i, .._ License as published by the Free Software 00013 - . .-<_> .<> Foundation; either version 2 of the License, 00014 ._= =} : or (at your option) any later version. 00015 .%`+i> _;_. 00016 .i_,=:_. -<s. This program is distributed in the hope that 00017 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 00018 : .. .:, . . . without even the implied warranty of 00019 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 00020 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 00021 ..}^=.= = ; Library General Public License for more 00022 ++= -. .` .: details. 00023 : = ...= . :.=- 00024 -. .:....=;==+<; You should have received a copy of the GNU 00025 -_. . . )=. = Library General Public License along with 00026 -- :-=` this library; see the file COPYING.LIB. 00027 If not, write to the Free Software Foundation, 00028 Inc., 59 Temple Place - Suite 330, 00029 Boston, MA 02111-1307, USA. 00030 */ 00031 00032 #include <opie2/oapplication.h> 00033 #include <opie2/odebug.h> 00034 00035 #include <qpe/applnk.h> 00036 #include <qpe/resource.h> 00037 00038 #include "oresource.h" 00039 00040 namespace Opie { 00041 namespace Core { 00042 00043 static int smallIconSize = -1; // Size of small icons (width & height) 00044 static int bigIconSize = -1; // Size of large icons (width & height) 00045 00046 QImage OResource::loadImage( const QString &name, Scale scale ) 00047 { 00048 // Load image 00049 QImage image = Resource::loadImage( name ); 00050 if ( image.isNull() ) 00051 odebug << "libopie2 OResource: can't find image " << name << oendl; 00052 00053 // Scale image (if necessary) 00054 if ( scale == SmallIcon ) 00055 { 00056 // Retrieve size of small icons 00057 if ( smallIconSize == -1 ) 00058 smallIconSize = AppLnk::smallIconSize(); 00059 00060 // Scale image 00061 return image.smoothScale( smallIconSize, smallIconSize ); 00062 } 00063 else if ( scale == BigIcon ) 00064 { 00065 // Retrieve size of big icons 00066 if ( bigIconSize == -1 ) 00067 bigIconSize = AppLnk::bigIconSize(); 00068 00069 // Scale image 00070 return image.smoothScale( bigIconSize, bigIconSize ); 00071 } 00072 else 00073 return image; 00074 } 00075 00076 QPixmap OResource::loadPixmap( const QString &name, Scale scale ) 00077 { 00078 QPixmap pixmap; 00079 pixmap.convertFromImage( loadImage( name, scale ) ); 00080 return pixmap; 00081 } 00082 00083 QString OResource::findPixmap( const QString &name ) 00084 { 00085 return Resource::findPixmap( name ); 00086 } 00087 00088 } // namespace Core 00089 } // namespace Opie 00090 00091 00092
1.4.2