SDL_image.pdf

(168 KB) Pobierz
20072923 UNPDF
SDLimage
24January2006
JonathanAtkins
20072923.001.png
Copyrightc 2002JonathanAtkins
Permissionisgrantedtodistributefreely,orinadistributionofanykind.Alldistributions
ofthisfilemustbeinanunalteredstate,exceptforcorrections.
Thelatestcopyofthisdocumentcanbefoundat http://jcatki.no-ip.org/SDL_image
i
TableofContents
1Overview .................................. 1
2GettingStarted ............................ 3
2.1Includes.................................................... 4
2.2Compiling.................................................. 5
3Functions ................................. 6
3.1Loading.................................................... 7
3.1.1IMGLoad............................................. 8
3.1.2IMGLoadRW......................................... 9
3.1.3IMGLoadTypedRW.................................. 10
3.1.4IMGLoadBMPRW................................... 11
3.1.5IMGLoadPNMRW................................... 12
3.1.6IMGLoadXPMRW................................... 13
3.1.7IMGLoadXCFRW................................... 14
3.1.8IMGLoadPCXRW................................... 15
3.1.9IMGLoadGIFRW.................................... 16
3.1.10IMGLoadJPGRW................................... 17
3.1.11IMGLoadTIFRW................................... 18
3.1.12IMGLoadPNGRW.................................. 19
3.1.13IMGLoadTGARW.................................. 20
3.1.14IMGLoadLBMRW.................................. 21
3.1.15IMGReadXPMFromArray............................ 22
3.2Info....................................................... 23
3.2.1IMGisBMP........................................... 24
3.2.2IMGisPNM.......................................... 25
3.2.3IMGisXPM.......................................... 26
3.2.4IMGisXCF........................................... 27
3.2.5IMGisPCX........................................... 28
3.2.6IMGisGIF............................................ 29
3.2.7IMGisJPG........................................... 30
3.2.8IMGisTIF............................................ 31
3.2.9IMGisPNG........................................... 32
3.2.10IMGisLBM.......................................... 33
3.3Errors..................................................... 34
3.3.1IMGSetError......................................... 35
3.3.2IMGGetError........................................ 36
Index ....................................... 37
20072923.002.png
Chapter1:Overview 1
1Overview
ALittleBitAboutMe
Iamcurrently,asIwritethisdocument,aprogrammerforRaytheon.ThereIdoallsorts
ofcommunications,network,GUI,andothergeneralprogrammingtasksinC/C ++ onthe
SolarisandsometimesLinuxOperatingSystems.
Feelfreetocontactme: jcatki@jcatki.no-ip.org
IamalsousuallyonIRCatirc.freenode.netinthe#SDLchannelasLIM
Whyisthisforyou?
Imagesprovidethebasicvisualbuildingblocksforanyuserinterface.Colorsandfun
shapesarethestuthatweaskidslookedatforhoursatatimewhiletryingtoshoot
downbigaliensandrescuepixelatedprincesses.Nowit’sourturntomaketheimagesthat
otherswillrememberlaterinlifeperhaps.Nowhowdowegetthisdangimagesintoour
SDLprograms,andbeflexibleinthehandlingoftheimagessothatwedon’tevenhave
toworryaboutwhatvariousformatstheymaybein?ThisiswhereSDLimagemakesall
ofourliveseasier.Thisdocumentdoesn’thelpyoumakeartwork,butitwillgiveyouthe
functionalknowledgeonhowtogetthatartintoyourgame.Nowgoforthandmakeyour
StickFigureofJustice,someoneelsemightfillinforyourlackofartistry,atleastyouwon’t
havetomakemuchofaneorttoincludethenewandbetterartintoyourcode.
Chapter1:Overview 2
ThisistheREADMEintheSDLimagesourcearchive.
SDL_image1.2
Thelatestversionofthislibraryisavailablefrom:
ThisisasimplelibrarytoloadimagesofvariousformatsasSDLsurfaces.
ThislibrarysupportsBMP,PNM(PPM/PGM/PBM),XPM,LBM,PCX,GIF,JPEG,PNG,
TGA,andTIFFformats.
API:
#include"SDL_image.h"
SDL_Surface*IMG_Load(constchar*file);
or
SDL_Surface*IMG_Load_RW(SDL_RWops*src,intfreesrc);
or
SDL_Surface*IMG_LoadTyped_RW(SDL_RWops*src,intfreesrc,char*type);
wheretypeisastringspecifyingtheformat(i.e."PNG"or"pcx").
NotethatIMG_Load_RWcannotloadTGAimages.
TocreateasurfacefromanXPMimageincludedinCsource,use:
SDL_Surface*IMG_ReadXPMFromArray(char**xpm);
Anexampleprogram’showimage’isincluded,withsourceinshowimage.c
JPEGsupportrequirestheJPEGlibrary:
PNGsupportrequiresthePNGlibrary:
andtheZliblibrary:
TIFFsupportrequirestheTIFFlibrary:
ThislibraryisundertheGNULibraryGeneralPublicLicense,seethefile
"COPYING"fordetails.Certainimageloadersmaybeunderadifferent
license,seetheindividualimageloadersourcefilesfordetails.
20072923.003.png 20072923.004.png
 
Zgłoś jeśli naruszono regulamin