@billyb123:
(1) how to put entire .png file into memory? do i put it in my var section as one big array of byte?
One of the solutions (as shown above) is to use resources.
In order to accomplish that, add the png image
to your resources inside your project options. Make sure your project gets saved correctly before compiling (otherwise errors will occur at runtime). Return to resources project options to verify that the resource was added to your project correctly. Also note the name you've given the resource.
(2) how to load it from memory? google says img_load_rw (), but i could not find usable examples
Something like the following should be able to solve your problem and loads the project's resource into a surface. It might be you need to tweak some more for your specifics.
var
sdlSpriteResource : TResourceStream;
sdlSpriteRWops : PSDL_RWops;
begin
// Create resource stream
sdlSpriteResource := TResourceStream.Create(HInstance, 'MYDATA', RT_RCDATA); // requires Classes and Windows unit
// create RWops buffer from resource. Note trick to access resource memory directly (use TMemoryStream instead to be safer).
sdlSpriteRWops:= SDL_RWFromConstMem(sdlSpriteResource.Memory, sdlSpriteResource.Size);
// done using the resource so free on earliest occasion
sdlSpriteResource.Free;
// check if RWops was created successfully
if sdlSpriteRWops = nil then HALT;
// Make sure you have this somewhere inside your init in order to add support for png images
IMG_Init(IMG_INIT_PNG);
// Create a surface from RWops buffer, automatically free RWops buffer
sdlSpriteSurface := IMG_Load_RW(sdlSpriteRWops, 1);
// Continue to use the surface as you are used to
// Finally: don't forget to eventually free the surface somewhere
end;
Note that the name of the resource should match, e.g. change 'MYDATA' to match your chosen name.