- is there any way to load a bitmap from a buffer instead of a file?
ie, I’ve got this data structure that has the bitmap file read into it,
soit’s stored in memory… I want to make an sdl surface from this, and
notfrom a file on disk. Is there already a way to do this? If not, I can
write one up and submit it, maybe tonight.There isn’t a way to load a BMP from memory, just a file.
Ideally you’d be able to do both, but since the loaders are just sort of
bootstrappers, and I’ve been trying to keep the code size small, I
haven’tdone anything with it.
Maybe we should implement a simple image loader library that would handle
that? It would be an add-on library, and we could stick in BMP, GIF, and
PNGso far…
What do you mean with “load a BMP from memory”?
When you have the pixel data (and maybe palette data) in memory
(having read it from a gif file or whatever), you can simply blit it
to the screen with several memcpy()s, one for each line ('cause
pitch might not be width). The only advantage of loading it into a
SDL_Surface might be that it’s stored in video memory 'cause
hardware accelerated blits only work from video ram to video ram (right?)
However, that’s something special and should be tread specially
as well.
Tell me if I’m wrong!
- Handling text. There seems to be absolutely no way to do this. an
SDL surface isn’t recognized as a Drawable by X, so I can’t use
XDrawString… is there a solution to this yet?This is frustrating me right now as I try to implement a chat client.
Does anyone have a simple bitmap font and code to display it?That’s not the Right Way, though. Ideally, under X, SDL should be able to
use X fonts.
Allright, fonts are a little difficult but we don’t have to go mad here.
As we all know, X is not avaiable on most Windows platforms
so that is a teeny-weeny bit unportable And though I don’t know
the X font format, it’s surely much too difficult to handle. Most of us
won’t need resizable fonts but a simple, readable and quite small
font.
What I did for jump is: I wrote a “font getter” that captures the letters
from a bitmap file and writes them in monochrome into its own
format. The message font is in fact Courier New. I don’t know if there’s
any (microsoft maybe) copyright on this…
If you like, I can hack a little font loader and putter for use with SDL
in so you can use it for whatever you want. BTW, a test chat
program is something I’m really looking forward to.
Hey, another (easier?) way would be to have a function in SDL that will
let you blit from an X drawable like a Pixmap. Then i can use
XDrawString() to write to the drawable and then blit the drawable to the
SDL surface…?
But XDrawString() is only avaiable on X and any SDL function
should be completely transparent to the underlying system.~~
Paulus Esterhazy (@Paulus_Esterhazy)