[SDL] grief loading/getting xpm in function with char *
Bob Pendleton
bob at pendleton.com
Fri Mar 7 15:11:36 PST 2008
On 3/7/08, neil at cloudsprinter.com <neil at cloudsprinter.com> wrote:
>
>
> i've had this issue before, i'm sorry if it is blaringly obvious, but
> how can i
> pass my char to the funtion IMG_ReadXPMFromArray( char **xpm )
>
> right now my function does this
>
> SDL_Surface *getimage(int mask , char *name )
> {
> /snip/
> strcat(name, "_xpm");
> surface=IMG_ReadXPMFromArray(name);
> /snip/
> };
> which gives
> warning: passing argument 1 of ?IMG_ReadXPMFromArray? from incompatible
> pointer type
The IMG_ReadXPMFromArrary() function expects the entire file to already be
in memory in a char array in memory. The function you want is IMG_Load()
which takes one argument which the the path and name of the file that
contains the .xpm. It will figure out that it is an XPM and load it. At
least it will if XPM support is compiled into the image library. You could
also use IMG_LoadXPM_RW() if you really want to make sure it treats the file
as a .xpm file. Please google for these function names to find the
documentation.
BTW, the way you are using strcat() is very dangerous. If you do not have 4
free bytes after the \0 byte at the end of each string you will wind up
corrupting the memory at the end of each string. It is better to just store
the name with the .xpm attached.
Bob Pendleton
last time i was using xpms from arrays there were a whole 4 of them,
> now i need
> to be able to use a getimage function as there are 88 images
>
> thanks
>
> ( sorry if as usual i am being a noob )
>
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
--
+ Bob Pendleton: writer and programmer
+ email: Bob at Pendleton.com
+ web: www.GameProgrammer.com
+ www.Wise2Food.com
+--------------------------------------+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20080307/7c84026e/attachment.html
More information about the SDL
mailing list