Readded window icon
parent
36e0cfbc9d
commit
0498e6e5f0
@ -0,0 +1,28 @@
|
||||
#include "imagetosurface.hpp"
|
||||
|
||||
#include <osg/Image>
|
||||
#include <SDL_surface.h>
|
||||
|
||||
namespace SDLUtil
|
||||
{
|
||||
|
||||
SDL_Surface* imageToSurface(osg::Image *image)
|
||||
{
|
||||
int width = image->s();
|
||||
int height = image->t();
|
||||
SDL_Surface* surface = SDL_CreateRGBSurface(0, width, height, 32, 0xFF000000,0x00FF0000,0x0000FF00,0x000000FF);
|
||||
|
||||
for(int x = 0; x < width; ++x)
|
||||
for(int y = 0; y < height; ++y)
|
||||
{
|
||||
osg::Vec4f clr = image->getColor(x, (height-1)-y);
|
||||
int bpp = surface->format->BytesPerPixel;
|
||||
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
|
||||
*(Uint32*)(p) = SDL_MapRGBA(surface->format, static_cast<Uint8>(clr.r() * 255),
|
||||
static_cast<Uint8>(clr.g() * 255), static_cast<Uint8>(clr.b() * 255), static_cast<Uint8>(clr.a() * 255));
|
||||
}
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef OPENMW_COMPONENTS_SDLUTIL_IMAGETOSURFACE_H
|
||||
#define OPENMW_COMPONENTS_SDLUTIL_IMAGETOSURFACE_H
|
||||
|
||||
struct SDL_Surface;
|
||||
|
||||
namespace osg
|
||||
{
|
||||
class Image;
|
||||
}
|
||||
|
||||
namespace SDLUtil
|
||||
{
|
||||
|
||||
/// Convert an osg::Image to an SDL_Surface.
|
||||
/// @note The returned surface must be freed using SDL_FreeSurface.
|
||||
SDL_Surface* imageToSurface(osg::Image* image);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue