Updated SDL_image

This commit is contained in:
pelya
2012-02-28 12:31:44 +02:00
parent eadfb0ab82
commit 996291e118
23 changed files with 387 additions and 1525 deletions

View File

@@ -32,13 +32,14 @@ StartupMenuButtonTimeout=3000
HiddenMenuOptions='KeyboardConfigMainMenu ScreenKeyboardThemeConfig ScreenKeyboardTransparencyConfig'
FirstStartMenuOptions=''
MultiABI=n
AppVersionCode=273918
AppVersionName="2739.18"
AppVersionCode=275018
AppVersionName="2750.18"
ResetSdlConfigForThisVersion=n
DeleteFilesOnUpgrade="%"
CompiledLibraries="sdl_net sdl_mixer sdl_image sdl_ttf png intl"
CustomBuildScript=n
AppCflags='-finline-functions -O2 -DWITH_ZLIB -DWITH_MIXER -DWITH_XML -DWITH_IMAGE -DWITH_TTF -DWITH_AI=simple -DWITH_NET'
AppCflags='-finline-functions -O2 -DWITH_ZLIB -DWITH_MIXER -DWITH_XML -DWITH_IMAGE -DWITH_TTF -DWITH_AI=simple -DWITH_NET' # -DWITH_DEBUG
AppLdflags=''
AppSubdirsBuild='fheroes2/src/engine/* fheroes2/src/xmlccwrap/* fheroes2/src/fheroes2/ai fheroes2/src/fheroes2/ai/simple fheroes2/src/fheroes2/agg fheroes2/src/fheroes2/algorithm fheroes2/src/fheroes2/army fheroes2/src/fheroes2/battle2 fheroes2/src/fheroes2/castle fheroes2/src/fheroes2/dialog fheroes2/src/fheroes2/editor fheroes2/src/fheroes2/game fheroes2/src/fheroes2/gui fheroes2/src/fheroes2/heroes fheroes2/src/fheroes2/image fheroes2/src/fheroes2/kingdom fheroes2/src/fheroes2/maps fheroes2/src/fheroes2/monster fheroes2/src/fheroes2/network fheroes2/src/fheroes2/objects fheroes2/src/fheroes2/pocketpc fheroes2/src/fheroes2/resource fheroes2/src/fheroes2/spell fheroes2/src/fheroes2/system fheroes2/src/fheroes2/test'
AppCmdline='fheroes2 -d 500'
AppCmdline='fheroes2'
ReadmeText='^You may press "Home" now - the data will be downloaded in background'

View File

@@ -1,99 +1,46 @@
Index: src/engine/tools.cpp
===================================================================
--- src/engine/tools.cpp (revision 2750)
+++ src/engine/tools.cpp (working copy)
@@ -761,7 +761,7 @@
if(stat(name.c_str(), &fs) || !S_ISREG(fs.st_mode))
return false;
- return writable ? 0 == access(name.c_str(), W_OK) : S_IRUSR & fs.st_mode;
+ return writable ? 0 == access(name.c_str(), W_OK) : true;
}
bool IsDirectory(const std::string & name, bool writable)
Index: src/fheroes2/system/settings.h
===================================================================
--- src/fheroes2/system/settings.h (revision 2699)
--- src/fheroes2/system/settings.h (revision 2750)
+++ src/fheroes2/system/settings.h (working copy)
@@ -115,10 +115,13 @@
#undef DEBUG
#define DEBUG(x, y, z)
@@ -117,9 +117,10 @@
#elif defined(ANDROID)
+// It won't work that way, preprocessor ignores namespaces
+/*
namespace std
{
#define endl "\n"
- #define endl "\n"
+ static const char * android_endl = "\n";
}
+*/
#define VERBOSE(x) { std::ostringstream osss; osss << x; __android_log_print(ANDROID_LOG_INFO, "FHeroes", "%s", osss.str().c_str()); }
- #define VERBOSE(x) { std::ostringstream osss; osss << x; __android_log_print(ANDROID_LOG_INFO, "FHeroes", "%s", osss.str().c_str()); }
+ #define endl android_endl
+ #define VERBOSE(x) if(true) { std::ostringstream osss; osss << x; __android_log_print(ANDROID_LOG_INFO, "FHeroes", "%s", osss.str().c_str()); } else String::GetTime()
#else
#define VERBOSE(x) std::cout << x << std::endl
Index: src/fheroes2/heroes/heroes.cpp
===================================================================
--- src/fheroes2/heroes/heroes.cpp (revision 2699)
+++ src/fheroes2/heroes/heroes.cpp (working copy)
@@ -1612,30 +1612,30 @@
std::ostringstream os;
os <<
- "name : " << name << std::endl <<
- "race : " << Race::String(race) << std::endl <<
- "color : " << Color::String(color) << std::endl <<
- "experience : " << experience << std::endl <<
- "level : " << static_cast<int>(GetLevel()) << std::endl <<
- "magic point : " << GetSpellPoints() << std::endl <<
- "position x : " << GetCenter().x << std::endl <<
- "position y : " << GetCenter().y << std::endl <<
- "move point : " << move_point << std::endl <<
- "max magic point : " << GetMaxSpellPoints() << std::endl <<
- "max move point : " << GetMaxMovePoints() << std::endl <<
- "direction : " << Direction::String(direction) << std::endl <<
- "index sprite : " << static_cast<u16>(sprite_index) << std::endl <<
- "in castle : " << (inCastle() ? "true" : "false") << std::endl <<
- "save object : " << MP2::StringObject(world.GetTiles(GetIndex()).GetObject(false)) << std::endl <<
+ "name : " << name << "\n" <<
+ "race : " << Race::String(race) << "\n" <<
+ "color : " << Color::String(color) << "\n" <<
+ "experience : " << experience << "\n" <<
+ "level : " << static_cast<int>(GetLevel()) << "\n" <<
+ "magic point : " << GetSpellPoints() << "\n" <<
+ "position x : " << GetCenter().x << "\n" <<
+ "position y : " << GetCenter().y << "\n" <<
+ "move point : " << move_point << "\n" <<
+ "max magic point : " << GetMaxSpellPoints() << "\n" <<
+ "max move point : " << GetMaxMovePoints() << "\n" <<
+ "direction : " << Direction::String(direction) << "\n" <<
+ "index sprite : " << static_cast<u16>(sprite_index) << "\n" <<
+ "in castle : " << (inCastle() ? "true" : "false") << "\n" <<
+ "save object : " << MP2::StringObject(world.GetTiles(GetIndex()).GetObject(false)) << "\n" <<
"flags : " << (Modes(SHIPMASTER) ? "SHIPMASTER," : "") <<
(Modes(SCOUTER) ? "SCOUTER," : "") <<
(Modes(HUNTER) ? "HUNTER," : "") <<
(Modes(PATROL) ? "PATROL," : "") <<
(Modes(AIWAITING) ? "WAITING," : "") <<
- (Modes(STUPID) ? "STUPID," : "") << std::endl;
+ (Modes(STUPID) ? "STUPID," : "") << "\n";
if(Modes(PATROL))
{
- os << "patrol square : " << static_cast<u16>(patrol_square) << std::endl;
+ os << "patrol square : " << static_cast<u16>(patrol_square) << "\n";
}
if(! visit_object.empty())
@@ -1644,16 +1644,16 @@
for(std::list<IndexObject>::const_iterator
it = visit_object.begin(); it != visit_object.end(); ++it)
os << MP2::StringObject((*it).second) << "(" << (*it).first << "), ";
- os << std::endl;
+ os << "\n";
}
if(GetControl() & CONTROL_AI)
{
os <<
- "skills : " << secondary_skills.String() << std::endl <<
- "artifacts : " << bag_artifacts.String() << std::endl <<
- "spell book : " << (HaveSpellBook() ? spell_book.String() : "disabled") << std::endl <<
- "army dump : " << army.String() << std::endl;
+ "skills : " << secondary_skills.String() << "\n" <<
+ "artifacts : " << bag_artifacts.String() << "\n" <<
+ "spell book : " << (HaveSpellBook() ? spell_book.String() : "disabled") << "\n" <<
+ "army dump : " << army.String() << "\n";
os << AI::HeroesString(*this);
}
#endif
Index: src/fheroes2/network/server.cpp
===================================================================
--- src/fheroes2/network/server.cpp (revision 2699)
--- src/fheroes2/network/server.cpp (revision 2750)
+++ src/fheroes2/network/server.cpp (working copy)
@@ -876,7 +876,7 @@
int FH2Server::RunServerProcess(void*)
{
- const std::string command = Settings::GetProgramPath();
+ const std::string command = Settings::Get().GetProgramPath();
std::ostringstream os;
os << command << " -s" << ">" << GetDirname(command) << SEPARATOR << "fh2server.log";
return system(os.str().c_str());
@@ -899,7 +899,7 @@
// clear background
@@ -105,7 +52,7 @@ Index: src/fheroes2/network/server.cpp
}
Index: src/fheroes2/network/localclient.cpp
===================================================================
--- src/fheroes2/network/localclient.cpp (revision 2699)
--- src/fheroes2/network/localclient.cpp (revision 2750)
+++ src/fheroes2/network/localclient.cpp (working copy)
@@ -490,7 +490,7 @@
{
@@ -125,188 +72,3 @@ Index: src/fheroes2/network/localclient.cpp
cursor.Show();
display.Flip();
Index: src/fheroes2/ai/simple/ai_heroes.cpp
===================================================================
--- src/fheroes2/ai/simple/ai_heroes.cpp (revision 2699)
+++ src/fheroes2/ai/simple/ai_heroes.cpp (working copy)
@@ -1485,12 +1485,12 @@
AIHero & ai_hero = AIHeroes::Get(hero);
Queue & task = ai_hero.sheduled_visit;
- os << "ai primary target: " << ai_hero.primary_target << std::endl <<
+ os << "ai primary target: " << ai_hero.primary_target << "\n" <<
"ai sheduled visit: ";
for(Queue::const_iterator
it = task.begin(); it != task.end(); ++it)
os << *it << "(" << MP2::StringObject(world.GetTiles(*it).GetObject()) << "), ";
- os << std::endl;
+ os << "\n";
return os.str();
}
Index: src/fheroes2/battle2/battle_arena.cpp
===================================================================
--- src/fheroes2/battle2/battle_arena.cpp (revision 2699)
+++ src/fheroes2/battle2/battle_arena.cpp (working copy)
@@ -1433,7 +1433,7 @@
it = board.begin(); it != board.end(); ++it)
{
const Battle2::Stats* b = GetTroopBoard((*it).index);
- if(b) os << "\t" << b->String(true) << std::endl;
+ if(b) os << "\t" << b->String(true) << "\n";
}
return os.str();
Index: src/fheroes2/maps/maps_tiles.cpp
===================================================================
--- src/fheroes2/maps/maps_tiles.cpp (revision 2699)
+++ src/fheroes2/maps/maps_tiles.cpp (working copy)
@@ -65,13 +65,13 @@
std::string Maps::TilesAddon::String(int level) const
{
std::ostringstream os;
- os << "----------------" << level << "--------" << std::endl <<
+ os << "----------------" << level << "--------" << "\n" <<
"object : " << "0x" << std::setw(2) << std::setfill('0') << static_cast<int>(object) <<
- ", (" << ICN::GetString(MP2::GetICNObject(object)) << ")" << std::endl <<
- "index : " << static_cast<int>(index) << std::endl <<
- "uniq : " << uniq << std::endl <<
- "level : " << static_cast<int>(level) << std::endl <<
- "tmp : " << static_cast<int>(tmp) << std::endl;
+ ", (" << ICN::GetString(MP2::GetICNObject(object)) << ")" << "\n" <<
+ "index : " << static_cast<int>(index) << "\n" <<
+ "uniq : " << uniq << "\n" <<
+ "level : " << static_cast<int>(level) << "\n" <<
+ "tmp : " << static_cast<int>(tmp) << "\n";
return os.str();
}
@@ -1541,16 +1541,16 @@
std::ostringstream os;
os <<
- "----------------:--------" << std::endl <<
- "maps index : " << GetIndex() << std::endl <<
- "tile index : " << TileSpriteIndex() << std::endl <<
- "ground : " << Ground::String(GetGround()) << (isRoad() ? ", (road)" : "") << std::endl <<
- "passable : " << (tile_passable ? Direction::String(tile_passable) : "false") << std::endl <<
+ "----------------:--------" << "\n" <<
+ "maps index : " << GetIndex() << "\n" <<
+ "tile index : " << TileSpriteIndex() << "\n" <<
+ "ground : " << Ground::String(GetGround()) << (isRoad() ? ", (road)" : "") << "\n" <<
+ "passable : " << (tile_passable ? Direction::String(tile_passable) : "false") << "\n" <<
"mp2 object : " << "0x" << std::setw(2) << std::setfill('0') << static_cast<int>(GetObject()) <<
- ", (" << MP2::StringObject(GetObject()) << ")" << std::endl <<
- "quantity 1 : " << static_cast<int>(quantity1) << std::endl <<
- "quantity 2 : " << static_cast<int>(quantity2) << std::endl <<
- "quantity 3 : " << static_cast<int>(GetQuantity3()) << std::endl;
+ ", (" << MP2::StringObject(GetObject()) << ")" << "\n" <<
+ "quantity 1 : " << static_cast<int>(quantity1) << "\n" <<
+ "quantity 2 : " << static_cast<int>(quantity2) << "\n" <<
+ "quantity 3 : " << static_cast<int>(GetQuantity3()) << "\n";
for(Addons::const_iterator
it = addons_level1.begin(); it != addons_level1.end(); ++it)
@@ -1561,7 +1561,7 @@
os << (*it).String(2);
os <<
- "----------------I--------" << std::endl;
+ "----------------I--------" << "\n";
// extra obj info
switch(GetObject())
@@ -1587,7 +1587,7 @@
case MP2::OBJ_THATCHEDHUT:
//
case MP2::OBJ_MONSTER:
- os << "count : " << MonsterCount() << std::endl;
+ os << "count : " << MonsterCount() << "\n";
break;
case MP2::OBJ_HEROES:
@@ -1614,7 +1614,7 @@
for(MapsIndexes::const_iterator
it = v.begin(); it != v.end(); ++it)
os << *it << ", ";
- os << std::endl;
+ os << "\n";
}
break;
}
@@ -1625,16 +1625,16 @@
const CapturedObject & co = world.GetCapturedObject(GetIndex());
os <<
- "capture color : " << Color::String(co.objcol.second) << std::endl;
+ "capture color : " << Color::String(co.objcol.second) << "\n";
if(co.guardians.isValid())
{
os <<
- "capture guard : " << co.guardians.GetName() << std::endl <<
- "capture caunt : " << co.guardians.GetCount() << std::endl;
+ "capture guard : " << co.guardians.GetName() << "\n" <<
+ "capture caunt : " << co.guardians.GetCount() << "\n";
}
}
- os << "----------------:--------" << std::endl;
+ os << "----------------:--------" << "\n";
return os.str();
}
Index: src/fheroes2/game/game_io.cpp
===================================================================
--- src/fheroes2/game/game_io.cpp (revision 2699)
+++ src/fheroes2/game/game_io.cpp (working copy)
@@ -703,8 +703,8 @@
if(format > CURRENT_FORMAT_VERSION || format < LAST_FORMAT_VERSION)
{
std::ostringstream os;
- os << "usupported save format: " << format << std::endl <<
- "game version: " << CURRENT_FORMAT_VERSION << std::endl <<
+ os << "usupported save format: " << format << "\n" <<
+ "game version: " << CURRENT_FORMAT_VERSION << "\n" <<
"last version: " << LAST_FORMAT_VERSION;
Dialog::Message("Error", os.str(), Font::BIG, Dialog::OK);
return false;
Index: src/fheroes2/castle/castle.cpp
===================================================================
--- src/fheroes2/castle/castle.cpp (revision 2699)
+++ src/fheroes2/castle/castle.cpp (working copy)
@@ -1691,25 +1691,25 @@
const CastleHeroes heroes = GetHeroes();
const Heroes* hero = NULL;
- os << "name : " << name << std::endl <<
- "race : " << Race::String(race) << std::endl <<
- "color : " << Color::String(color) << std::endl <<
- "build : " << "0x" << std::hex << building << std::dec << std::endl <<
- "present boat : " << (PresentBoat() ? "yes" : "no") << std::endl <<
- "nearly sea : " << (HaveNearlySea() ? "yes" : "no") << std::endl <<
- "is castle : " << (isCastle() ? "yes" : "no") << std::endl <<
- "army : " << army.String() << std::endl;
+ os << "name : " << name << "\n" <<
+ "race : " << Race::String(race) << "\n" <<
+ "color : " << Color::String(color) << "\n" <<
+ "build : " << "0x" << std::hex << building << std::dec << "\n" <<
+ "present boat : " << (PresentBoat() ? "yes" : "no") << "\n" <<
+ "nearly sea : " << (HaveNearlySea() ? "yes" : "no") << "\n" <<
+ "is castle : " << (isCastle() ? "yes" : "no") << "\n" <<
+ "army : " << army.String() << "\n";
if(NULL != (hero = heroes.Guard()))
{
os <<
- "army guard : " << hero->GetArmy().String() << std::endl;
+ "army guard : " << hero->GetArmy().String() << "\n";
}
if(NULL != (hero = heroes.Guest()))
{
os <<
- "army guest : " << hero->GetArmy().String() << std::endl;
+ "army guest : " << hero->GetArmy().String() << "\n";
}
return os.str();

View File

@@ -1 +1 @@
ufoai
fheroes2

View File

@@ -1,3 +1,23 @@
1.2.12:
Sam Lantinga - Thu Jan 19 23:18:09 EST 2012
* Fixed regression in 1.2.11 loading 8-bit PNG images with libpng
1.2.11:
Sam Lantinga - Sat Jan 14 17:54:38 EST 2012
* Fixed loading 8-bit PNG images on Mac OS X
Sam Lantinga - Sat Dec 31 09:35:40 EST 2011
* SDL_image is now under the zlib license
Michael Bonfils - Mon Nov 28 21:46:00 EST 2011
* Added WEBP image support
Thomas Klausner - Wed Jan 19 19:31:25 PST 2011
* Fixed compiling with libpng 1.4
Sam Lantinga - Mon Jan 10 12:09:57 2011 -0800
* Added Android.mk to build on the Android platform
Sam Lantinga - Mon May 10 22:42:53 PDT 2010
* Fixed loading HAM6 images with stencil mask
Mark Tucker - Fri, 27 Nov 2009 12:38:21 -0500
* Fixed bug loading 15 and 16 bit BMP images
1.2.10:
Sam Lantinga - Sat Nov 14 11:22:14 PST 2009
* Fixed bug loading multiple images

View File

@@ -1,458 +1,20 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
/*
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/

View File

@@ -1,23 +1,22 @@
/*
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2009 Sam Lantinga
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
This library 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
Lesser General Public License for more details.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/* A simple library to load images of various formats as SDL surfaces */
@@ -50,7 +49,8 @@ static struct {
{ "TIF", IMG_isTIF, IMG_LoadTIF_RW },
{ "XCF", IMG_isXCF, IMG_LoadXCF_RW },
{ "XPM", IMG_isXPM, IMG_LoadXPM_RW },
{ "XV", IMG_isXV, IMG_LoadXV_RW }
{ "XV", IMG_isXV, IMG_LoadXV_RW },
{ "WEBP", IMG_isWEBP, IMG_LoadWEBP_RW },
};
const SDL_version *IMG_Linked_Version(void)
@@ -67,6 +67,9 @@ extern void IMG_QuitPNG();
extern int IMG_InitTIF();
extern void IMG_QuitTIF();
extern int IMG_InitWEBP();
extern void IMG_QuitWEBP();
static int initialized = 0;
int IMG_Init(int flags)
@@ -88,6 +91,11 @@ int IMG_Init(int flags)
result |= IMG_INIT_TIF;
}
}
if (flags & IMG_INIT_WEBP) {
if ((initialized & IMG_INIT_WEBP) || IMG_InitWEBP() == 0) {
result |= IMG_INIT_WEBP;
}
}
initialized |= result;
return (initialized);
@@ -104,6 +112,9 @@ void IMG_Quit()
if (initialized & IMG_INIT_TIF) {
IMG_QuitTIF();
}
if (initialized & IMG_INIT_WEBP) {
IMG_QuitWEBP();
}
initialized = 0;
}
@@ -144,7 +155,7 @@ static int IMG_string_equals(const char *str1, const char *str2)
}
/* Load an image from an SDL datasource, optionally specifying the type */
SDL_Surface *IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, char *type)
SDL_Surface *IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, const char *type)
{
int i;
SDL_Surface *image;
@@ -192,6 +203,41 @@ SDL_Surface *IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, char *type)
return NULL;
}
#if (SDL_VERSION_ATLEAST(1,3,0))
SDL_Texture *IMG_LoadTexture(SDL_Renderer *renderer, const char *file)
{
SDL_Texture *texture = NULL;
SDL_Surface *surface = IMG_Load(file);
if (surface) {
texture = SDL_CreateTextureFromSurface(renderer, surface);
SDL_FreeSurface(surface);
}
return texture;
}
SDL_Texture *IMG_LoadTexture_RW(SDL_Renderer *renderer, SDL_RWops *src, int freesrc)
{
SDL_Texture *texture = NULL;
SDL_Surface *surface = IMG_Load_RW(src, freesrc);
if (surface) {
texture = SDL_CreateTextureFromSurface(renderer, surface);
SDL_FreeSurface(surface);
}
return texture;
}
SDL_Texture *IMG_LoadTextureTyped_RW(SDL_Renderer *renderer, SDL_RWops *src, int freesrc, const char *type)
{
SDL_Texture *texture = NULL;
SDL_Surface *surface = IMG_LoadTyped_RW(src, freesrc, type);
if (surface) {
texture = SDL_CreateTextureFromSurface(renderer, surface);
SDL_FreeSurface(surface);
}
return texture;
}
#endif
/* Invert the alpha of a surface for use with OpenGL
This function is a no-op and only kept for backwards compatibility.
*/

View File

@@ -1,523 +0,0 @@
/*
* IMG_ImageIO.c
* SDL_image
*
* Created by Eric Wing on 1/1/09.
* Copyright 2009 __MyCompanyName__. All rights reserved.
*
*/
#if defined(__APPLE__) && !defined(SDL_IMAGE_USE_COMMON_BACKEND)
#include "SDL_image.h"
// Used because CGDataProviderCreate became deprecated in 10.5
#include <AvailabilityMacros.h>
#include <TargetConditionals.h>
#if (TARGET_OS_IPHONE == 1) || (TARGET_IPHONE_SIMULATOR == 1)
#import <MobileCoreServices/MobileCoreServices.h> // for UTCoreTypes.h
#import <ImageIO/ImageIO.h>
#else
// For ImageIO framework and also LaunchServices framework (for UTIs)
#include <ApplicationServices/ApplicationServices.h>
#endif
/**************************************************************
***** Begin Callback functions for block reading *************
**************************************************************/
// This callback reads some bytes from an SDL_rwops and copies it
// to a Quartz buffer (supplied by Apple framework).
static size_t MyProviderGetBytesCallback(void* rwops_userdata, void* quartz_buffer, size_t the_count)
{
return (size_t)SDL_RWread((struct SDL_RWops *)rwops_userdata, quartz_buffer, 1, the_count);
}
// This callback is triggered when the data provider is released
// so you can clean up any resources.
static void MyProviderReleaseInfoCallback(void* rwops_userdata)
{
// What should I put here?
// I think the user and SDL_RWops controls closing, so I don't do anything.
}
static void MyProviderRewindCallback(void* rwops_userdata)
{
SDL_RWseek((struct SDL_RWops *)rwops_userdata, 0, RW_SEEK_SET);
}
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 // CGDataProviderCreateSequential was introduced in 10.5; CGDataProviderCreate is deprecated
off_t MyProviderSkipForwardBytesCallback(void* rwops_userdata, off_t the_count)
{
off_t start_position = SDL_RWtell((struct SDL_RWops *)rwops_userdata);
SDL_RWseek((struct SDL_RWops *)rwops_userdata, the_count, RW_SEEK_CUR);
off_t end_position = SDL_RWtell((struct SDL_RWops *)rwops_userdata);
return (end_position - start_position);
}
#else // CGDataProviderCreate was deprecated in 10.5
static void MyProviderSkipBytesCallback(void* rwops_userdata, size_t the_count)
{
SDL_RWseek((struct SDL_RWops *)rwops_userdata, the_count, RW_SEEK_CUR);
}
#endif
/**************************************************************
***** End Callback functions for block reading ***************
**************************************************************/
// This creates a CGImageSourceRef which is a handle to an image that can be used to examine information
// about the image or load the actual image data.
static CGImageSourceRef CreateCGImageSourceFromRWops(SDL_RWops* rw_ops, CFDictionaryRef hints_and_options)
{
CGImageSourceRef source_ref;
// Similar to SDL_RWops, Apple has their own callbacks for dealing with data streams.
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 // CGDataProviderCreateSequential was introduced in 10.5; CGDataProviderCreate is deprecated
CGDataProviderSequentialCallbacks provider_callbacks =
{
0,
MyProviderGetBytesCallback,
MyProviderSkipForwardBytesCallback,
MyProviderRewindCallback,
MyProviderReleaseInfoCallback
};
CGDataProviderRef data_provider = CGDataProviderCreateSequential(rw_ops, &provider_callbacks);
#else // CGDataProviderCreate was deprecated in 10.5
CGDataProviderCallbacks provider_callbacks =
{
MyProviderGetBytesCallback,
MyProviderSkipBytesCallback,
MyProviderRewindCallback,
MyProviderReleaseInfoCallback
};
CGDataProviderRef data_provider = CGDataProviderCreate(rw_ops, &provider_callbacks);
#endif
// Get the CGImageSourceRef.
// The dictionary can be NULL or contain hints to help ImageIO figure out the image type.
source_ref = CGImageSourceCreateWithDataProvider(data_provider, hints_and_options);
return source_ref;
}
/* Create a CGImageSourceRef from a file. */
/* Remember to CFRelease the created source when done. */
static CGImageSourceRef CreateCGImageSourceFromFile(const char* the_path)
{
CFURLRef the_url = NULL;
CGImageSourceRef source_ref = NULL;
CFStringRef cf_string = NULL;
/* Create a CFString from a C string */
cf_string = CFStringCreateWithCString(
NULL,
the_path,
kCFStringEncodingUTF8
);
if(!cf_string)
{
return NULL;
}
/* Create a CFURL from a CFString */
the_url = CFURLCreateWithFileSystemPath(
NULL,
cf_string,
kCFURLPOSIXPathStyle,
false
);
/* Don't need the CFString any more (error or not) */
CFRelease(cf_string);
if(!the_url)
{
return NULL;
}
source_ref = CGImageSourceCreateWithURL(the_url, NULL);
/* Don't need the URL any more (error or not) */
CFRelease(the_url);
return source_ref;
}
static CGImageRef CreateCGImageFromCGImageSource(CGImageSourceRef image_source)
{
CGImageRef image_ref = NULL;
if(NULL == image_source)
{
return NULL;
}
// Get the first item in the image source (some image formats may
// contain multiple items).
image_ref = CGImageSourceCreateImageAtIndex(image_source, 0, NULL);
if(NULL == image_ref)
{
IMG_SetError("CGImageSourceCreateImageAtIndex() failed");
}
return image_ref;
}
static CFDictionaryRef CreateHintDictionary(CFStringRef uti_string_hint)
{
CFDictionaryRef hint_dictionary = NULL;
if(uti_string_hint != NULL)
{
// Do a bunch of work to setup a CFDictionary containing the jpeg compression properties.
CFStringRef the_keys[1];
CFStringRef the_values[1];
the_keys[0] = kCGImageSourceTypeIdentifierHint;
the_values[0] = uti_string_hint;
// kCFTypeDictionaryKeyCallBacks or kCFCopyStringDictionaryKeyCallBacks?
hint_dictionary = CFDictionaryCreate(NULL, (const void**)&the_keys, (const void**)&the_values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
}
return hint_dictionary;
}
static int Internal_isType(SDL_RWops* rw_ops, CFStringRef uti_string_to_test)
{
CGImageSourceRef image_source;
CFStringRef uti_type;
Boolean is_type;
CFDictionaryRef hint_dictionary = NULL;
hint_dictionary = CreateHintDictionary(uti_string_to_test);
image_source = CreateCGImageSourceFromRWops(rw_ops, hint_dictionary);
if(hint_dictionary != NULL)
{
CFRelease(hint_dictionary);
}
if(NULL == image_source)
{
return 0;
}
// This will get the UTI of the container, not the image itself.
// Under most cases, this won't be a problem.
// But if a person passes an icon file which contains a bmp,
// the format will be of the icon file.
// But I think the main SDL_image codebase has this same problem so I'm not going to worry about it.
uti_type = CGImageSourceGetType(image_source);
// CFShow(uti_type);
// Unsure if we really want conformance or equality
is_type = UTTypeConformsTo(uti_string_to_test, uti_type);
CFRelease(image_source);
return (int)is_type;
}
// Once we have our image, we need to get it into an SDL_Surface
static SDL_Surface* Create_SDL_Surface_From_CGImage(CGImageRef image_ref)
{
/* This code is adapted from Apple's Documentation found here:
* http://developer.apple.com/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/index.html
* Listing 9-4††Using a Quartz image as a texture source.
* Unfortunately, this guide doesn't show what to do about
* non-RGBA image formats so I'm making the rest up.
* All this code should be scrutinized.
*/
size_t w = CGImageGetWidth(image_ref);
size_t h = CGImageGetHeight(image_ref);
CGRect rect = {{0, 0}, {w, h}};
CGImageAlphaInfo alpha = CGImageGetAlphaInfo(image_ref);
//size_t bits_per_pixel = CGImageGetBitsPerPixel(image_ref);
size_t bits_per_component = 8;
SDL_Surface* surface;
Uint32 Amask;
Uint32 Rmask;
Uint32 Gmask;
Uint32 Bmask;
CGContextRef bitmap_context;
CGBitmapInfo bitmap_info;
CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB();
if (alpha == kCGImageAlphaNone ||
alpha == kCGImageAlphaNoneSkipFirst ||
alpha == kCGImageAlphaNoneSkipLast) {
bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host; /* XRGB */
Amask = 0x00000000;
} else {
/* kCGImageAlphaFirst isn't supported */
//bitmap_info = kCGImageAlphaFirst | kCGBitmapByteOrder32Host; /* ARGB */
bitmap_info = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host; /* ARGB */
Amask = 0xFF000000;
}
Rmask = 0x00FF0000;
Gmask = 0x0000FF00;
Bmask = 0x000000FF;
surface = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, Rmask, Gmask, Bmask, Amask);
if (surface)
{
// Sets up a context to be drawn to with surface->pixels as the area to be drawn to
bitmap_context = CGBitmapContextCreate(
surface->pixels,
surface->w,
surface->h,
bits_per_component,
surface->pitch,
color_space,
bitmap_info
);
// Draws the image into the context's image_data
CGContextDrawImage(bitmap_context, rect, image_ref);
CGContextRelease(bitmap_context);
// FIXME: Reverse the premultiplied alpha
if ((bitmap_info & kCGBitmapAlphaInfoMask) == kCGImageAlphaPremultipliedFirst) {
int i, j;
Uint8 *p = (Uint8 *)surface->pixels;
for (i = surface->h * surface->pitch/4; i--; ) {
#if __LITTLE_ENDIAN__
Uint8 A = p[3];
if (A) {
for (j = 0; j < 3; ++j) {
p[j] = (p[j] * 255) / A;
}
}
#else
Uint8 A = p[0];
if (A) {
for (j = 1; j < 4; ++j) {
p[j] = (p[j] * 255) / A;
}
}
#endif /* ENDIAN */
p += 4;
}
}
}
if (color_space)
{
CGColorSpaceRelease(color_space);
}
return surface;
}
static SDL_Surface* LoadImageFromRWops(SDL_RWops* rw_ops, CFStringRef uti_string_hint)
{
SDL_Surface* sdl_surface;
CGImageSourceRef image_source;
CGImageRef image_ref = NULL;
CFDictionaryRef hint_dictionary = NULL;
hint_dictionary = CreateHintDictionary(uti_string_hint);
image_source = CreateCGImageSourceFromRWops(rw_ops, hint_dictionary);
if(hint_dictionary != NULL)
{
CFRelease(hint_dictionary);
}
if(NULL == image_source)
{
return NULL;
}
image_ref = CreateCGImageFromCGImageSource(image_source);
CFRelease(image_source);
if(NULL == image_ref)
{
return NULL;
}
sdl_surface = Create_SDL_Surface_From_CGImage(image_ref);
CFRelease(image_ref);
return sdl_surface;
}
static SDL_Surface* LoadImageFromFile(const char* file)
{
SDL_Surface* sdl_surface = NULL;
CGImageSourceRef image_source = NULL;
CGImageRef image_ref = NULL;
// First ImageIO
image_source = CreateCGImageSourceFromFile(file);
if(NULL == image_source)
{
return NULL;
}
image_ref = CreateCGImageFromCGImageSource(image_source);
CFRelease(image_source);
if(NULL == image_ref)
{
return NULL;
}
sdl_surface = Create_SDL_Surface_From_CGImage(image_ref);
CFRelease(image_ref);
return sdl_surface;
}
int IMG_InitJPG()
{
return 0;
}
void IMG_QuitJPG()
{
}
int IMG_InitPNG()
{
return 0;
}
void IMG_QuitPNG()
{
}
int IMG_InitTIF()
{
return 0;
}
void IMG_QuitTIF()
{
}
int IMG_isCUR(SDL_RWops *src)
{
/* FIXME: Is this a supported type? */
return Internal_isType(src, CFSTR("com.microsoft.cur"));
}
int IMG_isICO(SDL_RWops *src)
{
return Internal_isType(src, kUTTypeICO);
}
int IMG_isBMP(SDL_RWops *src)
{
return Internal_isType(src, kUTTypeBMP);
}
int IMG_isGIF(SDL_RWops *src)
{
return Internal_isType(src, kUTTypeGIF);
}
// Note: JPEG 2000 is kUTTypeJPEG2000
int IMG_isJPG(SDL_RWops *src)
{
return Internal_isType(src, kUTTypeJPEG);
}
int IMG_isPNG(SDL_RWops *src)
{
return Internal_isType(src, kUTTypePNG);
}
// This isn't a public API function. Apple seems to be able to identify tga's.
int IMG_isTGA(SDL_RWops *src)
{
return Internal_isType(src, CFSTR("com.truevision.tga-image"));
}
int IMG_isTIF(SDL_RWops *src)
{
return Internal_isType(src, kUTTypeTIFF);
}
SDL_Surface* IMG_LoadCUR_RW(SDL_RWops *src)
{
/* FIXME: Is this a supported type? */
return LoadImageFromRWops(src, CFSTR("com.microsoft.cur"));
}
SDL_Surface* IMG_LoadICO_RW(SDL_RWops *src)
{
return LoadImageFromRWops(src, kUTTypeICO);
}
SDL_Surface* IMG_LoadBMP_RW(SDL_RWops *src)
{
return LoadImageFromRWops(src, kUTTypeBMP);
}
SDL_Surface* IMG_LoadGIF_RW(SDL_RWops *src)
{
return LoadImageFromRWops(src, kUTTypeGIF);
}
SDL_Surface* IMG_LoadJPG_RW(SDL_RWops *src)
{
return LoadImageFromRWops(src, kUTTypeJPEG);
}
SDL_Surface* IMG_LoadPNG_RW(SDL_RWops *src)
{
return LoadImageFromRWops(src, kUTTypePNG);
}
SDL_Surface* IMG_LoadTGA_RW(SDL_RWops *src)
{
return LoadImageFromRWops(src, CFSTR("com.truevision.tga-image"));
}
SDL_Surface* IMG_LoadTIF_RW(SDL_RWops *src)
{
return LoadImageFromRWops(src, kUTTypeTIFF);
}
// Apple provides both stream and file loading functions in ImageIO.
// Potentially, Apple can optimize for either case.
SDL_Surface* IMG_Load(const char *file)
{
SDL_Surface* sdl_surface = NULL;
sdl_surface = LoadImageFromFile(file);
if(NULL == sdl_surface)
{
// Either the file doesn't exist or ImageIO doesn't understand the format.
// For the latter case, fallback to the native SDL_image handlers.
SDL_RWops *src = SDL_RWFromFile(file, "rb");
char *ext = strrchr(file, '.');
if(ext) {
ext++;
}
if(!src) {
/* The error message has been set in SDL_RWFromFile */
return NULL;
}
sdl_surface = IMG_LoadTyped_RW(src, 1, ext);
}
return sdl_surface;
}
#endif /* defined(__APPLE__) && !defined(SDL_IMAGE_USE_COMMON_BACKEND) */

View File

@@ -1,23 +1,22 @@
/*
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2009 Sam Lantinga
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
This library 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
Lesser General Public License for more details.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#if !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND)

View File

@@ -1,23 +1,22 @@
/*
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2009 Sam Lantinga
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
This library 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
Lesser General Public License for more details.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#if !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND)
@@ -82,7 +81,7 @@ int IMG_isGIF(SDL_RWops *src)
#define Image SDL_Surface
#define RWSetMsg IMG_SetError
#define ImageNewCmap(w, h, s) SDL_AllocSurface(SDL_SWSURFACE,w,h,8,0,0,0,0)
#define ImageNewCmap(w, h, s) SDL_CreateRGBSurface(SDL_SWSURFACE,w,h,8,0,0,0,0)
#define ImageSetCmap(s, i, R, G, B) do { \
s->format->palette->colors[i].r = R; \
s->format->palette->colors[i].g = G; \
@@ -178,7 +177,7 @@ IMG_LoadGIF_RW(SDL_RWops *src)
RWSetMsg("not a GIF file");
goto done;
}
strncpy(version, (char *) buf + 3, 3);
memcpy(version, (char *) buf + 3, 3);
version[3] = '\0';
if ((strcmp(version, "87a") != 0) && (strcmp(version, "89a") != 0)) {
@@ -262,7 +261,7 @@ IMG_LoadGIF_RW(SDL_RWops *src)
#ifdef USED_BY_SDL
if ( Gif89.transparent >= 0 ) {
SDL_SetColorKey(image, SDL_SRCCOLORKEY, Gif89.transparent);
SDL_SetColorKey(image, SDL_TRUE, Gif89.transparent);
}
#endif

View File

@@ -1,23 +1,22 @@
/*
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2009 Sam Lantinga
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
This library 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
Lesser General Public License for more details.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#if !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND)
@@ -34,7 +33,7 @@
#include <jpeglib.h>
#if JPEG_LIB_VERSION >= 80
#ifdef JPEG_TRUE /* MinGW version of jpeg-8.x renamed TRUE to JPEG_TRUE etc. */
typedef JPEG_boolean boolean;
#define TRUE JPEG_TRUE
#define FALSE JPEG_FALSE
@@ -261,7 +260,7 @@ static void init_source (j_decompress_ptr cinfo)
/*
* Fill the input buffer --- called whenever buffer is emptied.
*/
static int fill_input_buffer (j_decompress_ptr cinfo)
static boolean fill_input_buffer (j_decompress_ptr cinfo)
{
my_source_mgr * src = (my_source_mgr *) cinfo->src;
int nbytes;
@@ -417,7 +416,7 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src)
lib.jpeg_calc_output_dimensions(&cinfo);
/* Allocate an output surface to hold the image */
surface = SDL_AllocSurface(SDL_SWSURFACE,
surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
cinfo.output_width, cinfo.output_height, 32,
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
@@ -437,7 +436,7 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src)
lib.jpeg_calc_output_dimensions(&cinfo);
/* Allocate an output surface to hold the image */
surface = SDL_AllocSurface(SDL_SWSURFACE,
surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
cinfo.output_width, cinfo.output_height, 24,
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
0x0000FF, 0x00FF00, 0xFF0000,

View File

@@ -1,23 +1,22 @@
/*
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2009 Sam Lantinga
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
This library 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
Lesser General Public License for more details.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/* This is a ILBM image file loading framework
@@ -254,7 +253,7 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src )
goto done;
if ( bmhd.mask & 2 ) /* There is a transparent color */
SDL_SetColorKey( Image, SDL_SRCCOLORKEY, bmhd.tcolor );
SDL_SetColorKey( Image, SDL_TRUE, bmhd.tcolor );
/* Update palette informations */

View File

@@ -1,23 +1,22 @@
/*
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2009 Sam Lantinga
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
This library 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
Lesser General Public License for more details.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/*
@@ -141,7 +140,7 @@ SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src)
error = "unsupported PCX format";
goto done;
}
surface = SDL_AllocSurface(SDL_SWSURFACE, width, height,
surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
bits, Rmask, Gmask, Bmask, Amask);
if ( surface == NULL )
goto done;

View File

@@ -1,23 +1,22 @@
/*
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2009 Sam Lantinga
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
This library 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
Lesser General Public License for more details.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#if !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND)
@@ -454,9 +453,6 @@ SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src)
/* Allocate the SDL surface to hold the image */
Rmask = Gmask = Bmask = Amask = 0 ;
num_channels = lib.png_get_channels(png_ptr, info_ptr);
/* Some .png files are monochrome, with as much as 1 channel and 1 bit per pixel */
if( num_channels != 3 && num_channels != 4 )
num_channels = 3;
if ( color_type != PNG_COLOR_TYPE_PALETTE ) {
if ( SDL_BYTEORDER == SDL_LIL_ENDIAN ) {
Rmask = 0x000000FF;
@@ -471,7 +467,7 @@ SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src)
Amask = 0x000000FF >> s;
}
}
surface = SDL_AllocSurface(SDL_SWSURFACE, width, height,
surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
bit_depth*num_channels, Rmask,Gmask,Bmask,Amask);
if ( surface == NULL ) {
error = "Out of memory";
@@ -485,7 +481,7 @@ SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src)
(Uint8)transv->red,
(Uint8)transv->green,
(Uint8)transv->blue);
SDL_SetColorKey(surface, SDL_SRCCOLORKEY, ckey);
SDL_SetColorKey(surface, SDL_TRUE, ckey);
}
/* Create the array of pointers to image data */

View File

@@ -1,23 +1,22 @@
/*
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2009 Sam Lantinga
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
This library 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
Lesser General Public License for more details.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/*
@@ -150,7 +149,7 @@ SDL_Surface *IMG_LoadPNM_RW(SDL_RWops *src)
if(kind == PPM) {
/* 24-bit surface in R,G,B byte order */
surface = SDL_AllocSurface(SDL_SWSURFACE, width, height, 24,
surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 24,
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
0x000000ff, 0x0000ff00, 0x00ff0000,
#else
@@ -159,7 +158,7 @@ SDL_Surface *IMG_LoadPNM_RW(SDL_RWops *src)
0);
} else {
/* load PBM/PGM as 8-bit indexed images */
surface = SDL_AllocSurface(SDL_SWSURFACE, width, height, 8,
surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 8,
0, 0, 0, 0);
}
if ( surface == NULL )

View File

@@ -1,23 +1,22 @@
/*
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2009 Sam Lantinga
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
This library 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
Lesser General Public License for more details.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#if !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND)
@@ -236,7 +235,7 @@ SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src)
}
free(pal);
if(ckey >= 0)
SDL_SetColorKey(img, SDL_SRCCOLORKEY, ckey);
SDL_SetColorKey(img, SDL_TRUE, ckey);
} else {
/* skip unneeded colormap */
SDL_RWseek(src, palsiz, RW_SEEK_CUR);

View File

@@ -1,23 +1,22 @@
/*
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2009 Sam Lantinga
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
This library 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
Lesser General Public License for more details.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#if !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND)
@@ -236,7 +235,7 @@ SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src)
Gmask = 0x0000FF00;
Bmask = 0x00FF0000;
Amask = 0xFF000000;
surface = SDL_AllocSurface(SDL_SWSURFACE, img_width, img_height, 32,
surface = SDL_CreateRGBSurface(SDL_SWSURFACE, img_width, img_height, 32,
Rmask, Gmask, Bmask, Amask);
if(!surface)
goto error;

View File

@@ -1,23 +1,22 @@
/*
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2009 Sam Lantinga
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
This library 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
Lesser General Public License for more details.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/* This is a XCF image file loading framework */
@@ -710,7 +709,7 @@ SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src)
}
/* Create the surface of the appropriate type */
surface = SDL_AllocSurface(SDL_SWSURFACE, head->width, head->height, 32,
surface = SDL_CreateRGBSurface(SDL_SWSURFACE, head->width, head->height, 32,
0x00FF0000,0x0000FF00,0x000000FF,0xFF000000);
if ( surface == NULL ) {
@@ -728,7 +727,7 @@ SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src)
}
fp = SDL_RWtell (src);
lays = SDL_AllocSurface(SDL_SWSURFACE, head->width, head->height, 32,
lays = SDL_CreateRGBSurface(SDL_SWSURFACE, head->width, head->height, 32,
0x00FF0000,0x0000FF00,0x000000FF,0xFF000000);
if ( lays == NULL ) {
@@ -775,7 +774,7 @@ SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src)
if (chnls) {
SDL_Surface * chs;
chs = SDL_AllocSurface(SDL_SWSURFACE, head->width, head->height, 32,
chs = SDL_CreateRGBSurface(SDL_SWSURFACE, head->width, head->height, 32,
0x00FF0000,0x0000FF00,0x000000FF,0xFF000000);
if (chs == NULL) {

View File

@@ -1,23 +1,22 @@
/*
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2009 Sam Lantinga
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
This library 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
Lesser General Public License for more details.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/*
@@ -246,6 +245,8 @@ static char *error;
*/
static char *get_next_line(char ***lines, SDL_RWops *src, int len)
{
char *linebufnew;
if(lines) {
return *(*lines)++;
} else {
@@ -261,7 +262,7 @@ static char *get_next_line(char ***lines, SDL_RWops *src, int len)
len += 4; /* "\",\n\0" */
if(len > buflen){
buflen = len;
char *linebufnew = realloc(linebuf, buflen);
linebufnew = realloc(linebuf, buflen);
if(!linebufnew) {
free(linebuf);
error = "Out of memory";
@@ -281,7 +282,7 @@ static char *get_next_line(char ***lines, SDL_RWops *src, int len)
if(buflen == 0)
buflen = 16;
buflen *= 2;
char *linebufnew = realloc(linebuf, buflen);
linebufnew = realloc(linebuf, buflen);
if(!linebufnew) {
free(linebuf);
error = "Out of memory";
@@ -430,7 +431,7 @@ static SDL_Surface *load_xpm(char **xpm, SDL_RWops *src)
add_colorhash(colors, nextkey, cpp, pixel);
nextkey += cpp;
if(rgb == 0xffffffff)
SDL_SetColorKey(image, SDL_SRCCOLORKEY, pixel);
SDL_SetColorKey(image, SDL_TRUE, pixel);
break;
}
}

View File

@@ -1,23 +1,22 @@
/*
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2009 Sam Lantinga
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
This library 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
Lesser General Public License for more details.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/* This is a XV thumbnail image file loading framework */

View File

@@ -1,23 +1,22 @@
/*
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2009 Sam Lantinga
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
This library 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
Lesser General Public License for more details.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/* This is a generic "format not supported" image framework */

View File

@@ -37,6 +37,4 @@ sh ./configure CPPFLAGS="-I/somewhere/include" LDFLAGS="-L/somewhere/lib"
If this works, you may need to add /somewhere/lib to your LD_LIBRARY_PATH
so shared library loading works correctly.
This library is under the GNU Library General Public License, see the file
"COPYING" for details. Certain image loaders may be under a different
license, see the individual image loader source files for details.
This library is under the zlib License, see the file "COPYING" for details.

View File

@@ -1,23 +1,22 @@
/*
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2009 Sam Lantinga
SDL_image: An example image loading library for use with SDL
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
This library 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
Lesser General Public License for more details.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/* A simple library to load images of various formats as SDL surfaces */
@@ -38,7 +37,7 @@ extern "C" {
*/
#define SDL_IMAGE_MAJOR_VERSION 1
#define SDL_IMAGE_MINOR_VERSION 2
#define SDL_IMAGE_PATCHLEVEL 11
#define SDL_IMAGE_PATCHLEVEL 13
/* This macro can be used to fill a version structure with the compile-time
* version of the SDL_image library.
@@ -60,7 +59,8 @@ typedef enum
{
IMG_INIT_JPG = 0x00000001,
IMG_INIT_PNG = 0x00000002,
IMG_INIT_TIF = 0x00000004
IMG_INIT_TIF = 0x00000004,
IMG_INIT_WEBP = 0x00000008
} IMG_InitFlags;
/* Loads dynamic libraries and prepares them for use. Flags should be
@@ -80,11 +80,19 @@ extern DECLSPEC void SDLCALL IMG_Quit(void);
surface afterwards by calling:
SDL_SetColorKey(image, SDL_RLEACCEL, image->format->colorkey);
*/
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, char *type);
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, const char *type);
/* Convenience functions */
extern DECLSPEC SDL_Surface * SDLCALL IMG_Load(const char *file);
extern DECLSPEC SDL_Surface * SDLCALL IMG_Load_RW(SDL_RWops *src, int freesrc);
#if (SDL_VERSION_ATLEAST(1,3,0))
/* Load an image directly into a render texture.
*/
extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture(SDL_Renderer *renderer, const char *file);
extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture_RW(SDL_Renderer *renderer, SDL_RWops *src, int freesrc);
extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTextureTyped_RW(SDL_Renderer *renderer, SDL_RWops *src, int freesrc, const char *type);
#endif
/* Invert the alpha of a surface for use with OpenGL
This function is now a no-op, and only provided for backwards compatibility.
*/
@@ -104,6 +112,7 @@ extern DECLSPEC int SDLCALL IMG_isTIF(SDL_RWops *src);
extern DECLSPEC int SDLCALL IMG_isXCF(SDL_RWops *src);
extern DECLSPEC int SDLCALL IMG_isXPM(SDL_RWops *src);
extern DECLSPEC int SDLCALL IMG_isXV(SDL_RWops *src);
extern DECLSPEC int SDLCALL IMG_isWEBP(SDL_RWops *src);
/* Individual loading functions */
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadICO_RW(SDL_RWops *src);
@@ -120,6 +129,7 @@ extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTIF_RW(SDL_RWops *src);
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXCF_RW(SDL_RWops *src);
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXPM_RW(SDL_RWops *src);
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXV_RW(SDL_RWops *src);
extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadWEBP_RW(SDL_RWops *src);
extern DECLSPEC SDL_Surface * SDLCALL IMG_ReadXPMFromArray(char **xpm);