[SDL] Using MSVC Bitmap Resource with SDL_Image

James Buchwald jamestheprogrammer at gmail.com
Thu Jul 26 17:48:39 PDT 2007


No, it wouldn't necessarily require an external file. You're right - you can
load stuff that's buffered in memory. What you'll have to do is load your
bitmap resource as an HBITMAP using some sort of GDI method, then convert it
into a format that can be used by an SDL_RWops. I'm not sure quite how you
would go about doing that, but that's the basics of it.

One option you might want to consider instead is to use XPM images and the
SDL_image library. The XPM format is actually a C source file (meaning it
works in C++), and you can build it right into your program by including it
like a header file. In the header file is a large array of pixel data, and
it supports transparency, too. There's a method in the SDL_image library to
convert that structure into an SDL_Surface.

Good luck.

On 7/26/07, Sam Crow <samuraileumas at yahoo.com> wrote:
>
> Leeor D. <leeor_net <at> yahoo.com> writes:
>
> > I want to embed a BMP file into my Win32 program. This is easy enough
> with
> > MSVC -- simply import it into the resource file.
> >
> > The question now is, how can I use the BMP in the embeded resource file
> with
> > SDL_Image?
>
> Since that solution isn't portable to other platforms than Windows, I'd
> suggest
> you look into RW_Ops on the documentation wiki at
> http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fRWops but I think it still
> requires
> an external file.  Secondly, the BMP loader is in the main SDL library
> rather
> than the SDL_Image library.  It should be possible with the RW_Ops
> functions to
> read a BMP file from a buffer in memory.
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>



-- 
"If you see somebody who you don't know getting into a crop duster that
doesn't belong to you, report them." -- President George W. Bush
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/private.cgi/sdl-libsdl.org/attachments/20070726/226a38ea/attachment.html 


More information about the SDL mailing list